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
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
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
00095
00096
00097 static const char* GetName (
00098 MODEL model
00099 );
00100
00101
00102
00103
00104 static const char* GetDescription (
00105 MODEL model
00106 );
00107
00108
00109
00110
00111 static GEOMETRIC3D* GetInstance (
00112 MODEL model
00113 );
00114
00115 virtual ~GEOMETRIC3D (
00116 );
00117
00118
00119
00120
00121 const char* GetName (
00122 ) const;
00123
00124
00125
00126
00127 const char* GetDescription (
00128 ) const;
00129
00130
00131
00132
00133 const MODEL GetModel (
00134 ) const {return m_Model; };
00135
00136
00137
00138
00139 GEOMETRIC3D* CreateInstance (
00140 ) { return v_CreateInstance(); };
00141
00142
00143
00144
00145 bool IsTerrainNeeded (
00146 );
00147
00148
00149
00150
00151 bool IsPointsFieldNeeded (
00152 );
00153
00154
00155
00156
00157 ERRVALUE Build (
00158 const GRE::LAYER* layer
00159 ) { return v_Build(layer); };
00160
00161
00162 void Free (
00163 ) { v_Free(); return; };
00164
00165
00166
00167
00168 bool IsBuilt (
00169 );
00170
00171
00172
00173
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
00184
00185
00186 ERRVALUE DrawScene (
00187 CONTROLLER &controller,
00188 DRAWINGCONTEXT3D& drawing,
00189 TERRAIN* terrain,
00190 const bool wireframe = false
00191 );
00192
00193
00194
00195
00196 const DRECT3D& GetExtents (
00197 ) { return v_GetExtents(); };
00198
00199
00200 void SetCoordRefSys (
00201 const SPATREF::COORDREFSYS& CoordRefSys
00202 ) { v_SetCoordRefSys(CoordRefSys); return; };
00203
00204
00205 const SPATREF::COORDREFSYS GetCoordRefSys (
00206 ) { return v_GetCoordRefSys(); };
00207
00208
00209
00210
00211
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
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;
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 (
00293 const GEOMETRIC3D &rhs
00294 );
00295
00296 GEOMETRIC3D& operator= (
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 }
00332
00333 #endif
00334
00335
00336