gre/3dgeomet.h

Go to the documentation of this file.
00001 /*** 
00002  * \file gre/3dgeomet.h
00003  * \brief Base class for geometric algorithm
00004  *
00005  * \if NODOC
00006  * $Id: 3dgeomet.h_v 1.8 2006/09/18 15:43:41 mju Exp $
00007  *
00008  * $Log: 3dgeomet.h_v $
00009  * Revision 1.8  2006/09/18 15:43:41  mju
00010  * Don't inline virtuals.
00011  *
00012  * Revision 1.7  2006/02/03 16:58:06  vdronov
00013  * removed static init...
00014  *
00015  * Revision 1.6  2005/10/27 13:06:20  mju
00016  * Use gre namespace instead of legacy types.
00017  *
00018  * Revision 1.5  2005/10/05 15:39:02  mju
00019  * Include gre base hdr.
00020  *
00021  * Revision 1.4  2005/03/15 18:49:07  mju
00022  * Remove incorrect comment.
00023  *
00024  * Revision 1.1  2005/02/01 17:25:31  vdronov
00025  * Initial revision
00026  *
00027  * \endif
00028 **/ 
00029 
00030 #ifndef  INC_GRE_3DGEOMET_H
00031 #define  INC_GRE_3DGEOMET_H
00032 
00033 #ifndef  INC_GRE_BASE_H
00034 #include <gre/base.h>
00035 #endif
00036 
00037 #ifndef  INC_GRE_3DUTILS_H
00038 #include <gre/3dutils.h>
00039 #endif
00040 
00041 #ifndef  INC_GRE_3DSCENE_H
00042 #include <gre/3dscene.h>
00043 #endif
00044 
00045 #ifndef  INC_GRE_3DGMELEM_H
00046 #include <gre/3dgmelem.h>
00047 #endif
00048 
00049 namespace GRE {
00050 
00051 #ifndef GENERATING_DOXYGEN_OUTPUT
00052 class CONTROLLER;
00053 class TERRAIN;
00054 class DRAWINGCONTEXT3D;
00055 class GEOMETRIC3D_ELEMENTS;
00056 #endif // GENERATING_DOXYGEN_OUTPUT
00057 
00058 
00059 //! Base class for 3D geometric models.
00060 class GEOMETRIC3D {
00061 public:
00062 
00063    class IMPL_FACTORY {
00064       public:
00065          virtual GEOMETRIC3D *v_ConstructImpl () = 0;
00066       };
00067 
00068 #define  DECLARE_GEOMETRIC3D_IMPL_FACTORY(name,model)                   \
00069    class GEOMETRIC3D_IMPL_FACTORY_##name : public GRE::GEOMETRIC3D::IMPL_FACTORY {  \
00070       public:                                               \
00071       GEOMETRIC3D_IMPL_FACTORY_##name (                              \
00072       ) { GRE::GEOMETRIC3D::Register(this,model); }                     \
00073       virtual GRE::GEOMETRIC3D *v_ConstructImpl () {                    \
00074       return (new GRE::name);                                  \
00075          }                                               \
00076       };                                                 \
00077    static GEOMETRIC3D_IMPL_FACTORY_##name s_Geometric3DImplFactory_##name;
00078 
00079    enum MODEL {
00080       MODEL_Default = 0,
00081       MODEL_Vector = 0,
00082       MODEL_CAD = 1,
00083       MODEL_Shape = 2,
00084       MODEL_Pinmap = 3,
00085       MODEL_TIN = 4,
00086       MODEL_Count = 5
00087       };
00088 
00089    static void Register (
00090       IMPL_FACTORY* factory,
00091       const MODEL model
00092       );
00093 
00094    //! GetName returns a name of the given model enum
00095    //!
00096    //! @return char pointer of the name
00097    static const char* GetName (
00098       MODEL model
00099       );
00100 
00101    //! GetDescription returns a description of the given model enum
00102    //!
00103    //! @return char pointer of the description
00104    static const char* GetDescription (
00105       MODEL model
00106       );
00107 
00108    //! GetInstance returns a new instance of the given model enum
00109    //!
00110    //! @return pointer to new model
00111    static GEOMETRIC3D* GetInstance (
00112       MODEL model
00113       );
00114 
00115    virtual ~GEOMETRIC3D (                       //! Destructor
00116       );
00117 
00118    //! GetName returns a name of the model
00119    //!
00120    //! @return char pointer of the name
00121    const char* GetName (
00122       ) const;
00123 
00124    //! GetDescription returns a description of the model
00125    //!
00126    //! @return char pointer of the description
00127    const char* GetDescription (
00128       ) const;
00129 
00130    //! GetModel returns an enum of the model
00131    //!
00132    //! @return enum of the model
00133    const MODEL GetModel (
00134       ) const {return m_Model; };
00135 
00136    //! Create new instance of geometric model
00137    //!
00138    //! @return instance of geometric model
00139    GEOMETRIC3D* CreateInstance (
00140       ) { return v_CreateInstance(); };
00141 
00142    //!   Is terrain needed for geometric construction 
00143    //!
00144    //! @return true id needed or false if not
00145    bool IsTerrainNeeded (
00146       );
00147 
00148    //!   Is points field needed for geometric construction 
00149    //!
00150    //! @return true id needed or false if not
00151    bool IsPointsFieldNeeded (
00152       );
00153 
00154    //!   Build internal structures for geometric construction for given drape layer 
00155    //!
00156    //! @return 0 if built or < 0 if an error
00157    ERRVALUE Build (
00158       const GRE::LAYER* layer
00159       ) { return v_Build(layer); };
00160 
00161    //!   Free internal structures for geometric construction 
00162    void Free (
00163       ) { v_Free(); return; };
00164 
00165    //!   Is internal structures for geometric construction built? 
00166    //!
00167    //! @return true if built or false if an error
00168    bool IsBuilt (
00169       );
00170 
00171    //!   Draw given geometric
00172    //!
00173    //! @return >= 0 if set is done
00174    void SetScene (
00175       SCENE3D& scene
00176       ) { 
00177       m_Scene = &scene; 
00178       m_Viewer = DPOINT3D(m_Scene->GetViewer().x, m_Scene->GetViewer().y, m_Scene->GetViewer().z);
00179       m_Direction = DPOINT3D(m_Scene->GetDirection().x, m_Scene->GetDirection().y, m_Scene->GetDirection().z);
00180       return; 
00181       };
00182 
00183    //!   Draw given geometric
00184    //!
00185    //! @return >= 0 if set is done
00186    ERRVALUE DrawScene (
00187       CONTROLLER &controller,        
00188       DRAWINGCONTEXT3D& drawing,
00189       TERRAIN* terrain,
00190       const bool wireframe = false
00191       );
00192 
00193    //! Get extents in map projection coordinates
00194    //!
00195    //! @return extents
00196    const DRECT3D& GetExtents (
00197       ) { return v_GetExtents(); };
00198 
00199    //! Set model map projection be used for output data
00200    void SetCoordRefSys (
00201       const SPATREF::COORDREFSYS& CoordRefSys
00202       ) { v_SetCoordRefSys(CoordRefSys); return; };
00203 
00204    //! Get map projection be used for output data 
00205    const SPATREF::COORDREFSYS GetCoordRefSys (
00206       ) { return v_GetCoordRefSys(); };
00207 
00208 
00209    //! Get transformation from object coordinates to specifyed map projection
00210    //!
00211    //! @return TRANS2D_MAPGEN&
00212    const TRANS2D_MAPGEN& GetTransformationInternalToModel (
00213       ) { return v_GetTransformationInternalToModel(); };
00214 
00215 protected:
00216 
00217    GEOMETRIC3D (  
00218       const char* name,
00219       const char* desc,
00220       const MODEL model
00221       );
00222 
00223    //!   Set built state? 
00224    void SetBuilt (
00225       const bool built
00226       );
00227 
00228    void AppendElements (
00229       GEOMETRIC3D_ELEMENTS* elements
00230       ) { m_ElementsArray.Append(elements); return; };
00231 
00232    void ClearElements (
00233       );
00234 
00235    double ComputeScaleForPoint (
00236       const DPOINT2D& point
00237       );
00238 
00239 private:
00240 
00241    #ifndef GENERATING_DOXYGEN_OUTPUT
00242 
00243    class BUILDER_IMPL : public GEOMETRIC3D_BUILDER {
00244    public :
00245 
00246       BUILDER_IMPL (
00247          const GEOMETRIC3D& geometric
00248          ) : m_Geometric(geometric) {};
00249 
00250       ~BUILDER_IMPL (
00251          ) {};
00252 
00253    private:
00254 
00255       const GEOMETRIC3D& m_Geometric;
00256 
00257       BUILDER_IMPL (
00258          );
00259 
00260       void OnConstruction (
00261          GRE::TRIANGULATION& triangulation
00262          );
00263 
00264       void OnConstruction (
00265          GRE::PIXALIZATION& pixalization
00266          );
00267 
00268       friend class GEOMETRIC3D;
00269       };
00270 
00271    static IMPL_FACTORY* s_ImplFactories[MODEL_Count];
00272 
00273    const char* m_Name;
00274    const char* m_Description;
00275    const MODEL m_Model;
00276    BUILDER_IMPL m_Builder;
00277 
00278    bool m_Built;                             //!<  Is an object built?
00279 
00280    SCENE3D *m_Scene;
00281    DPOINT3D m_Viewer;
00282    DPOINT3D m_Direction;
00283    CONTROLLER* m_Controller;
00284    DRAWINGCONTEXT3D* m_Drawing;
00285    TERRAIN* m_Terrain;
00286 
00287    GEOMETRIC3D_ELEMENTS_ARRAY m_ElementsArray;
00288 
00289    GEOMETRIC3D (  
00290       );
00291 
00292    GEOMETRIC3D (                                //! Copy constructor (not implemented)
00293       const GEOMETRIC3D &rhs
00294       );
00295 
00296    GEOMETRIC3D& operator= (                        //! Assignment operator (not implemented)
00297       const GEOMETRIC3D& rhs
00298       );
00299 
00300    #endif // GENERATING_DOXYGEN_OUTPUT
00301 
00302    virtual GEOMETRIC3D* v_CreateInstance (
00303       ) = 0;
00304 
00305    virtual ERRVALUE v_Build (
00306       const GRE::LAYER *layer
00307       ) = 0;
00308 
00309    virtual void v_Free (
00310       ) = 0;
00311 
00312    virtual const DRECT3D& v_GetExtents (
00313       ) = 0;
00314 
00315    virtual void v_SetCoordRefSys (
00316       const SPATREF::COORDREFSYS& CoordRefSys
00317       ) = 0;
00318 
00319    virtual const SPATREF::COORDREFSYS v_GetCoordRefSys (
00320       ) = 0;
00321 
00322    virtual const TRANS2D_MAPGEN& v_GetTransformationInternalToModel (
00323       ) = 0;
00324 
00325    virtual void OnDrawBegin (GRE::GEOMETRIC3D_BUILDER* builder, const bool wireframe = false);
00326 
00327    virtual void OnDrawEnd ();
00328 
00329    };
00330 
00331 }     // End of GRE namespace
00332 
00333 #endif
00334 
00335 
00336 

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