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

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