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

Generated on Thu Apr 26 04:03:30 2007 for TNTsdk by  doxygen 1.5.2