QCAD Application Framework
CAD Application Development and Automation.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RSpatialIndex.h
Go to the documentation of this file.
1 #ifndef RSPATIALINDEX_H
2 #define RSPATIALINDEX_H
3 
4 #include <stdint.h>
5 
6 #include <QSet>
7 #include <QList>
8 
9 #include "RBox.h"
10 #include "RDebug.h"
11 #include "RMath.h"
12 #include "RRequireHeap.h"
13 #include "RSpatialIndexVisitor.h"
14 
16 public:
17  RSpatialIndexDebugVisitor(QDebug dbg) : dbg(dbg) {}
19  virtual void visitData(
20  int id,
21  int pos,
22  double x1, double y1, double z1,
23  double x2, double y2, double z2);
24 
25  virtual void visitNode(
26  double x1, double y1, double z1,
27  double x2, double y2, double z2) {
28  Q_UNUSED(x1)
29  Q_UNUSED(y1)
30  Q_UNUSED(z1)
31  Q_UNUSED(x2)
32  Q_UNUSED(y2)
33  Q_UNUSED(z2)
34  }
35 
36  QDebug dbg;
37  QList<QPair<int, int> > matches;
38 };
39 
40 
47 class RSpatialIndex: public RRequireHeap {
48 public:
50  }
51 
52  virtual ~RSpatialIndex() {
53  }
54 
55  static qint64 getSIId(int id, int pos);
56  static int getId(qint64 siid);
57  static int getPos(qint64 siid);
58 
59  virtual void clear() = 0;
60 
64  virtual void addToIndex(
65  int id, int pos,
66  double x1, double y1, double z1,
67  double x2, double y2, double z2
68  ) = 0;
69 
73  virtual void addToIndex(
74  int id, int pos,
75  const RBox& bb
76  );
77 
82  virtual void addToIndex(
83  int id,
84  const QList<RBox>& bbs
85  );
86 
90  //virtual void removeFromIndex(int id) = 0;
91 
96  virtual bool removeFromIndex(
97  int id, int pos,
98  double x1, double y1, double z1,
99  double x2, double y2, double z2) = 0;
100 
105  virtual bool removeFromIndex(int id, int pos, const RBox& bb);
106 
111  virtual bool removeFromIndex(int id, const QList<RBox>& bb);
112 
127  virtual QMap<int, QSet<int> > queryIntersected(
128  double x1, double y1, double z1,
129  double x2, double y2, double z2,
130  RSpatialIndexVisitor* dataVisitor=NULL
131  ) = 0;
132 
137  virtual QMap<int, QSet<int> > queryIntersected(
138  const RBox& b,
139  RSpatialIndexVisitor* dataVisitor=NULL
140  );
141 
155  virtual QMap<int, QSet<int> > queryContained(
156  double x1, double y1, double z1,
157  double x2, double y2, double z2,
158  RSpatialIndexVisitor* dataVisitor=NULL
159  ) = 0;
160 
165  virtual QMap<int, QSet<int> > queryContained(
166  const RBox& b,
167  RSpatialIndexVisitor* dataVisitor=NULL
168  );
169 
179  virtual QMap<int, QSet<int> > queryNearestNeighbor(
180  uint k,
181  double x, double y, double z,
182  RSpatialIndexVisitor* dataVisitor=NULL
183  ) = 0;
184 
185  virtual QPair<int, int> queryNearestNeighbor(double x, double y, double z);
186 
187 protected:
189 };
190 
191 QDebug operator<<(QDebug dbg, RSpatialIndex& si);
192 
194 
195 #endif