3dvtter.h

Go to the documentation of this file.
00001 /**
00002  * \file gre/3dlpter.h 
00003  * \brief Implementation of terrain algorithm
00004  *
00005  * \if NODOC
00006  * $Id: 3dvtter.h_v 1.7 2004/09/03 16:57:03 vdronov Exp $
00007  *
00008  * $Log: 3dvtter.h_v $
00009  * Revision 1.7  2004/09/03 16:57:03  vdronov
00010  * *** empty log message ***
00011  *
00012  * Revision 1.6  2004/08/11 23:04:55  vdronov
00013  * *** empty log message ***
00014  *
00015  * Revision 1.5  2004/07/30 19:09:01  vdronov
00016  * *** empty log message ***
00017  *
00018  * Revision 1.4  2004/06/29 15:22:58  vdronov
00019  * *** empty log message ***
00020  *
00021  * Revision 1.3  2003/10/02 16:18:21  linux32build!build
00022  * Doxygen
00023  *
00024  * Revision 1.2  2003/09/26 17:19:26  vdronov
00025  * added core algorithm
00026  *
00027  * Revision 1.1  2003/08/26 15:33:25  vdronov
00028  * Initial revision
00029  * \endif
00030  *
00031 **/ 
00032 
00033 #ifndef  INC_GRE_3DLPTER_H
00034 #define  INC_GRE_3DLPTER_H
00035 
00036 #ifndef  INC_GRE_3DTERRA_H
00037 #include <gre/3dterra.h>
00038 #endif
00039 
00040 #ifndef  INC_MI32_ASURFACE_H
00041 #include <mi32/asurface.h>
00042 #endif
00043 
00044 #ifndef  INC_MI32_SIMPLEAR_H
00045 #include <mi32/simplear.h>
00046 #endif
00047 
00048 #ifndef  INC_RVC_OBJECT_H
00049 #include <rvc/object.h>
00050 #endif
00051 
00052 #ifndef  INC_RVC_GEOREFER_H
00053 #include <rvc/georefer.h>
00054 #endif
00055 
00056 #include <map>
00057 
00058 namespace GRE {
00059 
00060 class VARIABLETRIANGULATION : public TERRAIN {
00061    public:
00062 
00063       VARIABLETRIANGULATION (                               // Constructor 
00064          );
00065 
00066       ~VARIABLETRIANGULATION (                              // Destructor 
00067          );
00068 
00069    private:
00070       #ifndef GENERATING_DOXYGEN_OUTPUT
00071 
00072       enum DIRECTION {
00073          DIRECTION_N  = 0,
00074          DIRECTION_NE = 1,
00075          DIRECTION_E  = 2,
00076          DIRECTION_SE = 3,
00077          DIRECTION_S  = 4,
00078          DIRECTION_SW = 5,
00079          DIRECTION_W  = 6,
00080          DIRECTION_NW = 7,
00081          DIRECTION_Count = 8
00082          };
00083 
00084       typedef std::map<INT32, DPOINT3D> VERTEXMAP; 
00085 
00086       struct PROPERTY {
00087          FLOAT m_Error;
00088          FLOAT m_Radius;
00089 
00090          PROPERTY () : m_Error(-1.0F), m_Radius(-1.0F) {};
00091          PROPERTY (const float error, const float radius) : m_Error(error), m_Radius(radius) {};
00092          bool IsSet () const { return (m_Error != -1.0F); };
00093          };
00094 
00095 
00096       struct BLOCK {
00097 
00098          DRECT3D m_Extents;
00099          double m_Elevation;
00100          float m_Error;
00101          float m_Radius;
00102 
00103          BLOCK () : m_Elevation(0.0) {};
00104          };
00105 
00106       static const bool s_Parity[DIRECTION_Count];
00107       static const INT32 s_SX[DIRECTION_Count];
00108       static const INT32 s_SY[DIRECTION_Count];
00109       static const DIRECTION s_DirectionL[DIRECTION_Count];
00110       static const DIRECTION s_DirectionR[DIRECTION_Count];
00111       static const INT32 s_MX[DIRECTION_Count];
00112       static const INT32 s_MY[DIRECTION_Count];
00113 
00114       ABSTRACT_SURFACE *m_Surface;
00115       DRECT3D m_Extents;
00116       SPATREF::COORDREFSYS m_CoordRefSys;
00117       TRANS2D_MAPGEN m_Transformation;
00118 
00119       RVC::RASTER m_DEM;
00120       RVC::OBJECT m_File;
00121       RVC::RASTER m_Error;
00122       RVC::RASTER m_Radius;
00123       DOUBLE_ARRAY<double> m_BlockDEM;
00124       SIMPLE_ARRAY<float> m_BlockError;
00125       SIMPLE_ARRAY<float> m_BlockRadius;
00126       SIMPLE_ARRAY<INT32> m_Index;
00127       double m_ZDefaults[3][3];
00128 
00129       bool m_Parity;
00130       double m_Value;
00131       DPOINT3D m_Viewer;
00132 
00133       INT32 m_BlockSize;
00134       INT32 m_HalfBlockSize;
00135       INT32 m_BlockSizePlus;
00136       INT32 m_BlockCells;
00137       INT32 m_BlockColumn;
00138       INT32 m_BlockLine;
00139       INT32 m_NumBlocks;
00140       INT32 m_XBlocks;
00141       INT32 m_YBlocks;
00142       BITSET m_BlockBits;  
00143       DOUBLE_ARRAY<BLOCK> m_Blocks;
00144 
00145       INT32 m_XLNodes;
00146       INT32 m_YLNodes;
00147       INT32 m_NumLNodes;
00148       DOUBLE_ARRAY<double> m_LevelDEM;
00149 
00150       VERTEXMAP m_VertexMap;
00151       TRIANGULATION m_Triangulation;
00152       SCENE3D *m_Scene;
00153       CONTROLLER *m_Controller;
00154       DRAWINGCONTEXT3D *m_Drawing;
00155 
00156       double m_Scale;
00157       double m_ScaleSqrt2;
00158       double m_ZMin;
00159       double m_ZMax;
00160       double m_ZDefault;
00161       bool m_HasNullValue;
00162       double m_NullValue;
00163 
00164       STATUSCONTEXT* m_StatusContext;
00165 
00166       VARIABLETRIANGULATION& operator= (                       // Assignment operator (not implemented)
00167          const VARIABLETRIANGULATION& rhs
00168          );
00169 
00170       static void GetCorners (
00171          const DRECT3D& rect,
00172          DPOINT3D points[8]
00173          );
00174 
00175       // Create new instance of terrain model
00176       //
00177       // @return instance of texture model
00178       TERRAIN* v_CreateInstance (
00179          ) { return new VARIABLETRIANGULATION(); };
00180 
00181       // Build internal structures for terrain decimation 
00182       //
00183       // @return 0 if OKey or < 0 if an error
00184       ERRVALUE v_Build (
00185          const GRE_LAYER *layer
00186          );
00187 
00188       bool v_IsObjectTypeSupported (
00189          const RVC::OBJTYPE objtype
00190          ) const { return (objtype == RVC::OBJTYPE_Raster); };
00191 
00192       // Free internal structures for terrain decimation 
00193       //
00194       // @return none
00195       void v_Free (
00196          );
00197 
00198       ERRVALUE Create (              
00199          const GRE_LAYER *layer
00200          );
00201 
00202       void Delete (               
00203          );
00204 
00205       ERRVALUE v_GetDefaultScene ( 
00206          SCENE3D& scene
00207          ) const;
00208 
00209       // Set scene by viewer and center positions and angle of field of view.
00210       //
00211       // @return none
00212       ERRVALUE v_SetScene (
00213          const SCENE3D& scene,
00214          const SIMPLE_ARRAY<TEXTURE*> &textures   
00215          );
00216 
00217       ERRVALUE v_DrawScene (
00218          CONTROLLER &controller,        
00219          DRAWINGCONTEXT3D& drawing,
00220          TEXTURE* texture,
00221          TEXTUREFILTER* texturefilter
00222          );
00223 
00224       // Get elevation at model coordinates (x, y)
00225       float v_GetElevation (
00226          const float x,
00227          const float y
00228          ) const;
00229 
00230       ERRVALUE v_ComputeProfile (
00231          const POLYLINE& polyline,
00232          POLYLINE& profile,
00233          SIMPLE_ARRAY<INT32>& index
00234          );
00235 
00236       // Get angle to elevation at model coordinates (x, y)
00237       float v_GetAngleToNorth (
00238          const float x,
00239          const float y
00240          ) const;
00241 
00242       const ABSTRACT_SURFACE* v_GetAbstractSurface (
00243          ) { return m_Surface; }
00244 
00245       bool v_HasNull (
00246          ) const { return m_HasNullValue; };
00247 
00248       bool v_IsNull (
00249          const float x,
00250          const float y
00251          ) const;
00252 
00253       void v_SetCoordRefSys (
00254          const SPATREF::COORDREFSYS& CoordRefSys
00255          );
00256 
00257       const SPATREF::COORDREFSYS v_GetCoordRefSys (
00258          ) const { return m_CoordRefSys; };
00259 
00260       const DRECT3D& v_GetExtents (
00261          ) { return m_Extents; };
00262 
00263       void v_CreateBoundary (
00264          REGION2D& boundary
00265          );
00266 
00267       ERRVALUE CreateBlocks (
00268          const TRANS2D_MAPGEN& transformation
00269          );
00270 
00271       void DeleteBlocks (
00272          );
00273 
00274       bool IsBlockValid (
00275          const INT32 column,
00276          const INT32 line
00277          ) {return ((0 <= column) && (column < m_XBlocks) && (0 <= line) && (line < m_YBlocks)); };
00278 
00279       ERRVALUE SetSceneForBlocks (
00280          const SCENE3D& scene,
00281          const SIMPLE_ARRAY<TEXTURE*> &textures   
00282          );
00283 
00284       ERRVALUE DrawSceneForBlocks (
00285          CONTROLLER &controller,        
00286          DRAWINGCONTEXT3D& drawing,
00287          TEXTURE* texture,
00288          TEXTUREFILTER* texturefilter
00289          );
00290 
00291       void TransformBlocks (
00292          const TRANS2D_MAPGEN& transformation
00293          );
00294 
00295       ERRVALUE MakePropertyRasters (
00296          );
00297 
00298 
00299       ERRVALUE CalculatePropertyRasters (
00300          );
00301 
00302 
00303       ERRVALUE ReadDataBlock (
00304          const INT32 index
00305          );
00306 
00307       void CalculateZDefaults (
00308          const INT32 index
00309          );
00310 
00311       double GetZDefault (
00312          const INT32 column,
00313          const INT32 line
00314          );
00315 
00316       double CalculateZDefault (
00317          const INT32 column,
00318          const INT32 line
00319          );
00320 
00321       ERRVALUE CalculateProperty (
00322          const INT32 x,
00323          const INT32 y,
00324          const INT32 length,
00325          const DIRECTION direction,
00326          PROPERTY& property
00327          );
00328 
00329       FLOAT CalculateError (
00330          const INT32 x,
00331          const INT32 y,
00332          const INT32 length,
00333          const DIRECTION direction
00334          );
00335 
00336       FLOAT CalculateRadius (
00337          const INT32 x,
00338          const INT32 y,
00339          const INT32 length,
00340          const DIRECTION direction
00341          );
00342 
00343       ERRVALUE SubMeshRefine (
00344          const INT32 px,
00345          const INT32 py,
00346          const INT32 length,
00347          const DIRECTION direction,
00348          const INT32 level
00349          );
00350 
00351       ERRVALUE VertexAppend (
00352          const INT32 x,
00353          const INT32 y,
00354          const bool parity
00355          );
00356 
00357       bool IsVertexActive (
00358          const INT32 x,
00359          const INT32 y
00360          );
00361 
00362       void MakeVertex (
00363          const INT32 x,
00364          const INT32 y,
00365          const INT32 index,
00366          DPOINT3D& point
00367          );
00368 
00369 
00370       INT32 CalculateIndex (
00371          const INT32 x,
00372          const INT32 y
00373          );
00374 
00375       void GetBlockProperty (
00376          const INT32 index,
00377          PROPERTY& property
00378          );
00379 
00380       float GetBlockError (
00381          const INT32 index
00382          );
00383 
00384       float GetBlockRadius (
00385          const INT32 index
00386          );
00387 
00388       double GetBlockElevation (
00389          const INT32 index
00390          );
00391 
00392       void SetRasterProperty (
00393          const INT32 x,
00394          const INT32 y,
00395          PROPERTY& property
00396          );
00397 
00398       void GetRasterProperty (
00399          const INT32 x,
00400          const INT32 y,
00401          PROPERTY& property
00402          );
00403 
00404       double GetRasterElevation (
00405          const INT32 x,
00406          const INT32 y,
00407          const bool check = true
00408          );
00409 
00410       #endif // GENERATING_DOXYGEN_OUTPUT
00411    };
00412 
00413 };    // End of namespace
00414 
00415 #endif
00416 

Generated on Tue Dec 14 13:18:12 2004 for TNTsdk by  doxygen 1.3.8-20040913