gre/3dtextur.h

Go to the documentation of this file.
00001 /*** 
00002  * \file gre/3dtextur.h
00003  * \brief Base class for texturing algorithm
00004  *
00005  * \if NODOC
00006  * $Id: 3dtextur.h_v 1.29 2006/09/14 19:44:06 mju Exp $
00007  *
00008  * $Log: 3dtextur.h_v $
00009  * Revision 1.29  2006/09/14 19:44:06  mju
00010  * Include region2d hdr.
00011  *
00012  * Revision 1.28  2005/11/10 18:27:55  vdronov
00013  * *** empty log message ***
00014  *
00015  * Revision 1.27  2005/11/10 18:09:02  vdronov
00016  * *** empty log message ***
00017  *
00018  * Revision 1.26  2005/10/19 20:07:14  mju
00019  * Use gre namespace instead of legacy typedefs.
00020  *
00021  * Revision 1.25  2005/10/05 16:26:18  mju
00022  * Include gre base hdr.
00023  *
00024  * Revision 1.24  2005/03/15 18:49:48  mju
00025  * Remove incorrect comment.
00026  *
00027  * Revision 1.23  2004/09/20 17:37:00  vdronov
00028  * added fence drawing
00029  *
00030  * Revision 1.22  2004/09/03 16:56:35  vdronov
00031  * *** empty log message ***
00032  *
00033  * Revision 1.21  2004/08/12 22:17:23  vdronov
00034  * added SetPedestalcoordRef
00035  *
00036  * Revision 1.20  2004/08/12 19:39:10  vdronov
00037  * added ClearPedestal
00038  *
00039  * Revision 1.19  2004/08/11 23:03:51  vdronov
00040  * *** empty log message ***
00041  *
00042  * Revision 1.18  2004/08/03 20:30:04  vdronov
00043  * *** empty log message ***
00044  *
00045  * Revision 1.17  2004/07/30 19:10:05  vdronov
00046  * *** empty log message ***
00047  *
00048  * Revision 1.16  2004/06/28 20:42:43  vdronov
00049  * *** empty log message ***
00050  *
00051  * Revision 1.15  2004/06/17 17:26:47  vdronov
00052  * added formula texture class
00053  *
00054  * Revision 1.14  2004/01/14 01:21:54  vdronov
00055  * made some changes
00056  *
00057  * Revision 1.13  2003/12/22 17:50:07  vdronov
00058  * *** empty log message ***
00059  *
00060  * Revision 1.12  2003/10/02 16:18:21  linux32build!build
00061  * Doxygen
00062  *
00063  * Revision 1.11  2003/09/15 13:48:59  fileserver!dwilliss
00064  * Doxygen
00065  *
00066  * Revision 1.10  2003/08/15 17:03:05  vdronov
00067  * nc
00068  *
00069  * Revision 1.9  2003/08/15 16:55:14  vdronov
00070  * add docs
00071  *
00072  * Revision 1.8  2003/07/30 14:27:36  mju
00073  * Check inclusion guards.
00074  * Ignore private section.
00075  * Make pure virtual methods private.
00076  *
00077  * Revision 1.2  2003/03/24 20:39:15  vdronov
00078  * added forward GRE_LAYER
00079  *
00080  * Revision 1.1  2003/03/10 15:08:04  vdronov
00081  * Initial revision
00082  * \endif
00083 **/ 
00084 
00085 #ifndef  INC_GRE_3DTEXTUR_H
00086 #define  INC_GRE_3DTEXTUR_H
00087 
00088 #ifndef  INC_GRE_BASE_H
00089 #include <gre/base.h>
00090 #endif
00091 
00092 #ifndef  INC_GRE_3DUTILS_H
00093 #include <gre/3dutils.h>
00094 #endif
00095 
00096 #ifndef  INC_GRE_3DSCENE_H
00097 #include <gre/3dscene.h>
00098 #endif
00099 
00100 #ifndef  INC_MI32_REGION2D_H
00101 #include <mi32/region2d.h>
00102 #endif
00103 
00104 #ifndef  INC_MI32_MGD2_H
00105 #include <mi32/mgd2.h>
00106 #endif
00107 
00108 namespace GRE {
00109 
00110 #ifndef GENERATING_DOXYGEN_OUTPUT
00111 class TEXTUREFILTER;
00112 class CONTROLLER;
00113 class TERRAIN;
00114 class DRAWINGCONTEXT3D;
00115 class BOUNDPARM;
00116 #endif // GENERATING_DOXYGEN_OUTPUT
00117 
00118 //! Base class for 3D texture models.
00119 class TEXTURE {
00120    public:
00121 
00122    class IMPL_FACTORY {
00123       public:
00124          virtual TEXTURE *v_ConstructImpl () = 0;
00125       };
00126 
00127 #define  DECLARE_TEXTURE_IMPL_FACTORY(name,model)                    \
00128    class TEXTURE_IMPL_FACTORY_##name : public GRE::TEXTURE::IMPL_FACTORY { \
00129       public:                                               \
00130       TEXTURE_IMPL_FACTORY_##name (                            \
00131       ) { GRE::TEXTURE::Register(this,model); }                   \
00132       virtual GRE::TEXTURE *v_ConstructImpl () {                     \
00133       return (new GRE::name);                                  \
00134          }                                               \
00135       };                                                 \
00136    static TEXTURE_IMPL_FACTORY_##name s_TextureImplFactory_##name;
00137 
00138       enum MODEL {
00139          MODEL_Default = 0,
00140          MODEL_SimpleRaster = 0,
00141          MODEL_Formula = 1,
00142          MODEL_Count = 2
00143          };
00144 
00145       static void Register (
00146          IMPL_FACTORY* factory,
00147          const MODEL model
00148          );
00149 
00150       //! GetName returns a name of the given model enum
00151       //!
00152       //! @return char pointer of the name
00153       static const char* GetName (
00154          MODEL model
00155          );
00156 
00157       //! GetDescription returns a description of the given model enum
00158       //!
00159       //! @return char pointer of the description
00160       static const char* GetDescription (
00161          MODEL model
00162          );
00163 
00164       //! GetInstance returns a new instance of the given model enum
00165       //!
00166       //! @return pointer to new model
00167       static TEXTURE* GetInstance (
00168          MODEL model
00169          );
00170 
00171       virtual ~TEXTURE (                        //! Destructor
00172          );
00173 
00174       //! GetName returns a name of the model
00175       //!
00176       //! @return char pointer of the name
00177       const char* GetName (
00178          ) const;
00179 
00180       //! GetDescription returns a description of the model
00181       //!
00182       //! @return char pointer of the description
00183       const char* GetDescription (
00184          ) const;
00185 
00186       //! GetModel returns an enum of the model
00187       //!
00188       //! @return enum of the model
00189       const MODEL GetModel (
00190          ) const {return m_Model; };
00191 
00192       //! Create new instance of texture model
00193       //!
00194       //! @return instance of texture model
00195       TEXTURE* CreateInstance (
00196          ) { return v_CreateInstance(); };
00197 
00198       //!   Build internal structures for texture construction for given drape layer 
00199       //!
00200       //! @return 0 if built or < 0 if an error
00201       ERRVALUE Build (
00202          const GRE::LAYER* layer
00203          ) { return v_Build(layer); };
00204 
00205       //!   Free internal structures for texture construction 
00206       void Free (
00207          ) { v_Free(); return; };
00208 
00209       //!   Is internal structures for texture construction built? 
00210       //!
00211       //! @return true if built or false if an error
00212       bool IsBuilt (
00213          );
00214 
00215       //! Begining of texture retriving for given scene
00216       void Begin (
00217          const SCENE3D& scene
00218          ) { v_Begin(scene); return; };
00219 
00220       //! Rnding of texture retriving
00221       void End (
00222          ) { v_End(); return; };
00223 
00224       //! Get extents in map projection coordinates
00225       //!
00226       //! @return extents
00227       const DRECT2D& GetExtents (
00228          ) { return v_GetExtents(); };
00229 
00230       //! Set model map projection be used for output data
00231       void SetCoordRefSys (
00232          const SPATREF::COORDREFSYS& CoordRefSys
00233          ) { SetPedestalCoordRefSys(CoordRefSys); v_SetCoordRefSys(CoordRefSys); return; };
00234 
00235       //! Get map projection be used for output data 
00236       const SPATREF::COORDREFSYS GetCoordRefSys (
00237          ) { return v_GetCoordRefSys(); };
00238 
00239       //! Get color for given cell and depth
00240       //!
00241       //! @return true if color was retrived
00242       bool GetColor (
00243          const INT32 line,
00244          const INT32 column,
00245          const UINT8 depth,
00246          COLOR& color 
00247          ) { return v_GetColor(line, column, depth, color); };
00248 
00249       //! Get color for given point in specifyed map projection and depth
00250       //!
00251       //! @return true if color was retrived
00252       bool GetColor (
00253          const DPOINT2D& point,
00254          const UINT8 depth,
00255          COLOR& color 
00256          ) { return v_GetColor(point, depth, color); };
00257 
00258       //! Check if for given depth pyramid tier exist
00259       //!
00260       //! @return the nearest lower depth
00261       UINT8 CheckDepth (
00262          const UINT8 depth
00263          ) { return v_CheckDepth(depth); };
00264 
00265       //! Get transformation from object coordinates to specifyed map projection
00266       //!
00267       //! @return TRANS2D_MAPGEN&
00268       const TRANS2D_MAPGEN& GetTransformationInternalToModel (
00269          ) { return v_GetTransformationInternalToModel(); };
00270 
00271       //!   Set boundary wall pedestal for terrain and texture
00272       //!
00273       //! @return >= 0 if set is done
00274       ERRVALUE SetBoundaryWall (
00275          const SCENE3D& scene,
00276          TERRAIN* terrain
00277          );
00278 
00279       //!   Draw given pedestal
00280       //!
00281       //! @return >= 0 if set is done
00282       ERRVALUE DrawBoundaryWall (
00283          CONTROLLER &controller,        
00284          DRAWINGCONTEXT3D& drawing,
00285          GRE::BOUNDPARM& boundparm
00286          );
00287 
00288       const REGION2D& GetBoundary (
00289          ) { 
00290          if (m_Boundary.IsEmpty()) v_CreateBoundary(m_Boundary); 
00291          return m_Boundary;
00292          };
00293 
00294 
00295       void ClearPedestal (
00296          ) { 
00297          m_PolyLineList.Clear();
00298          return;
00299          };
00300 
00301 
00302       void ClearBoundary (
00303          ) { 
00304          m_Boundary.Clear();
00305          return;
00306          };
00307 
00308       bool IsBoundaryChanged (
00309          ) const { 
00310          return m_Boundary.IsEmpty();
00311          };
00312 
00313    protected:
00314 
00315       TEXTURE (   
00316          const char* name,
00317          const char* desc,
00318          const MODEL model
00319          );
00320 
00321       //!   Set built state? 
00322       void SetBuilt (
00323          const bool built
00324          );
00325 
00326    private:
00327 
00328       #ifndef GENERATING_DOXYGEN_OUTPUT
00329 
00330       typedef SIMPLE_ARRAY<INT32> BASEINDEX;
00331       typedef MILIST<BASEINDEX> BASEINDEXLIST;
00332 
00333       static IMPL_FACTORY* s_ImplFactories[MODEL_Count];
00334 
00335       const char* m_Name;
00336       const char* m_Description;
00337       const MODEL m_Model;
00338 
00339       bool m_Built;                             //!<  Is an object built?
00340 
00341       REGION2D m_Boundary;
00342 
00343       REGION2D m_FinalBoundary;
00344       POLYLINELIST m_PolyLineList;
00345       BASEINDEXLIST m_BaseIndexList;
00346       SPATREF::COORDREFSYS m_PolyLineCoordRefSys;
00347       TRIANGULATION m_Triangulation;
00348       SCENE3D *m_Scene;
00349 
00350       TEXTURE (   
00351          );
00352 
00353       TEXTURE (                                 //! Copy constructor (not implemented)
00354          const TEXTURE &rhs
00355          );
00356 
00357       TEXTURE& operator= (                      //! Assignment operator (not implemented)
00358          const TEXTURE& rhs
00359          );
00360 
00361       #endif // GENERATING_DOXYGEN_OUTPUT
00362 
00363       void SetPedestalCoordRefSys (
00364          const SPATREF::COORDREFSYS& CoordRefSys
00365          );
00366 
00367       virtual TEXTURE* v_CreateInstance (
00368          ) = 0;
00369 
00370       virtual ERRVALUE v_Build (
00371          const GRE::LAYER *layer
00372          ) = 0;
00373 
00374       virtual void v_Free (
00375          ) = 0;
00376 
00377       virtual void v_Begin (
00378          const SCENE3D& scene
00379          ) = 0;
00380 
00381       virtual void v_End (
00382          ) = 0;
00383 
00384       virtual const DRECT2D& v_GetExtents (
00385          ) = 0;
00386 
00387       virtual void v_CreateBoundary (
00388          REGION2D& boundary
00389          ) = 0;
00390 
00391       virtual void v_SetCoordRefSys (
00392          const SPATREF::COORDREFSYS& CoordRefSys
00393          ) = 0;
00394 
00395       virtual const SPATREF::COORDREFSYS v_GetCoordRefSys (
00396          ) = 0;
00397 
00398       virtual bool v_GetColor (
00399          const INT32 line,
00400          const INT32 column,
00401          const UINT8 depth,
00402          COLOR& color 
00403          ) = 0;
00404 
00405       virtual bool v_GetColor (
00406          const DPOINT2D& point,
00407          const UINT8 depth,
00408          COLOR& color 
00409          ) = 0;
00410 
00411       virtual UINT8 v_CheckDepth (
00412          const UINT8 depth
00413          ) = 0;
00414 
00415       virtual const TRANS2D_MAPGEN& v_GetTransformationInternalToModel (
00416          ) = 0;
00417 
00418    };
00419 
00420 }     // End of GRE namespace
00421 
00422 #endif
00423 
00424 
00425 

Generated on Thu Apr 26 04:03:30 2007 for TNTsdk by  doxygen 1.5.2