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

Generated on Wed May 31 15:26:38 2006 for TNTsdk by  doxygen 1.3.8-20040913