00001
00026 #ifndef INC_MI32_RPOVRGN_H
00027 #define INC_MI32_RPOVRGN_H
00028
00029 #ifndef INC_MI32_LINERAST_H
00030 #include <mi32/linerast.h>
00031 #endif
00032
00033 #ifndef INC_MI32_FILLPOLY_H
00034 #include <mi32/fillpoly.h>
00035 #endif
00036
00037 #ifndef INC_MI32_STATUNIVAR_H
00038 #include <mi32/statunivar.h>
00039 #endif
00040
00041 #ifndef INC_RVC_NULLMASK_H
00042 #include <rvc/nullmask.h>
00043 #endif
00044
00045 #ifndef INC_MI32_TRIANGULATOR_H
00046 #include <mi32/triangulator.h>
00047 #endif
00048
00049
00051 class RASTER_REGION_PROP_CALC {
00052 public:
00053
00054 enum BOUNDARYCELLS {
00055 BOUNDARYCELLS_IncludeAll = 1,
00056 BOUNDARYCELLS_IncludeCenter = 2,
00057 BOUNDARYCELLS_Proportionally = 3,
00058 BOUNDARYCELLS_ExcludeAll = 4
00059 };
00060
00061 void Clear ();
00062
00063 bool Initialize (
00064 RVC::OBJITEM& objitem
00065 );
00066
00067 bool IsInitialized () { return m_Initialized; };
00068
00069 RASTER_REGION_PROP_CALC (
00070 ) : m_Initialized(false), m_FPSpan(this), m_LRSpan(this) {};
00071
00072 ERRVALUE Compute (
00073 REGION2D& region,
00074 STAT_UNIVARIATE& statistics,
00075 const BOUNDARYCELLS boundarycells
00076 );
00077
00078 ERRVALUE Compute (
00079 REGION2D& region,
00080 RANGE<double>& range,
00081 const BOUNDARYCELLS boundarycells
00082 );
00083
00084 private:
00085 #ifndef GENERATING_DOXYGEN_OUTPUT
00086
00087 enum MODE {
00088 MODE_Statistics = 0,
00089 MODE_Range = 1
00090 };
00091
00092 class FPSPAN : public FILLPOLYGON::SPAN {
00093 public:
00094
00095 FPSPAN (
00096 RASTER_REGION_PROP_CALC* operation
00097 ) :
00098 m_Operation(operation)
00099 { }
00100
00101 private:
00102 RASTER_REGION_PROP_CALC* m_Operation;
00103
00104 FPSPAN ();
00105 void VProcess (const double x1, const double x2, const double y);
00106 };
00107
00108 class LRSPAN : public LINERASTERIZER2D::SPAN {
00109 public:
00110
00111 LRSPAN (
00112 RASTER_REGION_PROP_CALC* operation
00113 ) :
00114 m_Operation(operation),
00115 m_Add(true)
00116 { }
00117
00118 void Set (
00119 const bool add
00120 ) { m_Add = add; return; };
00121
00122 private:
00123
00124 void v_Process (
00125 const INT32 colmin,
00126 const INT32 colmax,
00127 const INT32 lin
00128 ) { m_Operation->ProcessSpan(colmin, colmax, lin, m_Add); };
00129
00130 void v_ProcessSpan (
00131 const double x1,
00132 const double y1,
00133 const double x2,
00134 const double y2
00135 );
00136
00137 LRSPAN ();
00138
00139 RASTER_REGION_PROP_CALC* m_Operation;
00140 bool m_Add;
00141 };
00142
00143 RVC::RASTER m_Raster;
00144 RVC::IMAGE::CONVMODE m_Convmode;
00145 RVC::NULLMASK m_NullMask;
00146 RVC::RASTER m_Mask;
00147 RVC::OBJECT m_File;
00148 TRIANGULATOR m_Triangulator;
00149 DOUBLE_ARRAY<DTRIANGLE2D> m_Triangles;
00150
00151 bool m_Initialized;
00152
00153 MODE m_Mode;
00154 STAT_UNIVARIATE* m_Statistics;
00155 RANGE<double>* m_Range;
00156
00157 LRECT2D m_Extents;
00158 SIMPLE_ARRAY<UINT8> m_Data;
00159 SIMPLE_ARRAY<UINT8> m_NullBuffer;
00160 SIMPLE_ARRAY<UINT8> m_Buffer;
00161 SIMPLE_ARRAY<UINT8> m_Buffer0;
00162 SIMPLE_ARRAY<UINT8> m_Buffer1;
00163 FPSPAN m_FPSpan;
00164 LRSPAN m_LRSpan;
00165 POLYLINE m_Polyline;
00166
00167 ERRVALUE ProcessX (const DTRIANGLE2D& triangle);
00168 ERRVALUE ProcessEQX (const DPOINT2D& p1, const DPOINT2D& p2, const DPOINT2D& p3);
00169 ERRVALUE ProcessNEQX (const DPOINT2D& p1, const DPOINT2D& p2, const DPOINT2D& p3);
00170 ERRVALUE ProcessLtoR (const DPOINT2D& left, const DPOINT2D& tr, const DPOINT2D& br);
00171 ERRVALUE ProcessRtoL (const DPOINT2D& right, const DPOINT2D& tl, const DPOINT2D& bl);
00172
00173 ERRVALUE ProcessY (const DPOINT2D& p1, const DPOINT2D& p2, const DPOINT2D& p3);
00174 ERRVALUE ProcessEQY (const DPOINT2D& p1, const DPOINT2D& p2, const DPOINT2D& p3);
00175 ERRVALUE ProcessNEQY (const DPOINT2D& p1, const DPOINT2D& p2, const DPOINT2D& p3);
00176 ERRVALUE ProcessTtoB (const DPOINT2D& top, const DPOINT2D& b1, const DPOINT2D& b2);
00177 ERRVALUE ProcessBtoT (const DPOINT2D& bottom, const DPOINT2D& t1, const DPOINT2D& t2);
00178
00179 ERRVALUE Process (const DPOINT2D& p1, const DPOINT2D& p2, const DPOINT2D& p3);
00180 ERRVALUE ProcessSpan (const INT32 column1, const INT32 column2, const INT32 line, const bool add = true);
00181
00182 ERRVALUE FillMaskWithCenters (const REGION2D& region);
00183 ERRVALUE ProcessBoundary(const REGION2D& region, const bool add);
00184 ERRVALUE ProcessProportionally(const REGION2D& region);
00185 ERRVALUE ComputeStatisticsFromMask();
00186 ERRVALUE ClearMask();
00187
00188 ERRVALUE Accumulate (UINT32 NumValues, const void* vpValues, const UINT8* pValidity = 0);
00189 template<typename _CT> ERRVALUE Extend (UINT32 NumValues, const _CT* vpValues, const UINT8* pValidity = 0);
00190 ERRVALUE AccumulateWeighted (const void* vpValue, double weight);
00191
00192 #endif // GENERATING_DOXYGEN_OUTPUT
00193 };
00194
00195 #endif // INC_MI32_TRIANGUL_H