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.19 2005/10/05 15:49:02 mju Exp $
00007  *
00008  * $Log: 3dvtter.h_v $
00009  * Revision 1.19  2005/10/05 15:49:02  mju
00010  * Include gre base hdr.
00011  *
00012  * Revision 1.18  2005/08/19 15:12:52  vdronov
00013  * rollback to 1.16
00014  *
00015  * Revision 1.17  2005/08/17 20:14:25  vdronov
00016  * added static MakeSurfaceProperties.
00017  *
00018  * Revision 1.16  2005/06/27 17:12:30  vdronov
00019  * added nulmask handling
00020  *
00021  * Revision 1.15  2005/06/17 17:05:35  vdronov
00022  * added savings optimization structure
00023  *
00024  * Revision 1.14  2005/03/31 23:50:02  vdronov
00025  * *** empty log message ***
00026  *
00027  * Revision 1.13  2005/02/17 17:57:43  vdronov
00028  * *** empty log message ***
00029  *
00030  * Revision 1.12  2005/01/12 23:01:05  vdronov
00031  * added some modifications fot data structure
00032  *
00033  * Revision 1.11  2004/12/23 15:52:41  vdronov
00034  * nc
00035  *
00036  * Revision 1.10  2004/12/22 23:45:29  vdronov
00037  * replaced plainar properties by pyramid properties
00038  *
00039  * Revision 1.9  2004/12/10 22:35:18  vdronov
00040  * added ErrorTolerance
00041  *
00042  * Revision 1.8  2004/12/01 18:42:09  vdronov
00043  * ALIGN
00044  *
00045  * Revision 1.7  2004/09/03 16:57:03  vdronov
00046  * *** empty log message ***
00047  *
00048  * Revision 1.6  2004/08/11 23:04:55  vdronov
00049  * *** empty log message ***
00050  *
00051  * Revision 1.5  2004/07/30 19:09:01  vdronov
00052  * *** empty log message ***
00053  *
00054  * Revision 1.4  2004/06/29 15:22:58  vdronov
00055  * *** empty log message ***
00056  *
00057  * Revision 1.3  2003/10/02 16:18:21  linux32build!build
00058  * Doxygen
00059  *
00060  * Revision 1.2  2003/09/26 17:19:26  vdronov
00061  * added core algorithm
00062  *
00063  * Revision 1.1  2003/08/26 15:33:25  vdronov
00064  * Initial revision
00065  * \endif
00066  *****
00067 **/ 
00068 
00069 #ifndef  INC_GRE_3DLPTER_H
00070 #define  INC_GRE_3DLPTER_H
00071 
00072 #ifndef  INC_GRE_BASE_H
00073 #include <gre/base.h>
00074 #endif
00075 
00076 #ifndef  INC_GRE_3DTERRA_H
00077 #include <gre/3dterra.h>
00078 #endif
00079 
00080 #ifndef  INC_MI32_ASURFACE_H
00081 #include <mi32/asurface.h>
00082 #endif
00083 
00084 #ifndef  INC_MI32_SIMPLEAR_H
00085 #include <mi32/simplear.h>
00086 #endif
00087 
00088 #ifndef  INC_RVC_OBJECT_H
00089 #include <rvc/object.h>
00090 #endif
00091 
00092 #ifndef  INC_RVC_GEOREFER_H
00093 #include <rvc/georefer.h>
00094 #endif
00095 
00096 #ifndef  INC_RVC_NULLMASK_H
00097 #include <rvc/nullmask.h>
00098 #endif
00099 
00100 #include <map>
00101 
00102 namespace GRE {
00103 
00104 class VARIABLETRIANGULATION : public TERRAIN {
00105    public:
00106 
00107       VARIABLETRIANGULATION (                               // Constructor 
00108          );
00109 
00110       ~VARIABLETRIANGULATION (                              // Destructor 
00111          );
00112 
00113       void SetErrorTolerance (
00114          double tolerance
00115          ) { m_ErrorTolerance = bound(tolerance, 0.5, 10.0); return; };
00116 
00117       double GetErrorTolerance (
00118          ) const { return m_ErrorTolerance; };
00119 
00120       ERRVALUE SaveSurfaceProperties (
00121          );
00122 
00123       bool CanSaveSurfaceProperties (
00124          );
00125 
00126       bool HasSurfaceProperties (
00127          );
00128 
00129    private:
00130 
00131       #ifndef GENERATING_DOXYGEN_OUTPUT
00132 
00133       enum DIRECTION {
00134          DIRECTION_N  = 0,
00135          DIRECTION_NE = 1,
00136          DIRECTION_E  = 2,
00137          DIRECTION_SE = 3,
00138          DIRECTION_S  = 4,
00139          DIRECTION_SW = 5,
00140          DIRECTION_W  = 6,
00141          DIRECTION_NW = 7,
00142          DIRECTION_Count = 8
00143          };
00144 
00145       typedef std::map<INT32, DPOINT3D> VERTEXMAP; 
00146 
00147       struct PROPERTY {
00148          float m_Elevation;      // Important to have it as first member
00149          float m_Error;
00150          float m_Radius;
00151 
00152          PROPERTY () : m_Elevation(-1.0F), m_Error(-1.0F), m_Radius(-1.0F) {};
00153          PROPERTY (const float elevation, const float error, const float radius) : 
00154             m_Elevation(elevation), m_Error(error), m_Radius(radius) {};
00155          };
00156 
00157       static const bool s_Parity[DIRECTION_Count];
00158       static const INT32 s_SX[DIRECTION_Count];
00159       static const INT32 s_SY[DIRECTION_Count];
00160       static const DIRECTION s_DirectionL[DIRECTION_Count];
00161       static const DIRECTION s_DirectionR[DIRECTION_Count];
00162       static const INT32 s_MX[DIRECTION_Count];
00163       static const INT32 s_MY[DIRECTION_Count];
00164 
00165       GRE_LAYER_SURFACE* m_Layer;
00166       ABSTRACT_SURFACE *m_Surface;
00167       DRECT3D ALIGN16(m_Extents);
00168       SPATREF::COORDREFSYS m_CoordRefSys;
00169       TRANS2D_MAPGEN m_Transformation;
00170       bool m_AreSurfacePropertiesCreated;
00171       bool m_IsCreatedInside;
00172 
00173       RVC::RASTER m_DEM;
00174       SIMPLE_ARRAY<INT32> m_Index;
00175       double ALIGN8(m_ZDefaults[3][3]);
00176 
00177       bool m_Parity;
00178       double ALIGN8(m_Value);
00179       double ALIGN8(m_ErrorTolerance);
00180       DPOINT3D ALIGN16(m_Viewer);
00181 
00182       INT32 m_BlockSize;
00183       INT32 m_HalfBlockSize;
00184       INT32 m_BlockSizePlus;
00185       INT32 m_BlockCells;
00186       INT32 m_BlockColumn;
00187       INT32 m_BlockLine;
00188       INT32 m_NumBlocks;
00189       INT32 m_XBlocks;
00190       INT32 m_YBlocks;
00191       INT32 m_XSize;
00192       INT32 m_YSize;
00193       BITSET m_BlockBits;  
00194       DOUBLE_ARRAY<DRECT3D> m_BlockExtents;
00195 
00196       VERTEXMAP m_VertexMap;
00197       TRIANGULATION m_Triangulation;
00198       SCENE3D *m_Scene;
00199       CONTROLLER *m_Controller;
00200       DRAWINGCONTEXT3D *m_Drawing;
00201 
00202       double ALIGN8(m_DataScale);
00203       double ALIGN8(m_Scale);
00204       double ALIGN8(m_ScaleSqrt2);
00205       double ALIGN8(m_ZMin);
00206       double ALIGN8(m_ZMax);
00207       double ALIGN8(m_ZDefault);
00208 
00209       RVC::OBJECT m_File;
00210       RVC::NULLMASK m_NullMask;
00211       RVC::RASTER m_Corners;
00212       SIMPLE_ARRAY<RVC::RASTER*> m_WhiteH;
00213       SIMPLE_ARRAY<RVC::RASTER*> m_HBlackH;
00214       SIMPLE_ARRAY<RVC::RASTER*> m_VBlackH;
00215       SIMPLE_ARRAY<RVC::RASTER*> m_WhiteE;
00216       SIMPLE_ARRAY<RVC::RASTER*> m_HBlackE;
00217       SIMPLE_ARRAY<RVC::RASTER*> m_VBlackE;
00218       SIMPLE_ARRAY<RVC::RASTER*> m_WhiteR;
00219       SIMPLE_ARRAY<RVC::RASTER*> m_HBlackR;
00220       SIMPLE_ARRAY<RVC::RASTER*> m_VBlackR;
00221       INT32 m_LevelSize;
00222       INT32 m_LevelMask;
00223       SIMPLE_ARRAY<UINT8> m_LevelIndex;
00224       RVC::OBJECT m_ComputedSetFile;
00225       RVC::RASTER m_ComputedSetRaster;
00226       
00227       VARIABLETRIANGULATION& operator= (                       // Assignment operator (not implemented)
00228          const VARIABLETRIANGULATION& rhs
00229          );
00230 
00231       static void GetCorners (
00232          const DRECT3D& rect,
00233          DPOINT3D points[8]
00234          );
00235 
00236       // Create new instance of terrain model
00237       //
00238       // @return instance of texture model
00239       TERRAIN* v_CreateInstance (
00240          ) { return new VARIABLETRIANGULATION(); };
00241 
00242       // Build internal structures for terrain decimation 
00243       //
00244       // @return 0 if OKey or < 0 if an error
00245       ERRVALUE v_Build (
00246          const GRE_LAYER *layer
00247          );
00248 
00249       bool v_IsObjectTypeSupported (
00250          const RVC::OBJTYPE objtype
00251          ) const { return (objtype == RVC::OBJTYPE_Raster); };
00252 
00253       // Free internal structures for terrain decimation 
00254       //
00255       // @return none
00256       void v_Free (
00257          );
00258 
00259       ERRVALUE Create (              
00260          const GRE_LAYER *layer
00261          );
00262 
00263       void Delete (               
00264          );
00265 
00266       ERRVALUE v_GetDefaultScene ( 
00267          SCENE3D& scene
00268          ) const;
00269 
00270       // Set scene by viewer and center positions and angle of field of view.
00271       //
00272       // @return none
00273       ERRVALUE v_SetScene (
00274          const SCENE3D& scene,
00275          const SIMPLE_ARRAY<TEXTURE*> &textures   
00276          );
00277 
00278       ERRVALUE v_DrawScene (
00279          CONTROLLER &controller,        
00280          DRAWINGCONTEXT3D& drawing,
00281          TEXTURE* texture,
00282          TEXTUREFILTER* texturefilter
00283          );
00284 
00285       ERRVALUE v_SetScene (
00286          const SCENE3D& scene,
00287          const SIMPLE_ARRAY<GEOMETRIC3D*> &geometrics,
00288          const bool wireframe
00289          );
00290 
00291       // Get elevation at model coordinates (x, y)
00292       float v_GetElevation (
00293          const float x,
00294          const float y
00295          ) const;
00296 
00297       ERRVALUE v_ComputeProfile (
00298          const POLYLINE& polyline,
00299          POLYLINE& profile,
00300          SIMPLE_ARRAY<INT32>& index
00301          );
00302 
00303       // Get angle to elevation at model coordinates (x, y)
00304       float v_GetAngleToNorth (
00305          const float x,
00306          const float y
00307          ) const;
00308 
00309       const ABSTRACT_SURFACE* v_GetAbstractSurface (
00310          ) { return m_Surface; }
00311 
00312       bool v_HasNull (
00313          ) const { return true; };   //to check boundary condition
00314 
00315       bool v_IsNull (
00316          const float x,
00317          const float y
00318          ) const;
00319 
00320       void v_SetCoordRefSys (
00321          const SPATREF::COORDREFSYS& CoordRefSys
00322          );
00323 
00324       const SPATREF::COORDREFSYS v_GetCoordRefSys (
00325          ) const { return m_CoordRefSys; };
00326 
00327       const DRECT3D& v_GetExtents (
00328          ) { return m_Extents; };
00329 
00330       void v_CreateBoundary (
00331          REGION2D& boundary
00332          );
00333 
00334       ERRVALUE CreateBlocks (
00335          const TRANS2D_MAPGEN& transformation
00336          );
00337 
00338       void DeleteBlocks (
00339          );
00340 
00341       bool IsBlockValid (
00342          const INT32 column,
00343          const INT32 line
00344          ) {return ((0 <= column) && (column < m_XBlocks) && (0 <= line) && (line < m_YBlocks)); };
00345 
00346       ERRVALUE SetSceneForBlocks (
00347          const SCENE3D& scene,
00348          const SIMPLE_ARRAY<TEXTURE*> &textures   
00349          );
00350 
00351       ERRVALUE SetSceneForBlocks (
00352          const SCENE3D& scene,
00353          const SIMPLE_ARRAY<GEOMETRIC3D*> &geometrics,
00354          const bool wireframe
00355          );
00356 
00357       ERRVALUE DrawSceneForBlocks (
00358          CONTROLLER &controller,        
00359          DRAWINGCONTEXT3D& drawing,
00360          TEXTURE* texture,
00361          TEXTUREFILTER* texturefilter,
00362          const DRAW3DMODE draw3Dmode = DRAW3DMODE_Texture
00363          );
00364 
00365       void TransformBlocks (
00366          const TRANS2D_MAPGEN& transformation
00367          );
00368 
00369       ERRVALUE DefineSurfaceProperties (
00370          );
00371 
00372       ERRVALUE MakeSurfaceProperties (
00373          RVC::OBJECT& parent
00374          );
00375 
00376       ERRVALUE CalculateSurfaceProperties (
00377          );
00378 
00379       bool OpenSurfaceProperties (
00380          );
00381 
00382       ERRVALUE CloseSurfaceProperties (
00383          );
00384 
00385       bool CheckAndOpenSurfaceProperties (
00386          RVC::RASTER& corners
00387          );
00388 
00389       ERRVALUE DeleteSurfaceProperties (
00390          );
00391 
00392       void CalculateZDefaults (
00393          const INT32 index
00394          );
00395 
00396       double GetZDefault (
00397          const INT32 column,
00398          const INT32 line
00399          );
00400 
00401       double CalculateZDefault (
00402          const INT32 column,
00403          const INT32 line
00404          );
00405 
00406       ERRVALUE CalculateProperty (
00407          const INT32 x,
00408          const INT32 y,
00409          const INT32 length,
00410          const DIRECTION direction,
00411          PROPERTY& property
00412          );
00413 
00414       FLOAT CalculateError (
00415          const INT32 x,
00416          const INT32 y,
00417          const INT32 length,
00418          const DIRECTION direction
00419          );
00420 
00421       FLOAT CalculateRadius (
00422          const INT32 x,
00423          const INT32 y,
00424          const INT32 length,
00425          const DIRECTION direction
00426          );
00427 
00428       ERRVALUE SubMeshRefine (
00429          const INT32 px,
00430          const INT32 py,
00431          const INT32 length,
00432          const DIRECTION direction,
00433          const INT32 level
00434          );
00435 
00436       ERRVALUE VertexAppend (
00437          const INT32 x,
00438          const INT32 y,
00439          const bool parity
00440          );
00441 
00442       bool IsVertexActive (
00443          const INT32 x,
00444          const INT32 y
00445          );
00446 
00447       void MakeVertex (
00448          const INT32 x,
00449          const INT32 y,
00450          const INT32 index,
00451          DPOINT3D& point
00452          );
00453 
00454       INT32 CalculateIndex (
00455          const INT32 x,
00456          const INT32 y
00457          );
00458 
00459       void SetSurfaceProperty (
00460          const INT32 x,
00461          const INT32 y,
00462          PROPERTY& property
00463          );
00464 
00465       void GetSurfaceProperty (
00466          const INT32 x,
00467          const INT32 y,
00468          PROPERTY& property,
00469          const bool geth,
00470          const bool gete,
00471          const bool getr
00472          );
00473 
00474       bool IsPropertyComputed (
00475          const INT32 x,
00476          const INT32 y
00477          );
00478 
00479       void SetPropertyComputed (
00480          const INT32 x,
00481          const INT32 y
00482          );
00483 
00484       ERRVALUE MakeComputedSet (
00485          );
00486 
00487       void DestroyComputedSet (
00488          );
00489 
00490       double GetSurfaceElevation (
00491          const INT32 x,
00492          const INT32 y
00493          );
00494 
00495       #endif // GENERATING_DOXYGEN_OUTPUT
00496    };
00497 
00498 };    // End of namespace
00499 
00500 #endif
00501 

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