IPointSet.hpp
1 #ifndef DM_IPOINT_SET_HPP_INCLUDED
2 #define DM_IPOINT_SET_HPP_INCLUDED
3 
4 #ifdef _MSC_VER
5  #pragma once
6 #endif
7 
8 #include "DM/config.hpp"
9 #include "DM/IAddInfoLayout.hpp"
10 #include "DM/Handle.hpp"
11 #include "DM/IGeometry.hpp"
12 #include "DM/IAddInfo.hpp"
13 #include "DM/IAddInfoContainer.hpp"
14 #include "DM/IPoint.hpp"
15 #include "DM/Iterator.hpp"
16 #include "DM/AutoLink.hpp" //enable autolink
17 
18 DM_NAMESPACE_BEGIN
19 
20 /// \brief a set of 3d point object
21 class DM_API IPointSet : public IGeometry
22 {
23 public:
24  typedef ConstIterator<IPoint> const_iterator_point; ///< Point iterator
25 
26  ///create a new point set with size points
27  static IPointSet* New(unsigned size = 0);
28 
29 protected:
30  virtual ~IPointSet() {}
31 
32 public:
33  virtual unsigned sizePoint() const = 0; ///< number of points within the set
34  virtual void reservePoint(unsigned size) = 0; ///< reserve memory for points
35  virtual void resizePoint(unsigned resize) = 0; ///< resize memory for points
36  virtual void removePoint(unsigned) = 0; ///< remove points at the given index
37  virtual void clearPoint() = 0; ///< remove all points from point set
38  virtual void addPoint(const DM::IPoint &pt) = 0;
39  virtual void addPoint(const DM::PointHandle &pt) = 0;
40  virtual void addPoint(double x, double y, double z) = 0;
41 
42  /// \brief sorting points by distance to given reference point
43  /**
44  \param[in] refPt reference point used for distance computation
45  \param[in] dim dimension of distance (2 = 2d distance, 3 = 3d distance)
46  \param[in] ascending sort in ascending or descending order
47  */
48  virtual void sortByDistance(const DM::IPoint &refPt, int dim, bool ascending = true) = 0;
49 
50  virtual const_iterator_point beginPoint() const = 0;
51  virtual const_iterator_point endPoint() const = 0;
52 
53  virtual const IPoint& operator[](unsigned) const = 0;
54  virtual IPoint& operator[](unsigned) = 0;
55 
56  virtual const PointHandle& operator()(unsigned idx) const = 0;
57  virtual PointHandle& operator()(unsigned idx) = 0;
58 };
59 
60 typedef Handle< IPointSet > PointSetHandle;
61 
62 DM_NAMESPACE_END
63 
64 #endif //DM_IPOINT_SET_HPP_INCLUDED