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
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef INC_GRE_3DDRYTER_H
00040 #define INC_GRE_3DDRYTER_H
00041
00042 #ifndef INC_GRE_3DTERRA_H
00043 #include <gre/3dterra.h>
00044 #endif
00045
00046 #ifndef INC_GRE_3DSCENE_H
00047 #include <gre/3dscene.h>
00048 #endif
00049
00050 #ifndef INC_MI32_ASURFACE_H
00051 #include <mi32/asurface.h>
00052 #endif
00053
00054 #ifndef INC_MI32_SIMPLEAR_H
00055 #include <mi32/simplear.h>
00056 #endif
00057
00058 #ifndef INC_RVC_OBJECT_H
00059 #include <rvc/object.h>
00060 #endif
00061
00062 #ifndef INC_RVC_GEOREFER_H
00063 #include <rvc/georefer.h>
00064 #endif
00065
00066 namespace GRE {
00067
00068
00069 class DENSERAYCASTING : public TERRAIN {
00070 public:
00071
00072 DENSERAYCASTING (
00073 );
00074
00075 ~DENSERAYCASTING (
00076 );
00077
00078 private:
00079 #ifndef GENERATING_DOXYGEN_OUTPUT
00080
00081 struct ORDER {
00082 INT32 index;
00083 float distance;
00084 };
00085
00086 struct INTERSECTION {
00087 const DOUBLE_ARRAY<double>& m_Buffer;
00088 const INT32 m_NumCells;
00089 const DPOINT3D m_Min;
00090 const DPOINT3D m_Max;
00091 const bool m_HasNullValue;
00092 const double m_NullValue;
00093 const DPOINT3D& m_Viewer;
00094 const DPOINT3D& m_Direction;
00095 const bool m_IsPerspective;
00096
00097 POLYLINE m_Polyline;
00098
00099 INTERSECTION (
00100 const DOUBLE_ARRAY<double>& buffer,
00101 const INT32 numCells,
00102 const DPOINT3D min,
00103 const DPOINT3D max,
00104 const bool hasNullValue,
00105 const double nullValue,
00106 const DPOINT3D& viewer,
00107 const DPOINT3D& direction,
00108 const bool isPerspective
00109 ) :
00110 m_Buffer(buffer),
00111 m_NumCells(numCells),
00112 m_Min(min),
00113 m_Max(max),
00114 m_HasNullValue(hasNullValue),
00115 m_NullValue(nullValue),
00116 m_Viewer(viewer),
00117 m_Direction(direction),
00118 m_IsPerspective(isPerspective)
00119 {
00120 };
00121
00122 };
00123
00124 #define NUMPIXELS 4096
00125
00126 #define NUMCORNERS 8
00127 #define NUMSEGMENTS 12
00128
00129 static const INT32 s_Segments[NUMSEGMENTS][2];
00130
00131 ABSTRACT_SURFACE *m_Surface;
00132 DRECT3D m_Extents;
00133 SPATREF::COORDREFSYS m_CoordRefSys;
00134 TRANS2D_MAPGEN m_Transformation;
00135
00136 RVC::RASTER m_Raster;
00137 DOUBLE_ARRAY<double> m_Buffer;
00138
00139 INT32 m_XBlocks;
00140 INT32 m_YBlocks;
00141 INT32 m_BlockSize;
00142 DOUBLE_ARRAY<DRECT3D> m_Blocks;
00143 INT32 m_Index;
00144 bool m_BlockIsLoaded;
00145 double m_CoverAreaFactor;
00146
00147 SIMPLE_ARRAY<ORDER> m_Orders;
00148
00149 BITSET m_ScreenBits;
00150 INT32 m_ScreenWidth;
00151 INT32 m_ScreenHeight;
00152 INT32 m_ScreenX;
00153 INT32 m_ScreenY;
00154
00155 SIMPLE_ARRAY<DPOINT3D> m_Points;
00156 SIMPLE_ARRAY<LPOINT2D> m_Pixels;
00157
00158 PIXALIZATION m_Pixalization;
00159 TRIANGULATION m_Triangulation;
00160
00161 SCENE3D *m_Scene;
00162 CONTROLLER *m_Controller;
00163 DRAWINGCONTEXT3D *m_Drawing;
00164
00165 DPOINT3D m_Viewer;
00166 DPOINT3D m_Direction;
00167
00168 double m_ZMin;
00169 double m_ZMax;
00170 bool m_HasNullValue;
00171 double m_NullValue;
00172
00173 DENSERAYCASTING& operator= (
00174 const DENSERAYCASTING& rhs
00175 );
00176
00177 static int OrderSort (
00178 ORDER* item1,
00179 ORDER* item2,
00180 void*
00181 ) { if (item1->distance < item2->distance) return 1; return 0; };
00182
00183 static void GetCorners (
00184 const DRECT3D& rect,
00185 DPOINT3DH points[8]
00186 );
00187
00188 static void GetCorners (
00189 const DRECT3D& rect,
00190 DPOINT3D points[8]
00191 );
00192
00193 static double CalculateElevation (
00194 INTERSECTION& intersection,
00195 const DPOINT3D& pt,
00196 const int type
00197 );
00198
00199 static bool GetIntersection (
00200 INTERSECTION& intersection,
00201 const DPOINT3D& lookAt,
00202 DPOINT3D& result
00203 );
00204
00205 static void GetTriangle (
00206 INTERSECTION& intersection,
00207 const DPOINT3D& point,
00208 DPOINT3D points[3]
00209 );
00210
00211 TERRAIN* v_CreateInstance (
00212 ) { return new DENSERAYCASTING(); };
00213
00214 ERRVALUE v_Build (
00215 const GRE_LAYER *layer
00216 );
00217
00218 bool v_IsObjectTypeSupported (
00219 const RVC::OBJTYPE objtype
00220 ) const { return (objtype == RVC::OBJTYPE_Raster); };
00221
00222 void v_Free (
00223 );
00224
00225 ERRVALUE Create (
00226 const GRE_LAYER *layer
00227 );
00228
00229 void Delete (
00230 );
00231
00232 ERRVALUE v_GetDefaultScene (
00233 SCENE3D& scene
00234 ) const;
00235
00236 ERRVALUE v_SetScene (
00237 const SCENE3D& scene,
00238 const SIMPLE_ARRAY<TEXTURE*> &textures
00239 );
00240
00241 ERRVALUE v_DrawScene (
00242 CONTROLLER &controller,
00243 DRAWINGCONTEXT3D& drawing,
00244 TEXTURE* texture,
00245 TEXTUREFILTER* texturefilter
00246 );
00247
00248 float v_GetElevation (
00249 const float x,
00250 const float y
00251 ) const;
00252
00253 ERRVALUE v_ComputeProfile (
00254 const POLYLINE& polyline,
00255 POLYLINE& profile,
00256 SIMPLE_ARRAY<INT32>& index
00257 );
00258
00259 float v_GetAngleToNorth (
00260 const float x,
00261 const float y
00262 ) const;
00263
00264 const ABSTRACT_SURFACE* v_GetAbstractSurface (
00265 ) { return m_Surface; }
00266
00267 void v_SetCoordRefSys (
00268 const SPATREF::COORDREFSYS& CoordRefSys
00269 );
00270
00271 const SPATREF::COORDREFSYS v_GetCoordRefSys (
00272 ) const { return m_CoordRefSys; };
00273
00274 const DRECT3D& v_GetExtents (
00275 ) { return m_Extents; };
00276
00277 void v_CreateBoundary (
00278 REGION2D& boundary
00279 );
00280
00281 bool v_HasNull (
00282 ) const { return m_HasNullValue; };
00283
00284 bool v_IsNull (
00285 const float x,
00286 const float y
00287 ) const;
00288
00289 ERRVALUE CreateBlocks (
00290 const TRANS2D_MAPGEN& transformation
00291 );
00292
00293 void DeleteBlocks (
00294 );
00295 ERRVALUE SetSceneForBlocks (
00296 const SCENE3D& scene,
00297 const SIMPLE_ARRAY<TEXTURE*> &textures
00298 );
00299
00300 ERRVALUE DrawSceneForBlocks (
00301 CONTROLLER &controller,
00302 DRAWINGCONTEXT3D& drawing,
00303 TEXTURE* texture,
00304 TEXTUREFILTER* texturefilter
00305 );
00306
00307 void TransformBlocks (
00308 const TRANS2D_MAPGEN& transformation
00309 );
00310
00311 void FillSpan (
00312 const INT32 col1,
00313 const INT32 col2,
00314 const INT32 lin
00315 );
00316
00317 void DrawPixels (
00318 );
00319
00320 #endif
00321 };
00322
00323 };
00324
00325 #endif
00326