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

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