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 #ifndef INC_GRE_3DPNTFLD_H
00026 #define INC_GRE_3DPNTFLD_H
00027
00028 #ifndef INC_MI32_RECT_H
00029 #include <mi32/rect.h>
00030 #endif
00031
00032 #ifndef INC_MI32_SIMPLEAR_H
00033 #include <mi32/simplear.h>
00034 #endif
00035
00036 #include <vector>
00037
00038 #ifndef GENERATING_DOXYGEN_OUTPUT
00039 class BITSET;
00040 #endif // GENERATING_DOXYGEN_OUTPUT
00041
00042 namespace GRE {
00043
00044
00045
00046 class POINTSFIELD {
00047 public:
00048
00050 POINTSFIELD (
00051 ) :
00052 m_IsCreated(false),
00053 m_UseMask(false),
00054 m_StepReciprocal(0.0),
00055 m_NumColumns(0),
00056 m_NumLines(0)
00057 { }
00058
00060 ~POINTSFIELD() { Clear(); }
00061
00062
00063 void Clear (
00064 );
00065
00066
00067
00068 ERRVALUE Create (
00069 const DRECT2D& extents,
00070 const INT32 numBuckets = 4096
00071 );
00072
00073
00074 bool IsCreated (
00075 ) const { return m_IsCreated; }
00076
00077
00078 ERRVALUE AddPoint (
00079 const FPOINT3D& point
00080 );
00081
00082
00083 ERRVALUE FindInExtents (
00084 const DRECT2D& extents,
00085 SIMPLE_ARRAY<FPOINT3D>& points
00086 ) const;
00087
00088
00089 ERRVALUE FindInTriangle (
00090 const FPOINT2D& point1,
00091 const FPOINT2D& point2,
00092 const FPOINT2D& point3,
00093 SIMPLE_ARRAY<FPOINT3D>& points
00094 ) const;
00095
00096
00097 ERRVALUE FindInEllipse (
00098 const FPOINT2D& center,
00099 const float xradius,
00100 const float yradius,
00101 SIMPLE_ARRAY<FPOINT3D>& points
00102 ) const;
00103
00104
00105 ERRVALUE MaskExtents (
00106 const DRECT2D& extents
00107 );
00108
00109
00110 ERRVALUE MaskTriangle (
00111 const FPOINT2D& point1,
00112 const FPOINT2D& point2,
00113 const FPOINT2D& point3
00114 );
00115
00116
00117 ERRVALUE MaskEllipse (
00118 const FPOINT2D& center,
00119 const float xradius,
00120 const float yradius
00121 );
00122
00123
00124 void UseMask (
00125 const bool use
00126 );
00127
00128 private:
00129
00130 class TRIANGLE {
00131 public:
00132
00133 TRIANGLE (
00134 const FPOINT2D& point1,
00135 const FPOINT2D& point2,
00136 const FPOINT2D& point3
00137 );
00138
00139 const DRECT2D& GetExtents (
00140 ) { return m_Extents; }
00141
00142 bool IsPointInside (
00143 const FPOINT2D& point
00144 ) const;
00145
00146 private:
00147
00148 TRIANGLE ();
00149
00150 static const bool s_Inside[27];
00151
00152 DRECT2D m_Extents;
00153 DPOINT2D m_Normal1;
00154 DPOINT2D m_Normal2;
00155 DPOINT2D m_Normal3;
00156 double m_C1;
00157 double m_C2;
00158 double m_C3;
00159 };
00160
00161 class ELLIPSE {
00162 public:
00163
00164 ELLIPSE (
00165 const FPOINT2D& point,
00166 const float& x,
00167 const float& y
00168 );
00169
00170 const DRECT2D& GetExtents (
00171 ) { return m_Extents; }
00172
00173 bool IsPointInside (
00174 const FPOINT2D& point
00175 ) const;
00176
00177 private:
00178
00179 ELLIPSE ();
00180
00181 DRECT2D m_Extents;
00182 DPOINT2D m_Center;
00183 double m_X2Reciprocal;
00184 double m_Y2Reciprocal;
00185 };
00186
00187 typedef SIMPLE_ARRAY<FPOINT3D> BUCKET;
00188 typedef std::vector<BUCKET> BUCKETS;
00189 typedef std::vector<BITSET> MASK;
00190
00191 bool m_IsCreated;
00192 bool m_UseMask;
00193 DRECT2D m_Extents;
00194 double m_StepReciprocal;
00195 INT32 m_NumColumns;
00196 INT32 m_NumLines;
00197
00198 BUCKETS m_Buckets;
00199 MASK m_Mask;
00200
00201 };
00202
00203 }
00204
00205 #endif
00206
00207
00208