00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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
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
00092
00093
00094 static const char* GetName (
00095 MODEL model
00096 );
00097
00098
00099
00100
00101 static const char* GetDescription (
00102 MODEL model
00103 );
00104
00105
00106
00107
00108 static GEOMETRIC3D* GetInstance (
00109 MODEL model
00110 );
00111
00112 virtual ~GEOMETRIC3D (
00113 );
00114
00115
00116
00117
00118 const char* GetName (
00119 ) const;
00120
00121
00122
00123
00124 const char* GetDescription (
00125 ) const;
00126
00127
00128
00129
00130 const MODEL GetModel (
00131 ) const {return m_Model; };
00132
00133
00134
00135
00136 GEOMETRIC3D* CreateInstance (
00137 ) { return v_CreateInstance(); };
00138
00139
00140
00141
00142 bool IsTerrainNeeded (
00143 );
00144
00145
00146
00147
00148 bool IsPointsFieldNeeded (
00149 );
00150
00151
00152
00153
00154 ERRVALUE Build (
00155 const GRE::LAYER* layer
00156 ) { return v_Build(layer); };
00157
00158
00159 void Free (
00160 ) { v_Free(); return; };
00161
00162
00163
00164
00165 bool IsBuilt (
00166 );
00167
00168
00169
00170
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
00181
00182
00183 ERRVALUE DrawScene (
00184 CONTROLLER &controller,
00185 DRAWINGCONTEXT3D& drawing,
00186 TERRAIN* terrain,
00187 const bool wireframe = false
00188 );
00189
00190
00191
00192
00193 const DRECT3D& GetExtents (
00194 ) { return v_GetExtents(); };
00195
00196
00197 void SetCoordRefSys (
00198 const SPATREF::COORDREFSYS& CoordRefSys
00199 ) { v_SetCoordRefSys(CoordRefSys); return; };
00200
00201
00202 const SPATREF::COORDREFSYS GetCoordRefSys (
00203 ) { return v_GetCoordRefSys(); };
00204
00205
00206
00207
00208
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
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;
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 (
00290 const GEOMETRIC3D &rhs
00291 );
00292
00293 GEOMETRIC3D& operator= (
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 }
00329
00330 #endif
00331
00332
00333