QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
RSpatialIndex.h
Go to the documentation of this file.
1
20#ifndef RSPATIALINDEX_H
21#define RSPATIALINDEX_H
22
23#include "core_global.h"
24
25// MSVC <= 2008 does not have this:
26//#include <stdint.h>
27
28#include <QDebug>
29#include <QSet>
30#include <QList>
31
32#include "RRequireHeap.h"
34
35class RBox;
36
38public:
39 RSpatialIndexDebugVisitor(QDebug dbg) : dbg(dbg) {}
41 virtual void visitData(
42 int id,
43 int pos,
44 double x1, double y1, double z1,
45 double x2, double y2, double z2);
46
47 virtual void visitNode(
48 double x1, double y1, double z1,
49 double x2, double y2, double z2) {
50 Q_UNUSED(x1)
51 Q_UNUSED(y1)
52 Q_UNUSED(z1)
53 Q_UNUSED(x2)
54 Q_UNUSED(y2)
55 Q_UNUSED(z2)
56 }
57
58 QDebug dbg;
59 QList<QPair<int, int> > matches;
60};
61
62
70public:
72 }
73
74 virtual ~RSpatialIndex() {
75 }
76
77 static qint64 getSIId(int id, int pos);
78 static int getId(qint64 siid);
79 static int getPos(qint64 siid);
80
81 virtual RSpatialIndex* create() = 0;
82 virtual void clear() = 0;
83
84 virtual void bulkLoad(const QList<int>& ids, const QList<QList<RBox> >& bbs);
85
86 virtual void bulkLoadSimple(const QList<int>& ids, const QList<RBox>& bbs);
87
91 virtual void addToIndex(
92 int id, int pos,
93 double x1, double y1, double z1,
94 double x2, double y2, double z2
95 ) = 0;
96
100 virtual void addToIndex(
101 int id, int pos,
102 const RBox& bb
103 );
104
109 virtual void addToIndex(
110 int id,
111 const QList<RBox>& bbs
112 );
113
117 //virtual void removeFromIndex(int id) = 0;
118
123 virtual bool removeFromIndex(
124 int id, int pos,
125 double x1, double y1, double z1,
126 double x2, double y2, double z2) = 0;
127
132 virtual bool removeFromIndex(int id, int pos, const RBox& bb);
133
138 virtual bool removeFromIndex(int id, const QList<RBox>& bb);
139
155 double x1, double y1, double z1,
156 double x2, double y2, double z2,
157 RSpatialIndexVisitor* dataVisitor=NULL
158 ) = 0;
159
164 virtual QMap<int, QSet<int> > queryIntersected(
165 const RBox& b,
166 RSpatialIndexVisitor* dataVisitor=NULL
167 );
168
183 double x1, double y1, double z1,
184 double x2, double y2, double z2,
185 RSpatialIndexVisitor* dataVisitor=NULL
186 ) = 0;
187
192 virtual QMap<int, QSet<int> > queryContained(
193 const RBox& b,
194 RSpatialIndexVisitor* dataVisitor=NULL
195 );
196
197 QList<int> queryContainedIds(
198 double x1, double y1, double z1,
199 double x2, double y2, double z2,
200 RSpatialIndexVisitor* dataVisitor = NULL);
201
212 unsigned int k,
213 double x, double y, double z,
214 RSpatialIndexVisitor* dataVisitor=NULL
215 ) = 0;
216
217 virtual QPair<int, int> queryNearestNeighbor(double x, double y, double z);
218
219protected:
221};
222
223QCADCORE_EXPORT QDebug operator<<(QDebug dbg, RSpatialIndex& si);
224
227
228#endif
Q_DECLARE_METATYPE(RMath *)
QCADCORE_EXPORT QDebug operator<<(QDebug dbg, RSpatialIndex &si)
Stream operator for QDebug.
Definition RSpatialIndex.cpp:156
Definition RDebug.h:38
Represents a box e.g.
Definition RBox.h:46
Copyright (c) 2011-2018 by Andrew Mustun.
Definition RRequireHeap.h:30
Definition RSpatialIndex.h:37
RSpatialIndexDebugVisitor(QDebug dbg)
Definition RSpatialIndex.h:39
virtual void visitNode(double x1, double y1, double z1, double x2, double y2, double z2)
Definition RSpatialIndex.h:47
virtual ~RSpatialIndexDebugVisitor()
Definition RSpatialIndex.h:40
QDebug dbg
Definition RSpatialIndex.h:58
QList< QPair< int, int > > matches
Definition RSpatialIndex.h:59
Abstract base class for spatial index implementations.
Definition RSpatialIndex.h:69
virtual ~RSpatialIndex()
Definition RSpatialIndex.h:74
virtual QMap< int, QSet< int > > queryContained(double x1, double y1, double z1, double x2, double y2, double z2, RSpatialIndexVisitor *dataVisitor=NULL)=0
Queries the index for all items that are completely inside the given box x1,y1,z1,...
virtual void clear()=0
virtual QMap< int, QSet< int > > queryNearestNeighbor(unsigned int k, double x, double y, double z, RSpatialIndexVisitor *dataVisitor=NULL)=0
Queries the index for closest neighbor items.
virtual bool removeFromIndex(int id, int pos, double x1, double y1, double z1, double x2, double y2, double z2)=0
Removes the entry with the given ID from this spatial index.
virtual QMap< int, QSet< int > > queryIntersected(double x1, double y1, double z1, double x2, double y2, double z2, RSpatialIndexVisitor *dataVisitor=NULL)=0
Queries the index for all items that are completely inside or intersect with the given box x1,...
virtual RSpatialIndex * create()=0
RSpatialIndex()
Definition RSpatialIndex.h:71
virtual void addToIndex(int id, int pos, double x1, double y1, double z1, double x2, double y2, double z2)=0
Adds a new entry into this spatial index.
int idCounter
Definition RSpatialIndex.h:220
Copyright (c) 2011-2018 by Andrew Mustun.
Definition RSpatialIndexVisitor.h:35
virtual void visitData(int id, int pos, double x1, double y1, double z1, double x2, double y2, double z2)=0
#define QCADCORE_EXPORT
Definition core_global.h:10
#define NULL
Definition opennurbs_system.h:256