3dpntfld.h

Go to the documentation of this file.
00001 /*** 
00002  * \file gre/3dpntfld.h
00003  * \brief 3D Points field
00004  *
00005  * \if NODOC
00006  * $Id: 3dpntfld.h_v 1.4 2005/09/15 18:03:40 vdronov Exp $
00007  *
00008  * $Log: 3dpntfld.h_v $
00009  * Revision 1.4  2005/09/15 18:03:40  vdronov
00010  * added comments
00011  *
00012  * Revision 1.3  2005/03/16 14:18:14  vdronov
00013  * *** empty log message ***
00014  *
00015  * Revision 1.2  2005/03/10 21:42:59  vdronov
00016  * *** empty log message ***
00017  *
00018  * Revision 1.1  2005/02/01 17:27:17  vdronov
00019  * Initial revision
00020  *
00021  *
00022  * \endif
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 // POINTSFIELD class is the variaion of quadtree with given number of buckets equally distributed in given extents. 
00045 // There are no methods for deleting or modifying of elements.
00046 class POINTSFIELD {
00047    public:
00048 
00049       //! Default constructor.
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 
00059       //! Destructor.
00060       ~POINTSFIELD() { Clear(); }
00061 
00062       // Removes elements from quadtree and realeses all resources
00063       void Clear (
00064          );
00065 
00066       // Creates quadtree for given extents and number of buckets
00067       // equally distributed in extents
00068       ERRVALUE Create (
00069          const DRECT2D& extents,
00070          const INT32 numBuckets  = 4096
00071          );
00072 
00073       // Checks if quadtree is created
00074       bool IsCreated (
00075          ) const { return m_IsCreated; }
00076 
00077       // Adds a point to quadtree
00078       ERRVALUE AddPoint (
00079          const FPOINT3D& point
00080          );
00081 
00082       // Finds points inside given extents
00083       ERRVALUE FindInExtents (
00084          const DRECT2D& extents,
00085          SIMPLE_ARRAY<FPOINT3D>& points
00086          ) const;
00087 
00088       // Finds points inside given triangle
00089       ERRVALUE FindInTriangle (
00090          const FPOINT2D& point1,
00091          const FPOINT2D& point2,
00092          const FPOINT2D& point3,
00093          SIMPLE_ARRAY<FPOINT3D>& points
00094          ) const;
00095 
00096       // Finds points inside given ellipse
00097       ERRVALUE FindInEllipse (
00098          const FPOINT2D& center, 
00099          const float xradius,
00100          const float yradius,
00101          SIMPLE_ARRAY<FPOINT3D>& points
00102          ) const;
00103 
00104       // Masks points inside given extents
00105       ERRVALUE MaskExtents (
00106          const DRECT2D& extents
00107          );
00108 
00109       // Masks points inside given triangle
00110       ERRVALUE MaskTriangle (
00111          const FPOINT2D& point1,
00112          const FPOINT2D& point2,
00113          const FPOINT2D& point3
00114          );
00115 
00116       // Masks points inside given ellipse
00117       ERRVALUE MaskEllipse (
00118          const FPOINT2D& center,
00119          const float xradius,
00120          const float yradius
00121          );
00122 
00123       // Set use of mask, so if it set all find methods will find points only inside masked area.
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    }; // End of POINTSFIELD class.
00202 
00203 }     // End of GRE namespace
00204 
00205 #endif
00206 
00207 
00208 

Generated on Wed May 31 15:26:38 2006 for TNTsdk by  doxygen 1.3.8-20040913