00001
00023 #ifndef INC_RVC_CONTOURING_H
00024 #define INC_RVC_CONTOURING_H
00025
00026 #ifndef INC_RVC_OPCOMPONENT_H
00027 #include <rvc/opcomponent.h>
00028 #endif
00029
00030 #ifndef INC_RVC_VECTOR_H
00031 #include <rvc/vector.h>
00032 #endif
00033
00034 #ifndef INC_MI32_QTREE_H
00035 #include <mi32/qtree.h>
00036 #endif
00037
00038 #include <float.h>
00039
00040
00041 #ifndef GENERATING_DOXYGEN_OUTPUT
00042
00043 namespace SPATREF {
00044 class COORDREFSYS;
00045 }
00046 #endif
00047
00048
00049 namespace RVC {
00050 namespace OP {
00051
00052
00053
00055 class CONTOURING {
00056 public:
00057
00059 enum SOURCE {
00060 SOURCE_Invalid = -1,
00061 SOURCE_First = 0,
00062 SOURCE_Raster = 0,
00063 SOURCE_TIN = 1,
00064 SOURCE_Last = 1,
00065 SOURCE_Count = 2
00066 };
00067
00069 enum METHOD {
00070 METHOD_Invalid = -1,
00071 METHOD_First = 0,
00072 METHOD_Linear = 0,
00073 METHOD_IterativeThresholding = 1,
00074 METHOD_Last = 1,
00075 METHOD_Count = 2
00076 };
00077
00079 class SOURCE_PARAMETERS {
00080 public:
00081
00082 SOURCE_PARAMETERS (
00083 const SOURCE source
00084 );
00085
00086 virtual ~SOURCE_PARAMETERS (
00087 );
00088
00089 SOURCE GetSource (
00090 ) const { return m_Source; }
00091
00092 private:
00093 #ifndef GENERATING_DOXYGEN_OUTPUT
00094 const SOURCE m_Source;
00095 #endif // GENERATING_DOXYGEN_OUTPUT
00096 };
00097
00099 class RASTER_PARAMETERS : public SOURCE_PARAMETERS {
00100 public:
00101
00103 enum RESAMPLINGMETHOD {
00104 RESAMPLINGMETHOD_None = 0,
00105 RESAMPLINGMETHOD_BilinearInterpolation = 1,
00106 RESAMPLINGMETHOD_CubicConvolution = 2
00107 };
00108
00110 enum SMOOTHINGMETHOD {
00111 SMOOTHINGMETHOD_None = 0,
00112 SMOOTHINGMETHOD_WeightedAverage = 1,
00113 SMOOTHINGMETHOD_Gaussian = 2,
00114 SMOOTHINGMETHOD_Quadratic = 3,
00115 SMOOTHINGMETHOD_Cubic = 4,
00116 SMOOTHINGMETHOD_Quartic = 5
00117 };
00118
00120 enum WINDOWSIZE {
00121 WINDOWSIZE_3x3 = 3,
00122 WINDOWSIZE_5x5 = 5,
00123 WINDOWSIZE_7x7 = 7,
00124 WINDOWSIZE_9x9 = 9,
00125 WINDOWSIZE_11x11 = 11,
00126 WINDOWSIZE_13x13 = 13,
00127 WINDOWSIZE_15x15 = 15
00128 };
00129
00130 RASTER_PARAMETERS (
00131 );
00132
00133 ~RASTER_PARAMETERS (
00134 );
00135
00137 RESAMPLINGMETHOD GetResamplingMethod (
00138 ) const { return m_ResamplingMethod; };
00139
00141 UINT8 GetResolutionFactor (
00142 ) const { return m_ResolutionFactor; }
00143
00145 SMOOTHINGMETHOD GetSmoothingMethod (
00146 ) const { return m_SmoothingMethod; };
00147
00149 WINDOWSIZE GetWindowSize (
00150 ) const { return m_WindowSize; };
00151
00153 void SetResamplingMethod (
00154 const RESAMPLINGMETHOD method
00155 ) { m_ResamplingMethod = method; };
00156
00158 UINT8 SetResolutionFactor (
00159 const UINT8 ResolutionFactor
00160 ) {
00161 const UINT8 factor1 = ResolutionFactor >> 1;
00162 const UINT8 factor2 = bound(factor1, 1, 8);
00163 m_ResolutionFactor = factor2 << 1;
00164 return m_ResolutionFactor;
00165 }
00166
00168 void SetSmoothingMethod (
00169 const SMOOTHINGMETHOD method
00170 ) { m_SmoothingMethod = method; };
00171
00173 void SetWindowSize (
00174 const WINDOWSIZE size
00175 ) { m_WindowSize = size; };
00176
00177 private:
00178 #ifndef GENERATING_DOXYGEN_OUTPUT
00179 RESAMPLINGMETHOD m_ResamplingMethod;
00180 UINT8 m_ResolutionFactor;
00181 SMOOTHINGMETHOD m_SmoothingMethod;
00182 WINDOWSIZE m_WindowSize;
00183 #endif // GENERATING_DOXYGEN_OUTPUT
00184 };
00185
00186
00188 class TIN_PARAMETERS : public SOURCE_PARAMETERS {
00189 public:
00190
00191 TIN_PARAMETERS (
00192 );
00193
00194 ~TIN_PARAMETERS (
00195 );
00196
00198 const OP::COMPONENT& GetComponent (
00199 ) const { return m_Component; };
00200
00202 void SetComponent (
00203 const OP::COMPONENT& element
00204 ) { m_Component = element; };
00205
00206 private:
00207 #ifndef GENERATING_DOXYGEN_OUTPUT
00208 OP::COMPONENT m_Component;
00209 #endif // GENERATING_DOXYGEN_OUTPUT
00210 };
00211
00213 class DESTINATION_PARAMETERS {
00214 public:
00215
00216 DESTINATION_PARAMETERS (
00217 );
00218
00219 ~DESTINATION_PARAMETERS (
00220 );
00221
00223 bool GetCreateElevationRangeTable (
00224 ) const { return m_CreateElevationRangeTable; }
00225
00227 void SetCreateElevationRangeTable (
00228 const bool create
00229 ) { m_CreateElevationRangeTable = create; }
00230
00231 private:
00232 #ifndef GENERATING_DOXYGEN_OUTPUT
00233 bool m_CreateElevationRangeTable;
00234 #endif // GENERATING_DOXYGEN_OUTPUT
00235 };
00236
00238 class METHOD_PARAMETERS {
00239 public:
00240
00241 METHOD_PARAMETERS (
00242 const METHOD method
00243 );
00244
00245 virtual ~METHOD_PARAMETERS (
00246 );
00247
00249 METHOD GetMethod (
00250 ) const { return m_Method; }
00251
00253 double GetStartingLevel (
00254 ) const { return m_StartingLevel; }
00255
00257 double GetEndingLevel (
00258 ) const { return m_EndingLevel; }
00259
00261 double GetInterval (
00262 ) const { return m_Interval; }
00263
00265 double GetZScale (
00266 ) const { return m_ZScale; }
00267
00269 double GetZOffset (
00270 ) const { return m_ZOffset; }
00271
00273 void SetStartingLevel (
00274 const double StartingLevel
00275 ) { m_StartingLevel = StartingLevel; }
00276
00278 void SetEndingLevel (
00279 const double EndingLevel
00280 ) {m_EndingLevel = EndingLevel; }
00281
00283 void SetInterval (
00284 const double Interval
00285 ) { m_Interval = Interval; }
00286
00288 void SetZScale (
00289 const double ZScale
00290 ) { m_ZScale = ZScale; }
00291
00293 void SetZOffset (
00294 const double ZOffset
00295 ) { m_ZOffset = ZOffset; }
00296
00297 private:
00298
00299 #ifndef GENERATING_DOXYGEN_OUTPUT
00300
00301 const METHOD m_Method;
00302
00303 double m_StartingLevel;
00304 double m_EndingLevel;
00305 double m_Interval;
00306 double m_ZScale;
00307 double m_ZOffset;
00308
00309 METHOD_PARAMETERS (
00310 );
00311
00312 static METHOD Check (
00313 const METHOD method
00314 );
00315
00316 #endif // GENERATING_DOXYGEN_OUTPUT
00317 };
00318
00320 class LINEAR_PARAMETERS : public METHOD_PARAMETERS {
00321 public:
00322
00323 LINEAR_PARAMETERS (
00324 ) :
00325 METHOD_PARAMETERS(METHOD_Linear)
00326 { }
00327
00328 ~LINEAR_PARAMETERS (
00329 ) { }
00330
00331 };
00332
00334 class ITERATIVETHRESHOLDING_PARAMETERS : public METHOD_PARAMETERS {
00335 public:
00336
00337 ITERATIVETHRESHOLDING_PARAMETERS (
00338 ) :
00339 METHOD_PARAMETERS(METHOD_IterativeThresholding)
00340 {}
00341
00342 ~ITERATIVETHRESHOLDING_PARAMETERS (
00343 ) {}
00344
00345 };
00346
00348 class SEGMENTS {
00349 public:
00350
00351
00352 SEGMENTS ();
00353
00354 ~SEGMENTS ();
00355
00357 ERRVALUE Add (
00358 const DPOINT3D& p1,
00359 const DPOINT3D& p2
00360 );
00361
00363 void Clear (
00364 );
00365
00367 ERRVALUE Init (
00368 const RVC::OBJITEM& objitem,
00369 const DRECT3D& extents
00370 );
00371
00373 ERRVALUE Trace (
00374 const bool force = false
00375 );
00376
00377 private:
00378
00379 #ifndef GENERATING_DOXYGEN_OUTPUT
00380 struct SEGMENT {
00381 DPOINT3D m_Left;
00382 DPOINT3D m_Right;
00383 bool m_IsTheSameZ;
00384 bool m_IsUsed;
00385
00386 SEGMENT (
00387 ) :
00388 m_IsTheSameZ(true),
00389 m_IsUsed(false)
00390 { }
00391 };
00392
00393 RVC::VECTOR m_Vector;
00394 QUADTREE m_QTree;
00395 POLYLINE m_Polyline;
00396 POLYLINE m_Baseline;
00397 POLYLINE m_Joinline;
00398 POLYLINE m_Templine;
00399 SIMPLE_ARRAY<SEGMENT> m_Segments;
00400 SIMPLE_ARRAY<INT32> m_ListA;
00401 SIMPLE_ARRAY<INT32> m_ListB;
00402
00403 double m_Tolerance;
00404
00405 static int Compare (SEGMENT* p1, SEGMENT* p2, void* );
00406 static double Distance (const DPOINT2D& p1, const DPOINT2D& p2);
00407
00408 ERRVALUE ReplaceNode (const DPOINT2D& op, const DPOINT2D& np, const INT32 itemnum);
00409 int Snap (POLYLINE& polyline);
00410 ERRVALUE Store (POLYLINE& polyline);
00411 ERRVALUE StoreSimple (POLYLINE& polyline, const INT32 linenum);
00412
00413 #endif // GENERATING_DOXYGEN_OUTPUT
00414
00415 };
00416
00417
00419 static ERRVALUE Process (
00420 const RVC::OBJITEM& SrcObjItem,
00421 RVC::OBJITEM& DestObjItem,
00422 const SOURCE_PARAMETERS* SrcParameters,
00423 const METHOD_PARAMETERS* MethodParameters,
00424 const DESTINATION_PARAMETERS& DestParameters
00425 );
00426
00428 static ERRVALUE ProcessLinearFromTIN (
00429 const RVC::OBJITEM& SrcObjItem,
00430 RVC::OBJITEM& DestObjItem,
00431 const TIN_PARAMETERS& TINParameters,
00432 const LINEAR_PARAMETERS& LinearParameters,
00433 const DESTINATION_PARAMETERS& DestParameters
00434 );
00435
00437 static ERRVALUE ProcessFromRaster (
00438 const RVC::OBJITEM& SrcObjItem,
00439 RVC::OBJITEM& DestObjItem,
00440 const RASTER_PARAMETERS& RasterParameters,
00441 const METHOD_PARAMETERS* MethodParameters,
00442 const DESTINATION_PARAMETERS& DestParameters
00443 );
00444
00446 static ERRVALUE ProcessLinearFromRaster (
00447 const RVC::OBJITEM& SrcObjItem,
00448 RVC::OBJITEM& DestObjItem,
00449 const RASTER_PARAMETERS& RasterParameters,
00450 const LINEAR_PARAMETERS& LinearParameters,
00451 const DESTINATION_PARAMETERS& DestParameters
00452 );
00453
00455 static ERRVALUE ProcessIterativeThresholdingFromRaster (
00456 const RVC::OBJITEM& SrcObjItem,
00457 RVC::OBJITEM& DestObjItem,
00458 const RASTER_PARAMETERS& RasterParameters,
00459 const ITERATIVETHRESHOLDING_PARAMETERS& IterThresParameters,
00460 const DESTINATION_PARAMETERS& DestParameters
00461 );
00462
00464 static ERRVALUE ComputeFromTriangle (
00465 const DPOINT3D& A,
00466 const DPOINT3D& B,
00467 const DPOINT3D& C,
00468 double start,
00469 double end,
00470 double interval,
00471 FastDelegate<ERRVALUE(const DPOINT3D&, const DPOINT3D&)> DelegateContourSegment
00472 );
00473
00474 private:
00475
00476 #ifndef GENERATING_DOXYGEN_OUTPUT
00477 static ERRVALUE ProcessDestination (
00478 const RVC::OBJITEM& DestObjItem,
00479 const DESTINATION_PARAMETERS& DestParameters
00480 );
00481 #endif // GENERATING_DOXYGEN_OUTPUT
00482
00483 };
00484
00485
00486
00487 }
00488 }
00489
00490
00491 #endif // INC_RVC_OPPROFILING_H