IPointIndex.hpp
1 #ifndef DM_IPOINT_INDEX_HPP_INCLUDED
2 #define DM_IPOINT_INDEX_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/IPointIndexLeaf.hpp"
13 #include "DM/IAddInfoStatistics.hpp"
14 #include "DM/IIndexStats.hpp"
15 
16 DM_NAMESPACE_BEGIN
17 
18 /// \brief Interface to a point index object managing the point objects within the datamanager
19 class DM_API IPointIndex : public ObjectBase
20 {
21  public:
22  // Iterator typedefs ============================================================================
23  typedef ConstIterator<IPoint> const_iterator_point; ///< Point iterator
24  typedef InsertIterator<IPoint> insert_iterator_point; ///< Point insert iterator (used in searchPoint functions)
25 
27  typedef Iterator<IPointIndexLeaf> iterator_leaf; ///< Leaf iterator
28  typedef InsertIterator<IPointIndexLeaf> insert_iterator_leaf; ///< Leaf insert iterator (used in searchPoint functions)
29 
30  virtual ~IPointIndex() {}
31 
32  // General memeber functions ====================================================================
33  virtual BoxHandle getLimit() const = 0; ///< get points based bounding box
34  virtual BoxHandle getIndexLimit() const = 0; ///< get index based bounding box (if no index bounding available the points based bounding box is returned)
35 
36  virtual int64_t sizePoint() const=0;
37 
38  virtual int64_t sizeLeaf() const=0;
39 
40  virtual double estimatePointDensity(bool fastEstimation = true) const = 0;
41 
42  // Iterator function ============================================================================
43  virtual const_iterator_point beginPoint(E_IteratorOrder order = eORDER_INTERNAL) const = 0;
44  virtual const_iterator_point endPoint(E_IteratorOrder order = eORDER_INTERNAL) const = 0;
45 
46  virtual const_iterator_leaf beginLeaf(E_IteratorOrder order = eORDER_INTERNAL) const = 0;
47  virtual const_iterator_leaf endLeaf(E_IteratorOrder order = eORDER_INTERNAL) const = 0;
48  virtual iterator_leaf beginLeaf(E_IteratorOrder order = eORDER_INTERNAL) = 0;
49  virtual iterator_leaf endLeaf(E_IteratorOrder order = eORDER_INTERNAL) = 0;
50 
51  virtual const_iterator_leaf beginLeaf(FilterHandle filter, WindowHandle limits = WindowHandle()) const = 0;
52  virtual const_iterator_leaf endLeaf(FilterHandle filter, WindowHandle limits = WindowHandle()) const = 0;
53 
54  virtual PointIndexLeafHandle getLeaf(const_iterator_point &it) = 0;
55  virtual PointIndexLeafHandle getLeaf(int64_t leafId) = 0;
56 
57  // access functions ============================================================================
58  virtual PointHandle getPoint(int64_t id) const = 0; ///< get point by id (if the id doesn't exist an empty handle is returned)
59 
60  // Spatial access functions =====================================================================
61  virtual void searchPoint(const IWindow &win, insert_iterator_point &insIt, bool includeRightBoundary = true) = 0;
62  virtual void searchPoint(const IBox &box, insert_iterator_point &insIt, bool includeRightBoundary = true) = 0;
63  virtual void searchPoint(const IPolygon &p, insert_iterator_point &insIt) = 0;
64  virtual void searchPoint(const ICircle &c, insert_iterator_point &instIt) = 0;
65  virtual void searchPoint(const ISphere &s, insert_iterator_point &instIt) = 0;
66  virtual void searchPoint(const ICylinder &c, insert_iterator_point &instIt) = 0;
67 
68  virtual void searchPoint(const IWindow &win, insert_iterator_point &insIt, insert_iterator_leaf &insLeaf, bool includeRightBoundary = true) = 0;
69  virtual void searchPoint(const IBox &box, insert_iterator_point &insIt, insert_iterator_leaf &insLeaf, bool includeRightBoundary = true) = 0;
70  virtual void searchPoint(const IPolygon &p, insert_iterator_point &insIt, insert_iterator_leaf &insLeaf) = 0;
71  virtual void searchPoint(const ICircle &c, insert_iterator_point &instIt, insert_iterator_leaf &insLeaf) = 0;
72  virtual void searchPoint(const ISphere &s, insert_iterator_point &instIt, insert_iterator_leaf &insLeaf) = 0;
73  virtual void searchPoint(const ICylinder &c, insert_iterator_point &instIt, insert_iterator_leaf &insLeaf) = 0;
74 
75  /// \brief k nearest neighbour search
76  /// potentially slow for the overall point index object. consider building a local kd tree -> IPointIndexLeaf
77  ///
78  /// \param[in] nnCount number of k neighbour to find
79  /// \param[in] queryPt base point for the neighbour search
80  /// \param[in] instIt insert iterator for collecting the found geometry objects
81  /// \param[in] maxDistance maximum distance (not squared distance) for finding geometry objects (use -1 disabling the distance limit)
82  /// \return distance to the furthest found geometry object or 'maxDistance' in case on object was found
83  virtual double searchPoint(int nnCount, const IPoint &queryPt, insert_iterator_point &instIt,
84  double maxDistance = -1) = 0;
85  /// \brief k nearest neighbour search
86  /// potentially slow for the overall point index object. consider building a local kd tree -> IPointIndexLeaf
87  ///
88  /// \param[in] nnCount number of k neighbour to find
89  /// \param[in] queryPt base point for the neighbour search
90  /// \param[in] instIt insert iterator for collecting the found geometry objects
91  /// \param[in] insLeaf leaf inster iterator for storing all leafs for which nearest neighbour points where returned
92  /// \param[in] maxDistance maximum distance (not squared distance) for finding geometry objects (use -1 disabling the distance limit)
93  /// \return distance to the furthest found geometry object or 'maxDistance' in case on object was found
94  virtual double searchPoint(int nnCount, const IPoint &queryPt, insert_iterator_point &instIt, insert_iterator_leaf &insLeaf,
95  double maxDistance = -1) = 0;
96 
97  // Memory consumption functions ================================================================
98  virtual int64_t sizePointCache() const = 0;
99  virtual void sizePointCache(int64_t size) = 0;
100 
101  // efficiency function. access leaf properties without loading point data into memory ===========
102  virtual BoxHandle getLimit(const const_iterator_leaf &it) const = 0;
103  virtual BoxHandle getIndexLimit(const const_iterator_leaf &it) const = 0;
104  virtual int64_t sizePoint(const const_iterator_leaf &it) const = 0;
105  virtual int64_t id(const const_iterator_leaf &it) const = 0;
106 
107  virtual AddInfoStatisticsHandle getAddInfoStatistics() const = 0;
108  virtual AddInfoStatisticsHandle getLeafAddInfoStatistics(const const_iterator_leaf &it) const = 0;
109  virtual IndexStatsHandle getIndexStatistics() const = 0;
110 
111  // get all leafs within window ==================================================================
112  virtual void searchLeaf(const IWindow &win, insert_iterator_leaf &insLeaf, bool includeRightBoundary = true) = 0;
113 
114  //drop all freeable memory object
115  virtual void freeMemory() const = 0;
116 
117  //gives the pointindex a hint for a possible tile size
118  virtual void tileSizeHint(double tilesize) = 0;
119 };
120 
121 typedef Handle< IPointIndex > PointIndexHandle;
122 
123 DM_NAMESPACE_END
124 
125 #endif //DM_IPOINT_INDEX_HPP_INCLUDED