QCAD
Open Source 2D CAD
RSpatialIndexSimple.h
Go to the documentation of this file.
1 
20 #ifndef RSPATIALINDEXSIMPLE_H
21 #define RSPATIALINDEXSIMPLE_H
22 
23 #include "core_global.h"
24 
25 #include <QSet>
26 #include <QList>
27 
28 #include "RSpatialIndex.h"
29 #include "RDebug.h"
30 #include "RMath.h"
31 
32 
33 
41 public:
43  virtual ~RSpatialIndexSimple();
44 
45  virtual void clear();
46 
50  virtual void addToIndex(
51  int id, int pos,
52  double x1, double y1, double z1,
53  double x2, double y2, double z2
54  );
55 
56  //virtual void removeFromIndex(int id);
57  virtual bool removeFromIndex(
58  int id, int pos,
59  double x1, double y1, double z1,
60  double x2, double y2, double z2);
61 
62  virtual bool removeFromIndex(int id, const QList<RBox>& bb);
63 
64  virtual QMap<int, QSet<int> > queryIntersected(
65  double x1, double y1, double z1,
66  double x2, double y2, double z2,
67  RSpatialIndexVisitor* dataVisitor=NULL
68  );
69 
70  virtual QMap<int, QSet<int> > queryContained(
71  double x1, double y1, double z1,
72  double x2, double y2, double z2,
73  RSpatialIndexVisitor* dataVisitor=NULL
74  );
75 
76  virtual QMap<int, QSet<int> > queryNearestNeighbor(
77  uint k,
78  double x, double y, double z,
79  RSpatialIndexVisitor* dataVisitor=NULL
80  );
81 
82 protected:
83  //QMultiHash<RBox, int> si;
84  QMap<int, QList<RBox> > si;
85 };
86 
87 //QDebug operator<<(QDebug dbg, RSpatialIndexSimple& si);
88 
90 
91 #endif
virtual void clear()=0
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,x2,y2,z2.
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RSpatialIndexVisitor.h:35
#define QCADCORE_EXPORT
Definition: core_global.h:10
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RSpatialIndexSimple.h:40
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.
QMap< int, QList< RBox > > si
Definition: RSpatialIndexSimple.h:84
Q_DECLARE_METATYPE(RMath *)
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.
Abstract base class for spatial index implementations.
Definition: RSpatialIndex.h:69
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...