IPointIndexLeaf.hpp
1 #ifndef DM_IPOINT_INDEX_LEAF_HPP_INCLUDED
2 #define DM_IPOINT_INDEX_LEAF_HPP_INCLUDED
3 
4 #ifdef _MSC_VER
5  #pragma once
6 #endif
7 
8 #include "DM/config.hpp"
9 #include "DM/Handle.hpp"
10 #include "DM/Iterator.hpp"
11 #include "DM/IPoint.hpp"
12 #include "DM/IPolygon.hpp"
13 #include "DM/IWindow.hpp"
14 #include "DM/IBox.hpp"
15 #include "DM/ICircle.hpp"
16 #include "DM/ISphere.hpp"
17 #include "DM/ICylinder.hpp"
18 #include "DM/ObjectBase.hpp"
19 #include "DM/IKnnQueryDescriptor.hpp"
20 #include "DM/IFilter.hpp"
21 #include "DM/IColBufferManagerWrite.hpp"
22 #include "DM/AutoLink.hpp" //enable autolink
23 
24 DM_NAMESPACE_BEGIN
25 
26 class IIndexMapSet;
27 class IIndexHelperSet;
28 class IClassificationMatrix;
29 
30 /// \brief object representing a spatial leaf within a point index
31 /** Whereas IPointIndexLeaf objects are fully kept in memory, IPointIndex objects may consists of multiple
32  IPointIndexLeaf objects that can be swapped to disk. For details see \ref dm_structure
33 */
34 class DM_API IPointIndexLeaf : public ObjectBase
35 {
36 public:
37  struct kd_tree_tag {};
39 
40  /// create a new kd tree object
41  static IPointIndexLeaf* New(const kd_tree_tag &, int dimension, bool threadsafe);
42  static IPointIndexLeaf* New(const kd_tree_with_lazy_deletion_tag &, int dimension, bool threadsafe);
43 
44 
45  // Iterator typedefs ============================================================================
46  typedef ConstIterator<IPoint> const_iterator_point; ///< Point iterator
47  typedef InsertIterator<IPoint> insert_iterator_point; ///< Point insert iterator (used in searchPoint functions)
48 
49 protected:
50  virtual ~IPointIndexLeaf() {}
51 
52 public:
53  // General memeber functions ====================================================================
54  virtual BoxHandle getLimit() const = 0; ///< get points based bounding box
55  virtual BoxHandle getIndexLimit() const = 0; ///< get index based bounding box (if no index bounding available the points based bounding box is returned)
56 
57  virtual int64_t sizePoint() const = 0;
58  virtual int indexDim() const = 0;
59 
60  virtual int64_t id() const = 0; ///< identifier for direct leaf access by the IPointIndex object
61 
62  virtual double estimatePointDensity() const = 0;
63 
64  virtual IPointIndexLeaf* clone() const = 0;
65 
66  // Iterator function ============================================================================
67  virtual const_iterator_point beginPoint() const = 0;
68  virtual const_iterator_point endPoint() const = 0;
69 
70  // access functions ============================================================================
71  virtual PointHandle getPoint(int64_t id) const = 0; ///< get point by id (if the id doesn't exist within the leaf an empty handle is returned)
72 
73  // modifier functions ==========================================================================
74  virtual void addPoint(const IPoint &pt) = 0;
75  virtual void addPoint(PointHandle pt) = 0;
76 
77  virtual void removePoint(int64_t id) = 0;
78 
79  virtual void build() = 0;
80  virtual void clear() = 0;
81 
82  virtual void setChanged(bool changed) = 0;
83  virtual bool isChanged() const = 0;
84 
85  // Spatial access functions =====================================================================
86  virtual void searchPoint(const IWindow &win, insert_iterator_point &instIt, bool includeRightBoundary = true) = 0;
87  virtual void searchPoint(const IBox &box, insert_iterator_point &instIt, bool includeRightBoundary = true) = 0;
88  virtual void searchPoint(const IPolygon &p, insert_iterator_point &instIt) = 0;
89  virtual void searchPoint(const ICircle &c, insert_iterator_point &instIt) = 0;
90  virtual void searchPoint(const ISphere &s, insert_iterator_point &instIt) = 0;
91  virtual void searchPoint(const ICylinder &c, insert_iterator_point &instIt) = 0;
92 
93  virtual void searchPoint(int nnCount, const IPoint &queryPt, insert_iterator_point &instIt,
94  double maxDistance = -1, SelectionMode::Type selectionMode = SelectionMode::nearest) = 0;
95 
96  // Comparision operator =========================================================================
97  virtual bool operator==(const IPointIndexLeaf &ref) const = 0;
98  virtual bool operator!=(const IPointIndexLeaf &ref) const = 0;
99 
100 };
101 typedef Handle< IPointIndexLeaf > PointIndexLeafHandle;
102 
103 DM_NAMESPACE_END
104 
105 
106 #endif //DM_IPOINT_INDEX_LEAF_HPP_INCLUDED