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

Generated on Thu Apr 26 04:44:38 2007 for TNTsdk by  doxygen 1.5.2