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 RSpatialIndex* create();
46  virtual void clear();
47 
51  virtual void addToIndex(
52  int id, int pos,
53  double x1, double y1, double z1,
54  double x2, double y2, double z2
55  );
56 
57  //virtual void removeFromIndex(int id);
58  virtual bool removeFromIndex(
59  int id, int pos,
60  double x1, double y1, double z1,
61  double x2, double y2, double z2);
62 
63  virtual bool removeFromIndex(int id, const QList<RBox>& bb);
64 
65  virtual QMap<int, QSet<int> > queryIntersected(
66  double x1, double y1, double z1,
67  double x2, double y2, double z2,
68  RSpatialIndexVisitor* dataVisitor=NULL
69  );
70 
71  virtual QMap<int, QSet<int> > queryContained(
72  double x1, double y1, double z1,
73  double x2, double y2, double z2,
74  RSpatialIndexVisitor* dataVisitor=NULL
75  );
76 
77  virtual QMap<int, QSet<int> > queryNearestNeighbor(
78  uint k,
79  double x, double y, double z,
80  RSpatialIndexVisitor* dataVisitor=NULL
81  );
82 
83 protected:
84  //QMultiHash<RBox, int> si;
85  QMap<int, QList<RBox> > si;
86 };
87 
88 //QDebug operator<<(QDebug dbg, RSpatialIndexSimple& si);
89 
91 
92 #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-2016 by Andrew Mustun.
Definition: RSpatialIndexVisitor.h:35
#define QCADCORE_EXPORT
Definition: core_global.h:10
Copyright (c) 2011-2016 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:85
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.
virtual RSpatialIndex * create()=0
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...