|
INET Framework for OMNeT++/OMNEST
|
#include <QuadTree.h>
|
| typedef std::vector< const cObject * > | Points |
| |
◆ Points
◆ QuadTree()
| inet::QuadTree::QuadTree |
( |
const Coord & |
boundaryMin, |
|
|
const Coord & |
boundaryMax, |
|
|
unsigned int |
quadrantCapacity, |
|
|
QuadTree * |
parent |
|
) |
| |
◆ ~QuadTree()
| inet::QuadTree::~QuadTree |
( |
| ) |
|
◆ doesIntersectWithQuadrant()
| bool inet::QuadTree::doesIntersectWithQuadrant |
( |
const Coord & |
pos, |
|
|
double |
range |
|
) |
| const |
|
protected |
132 Coord minRectangleBoundary = pos;
133 Coord maxRectangleBoundary = pos;
134 minRectangleBoundary.x -= range;
135 minRectangleBoundary.y -= range;
136 maxRectangleBoundary.x += range;
137 maxRectangleBoundary.y += range;
Referenced by rangeQuery(), and strictRangeQuery().
◆ hasChild()
| bool inet::QuadTree::hasChild |
( |
| ) |
const |
|
protected |
◆ insert()
| bool inet::QuadTree::insert |
( |
const cObject * |
point, |
|
|
const Coord & |
pos |
|
) |
| |
19 (*lastPosition)[point] = pos;
29 if (elem->insert(point, pos))
31 throw cRuntimeError(
"QuadTree insertion failed for object: %s with position: (%f, %f, %f)", point->getFullName(), pos.x, pos.y, pos.z);
Referenced by inet::physicallayer::QuadTreeNeighborCache::addRadio(), inet::physicallayer::QuadTreeNeighborCache::fillQuadTreeWithRadios(), move(), and splitPoints().
◆ isInRectangleRange()
| bool inet::QuadTree::isInRectangleRange |
( |
const Coord & |
pointCoord | ) |
const |
|
protected |
◆ move()
| bool inet::QuadTree::move |
( |
const cObject * |
point, |
|
|
const Coord & |
newPos |
|
) |
| |
228 if (quadrant ==
nullptr)
229 throw cRuntimeError(
"Quadrant not found for point (%f %f %f)", newPos.x, newPos.y, newPos.z);
230 auto it =
find(quadrant->points, point);
234 if (it != quadrant->points.end())
◆ rangeQuery()
| void inet::QuadTree::rangeQuery |
( |
const Coord & |
pos, |
|
|
double |
range, |
|
|
const IVisitor * |
visitor |
|
) |
| const |
◆ remove()
| bool inet::QuadTree::remove |
( |
const cObject * |
point | ) |
|
153 lastPos = lastIt->second;
155 if (quadrant ==
nullptr)
156 throw cRuntimeError(
"Quadrant not found for point: (%f, %f, %f)", lastPos.x, lastPos.y, lastPos.z);
157 auto it =
find(quadrant->points, point);
159 if (it != quadrant->points.end()) {
161 quadrant->points.erase(it);
164 throw cRuntimeError(
"Point (%f, %f, %f) not found in its quadrant's vector", lastPos.x, lastPos.y, lastPos.z);
165 quadrant->parent->tryToJoinChildQuadrants();
Referenced by move(), and inet::physicallayer::QuadTreeNeighborCache::removeRadio().
◆ searchQuadrant()
| QuadTree * inet::QuadTree::searchQuadrant |
( |
const Coord & |
lastPos | ) |
|
|
protected |
◆ setBoundary()
| void inet::QuadTree::setBoundary |
( |
Coord * |
minBoundaries, |
|
|
Coord * |
maxBoundaries |
|
) |
| const |
|
protected |
◆ setToLeaf()
| void inet::QuadTree::setToLeaf |
( |
| ) |
|
|
protected |
◆ splitPoints()
| void inet::QuadTree::splitPoints |
( |
| ) |
|
|
protected |
70 Coord minBoundaries[4], maxBoundaries[4];
73 for (
unsigned int i = 0; i < 4; i++)
77 for (
auto& elem :
points) {
80 throw cRuntimeError(
"Last position not found for object: %s", elem->getFullName());
81 Coord pos = it->second;
Referenced by insert().
◆ strictRangeQuery()
| void inet::QuadTree::strictRangeQuery |
( |
const Coord & |
pos, |
|
|
double |
range, |
|
|
const IVisitor * |
visitor |
|
) |
| const |
112 for (
auto& elem :
points) {
113 Coord otherPos = (*lastPosition)[elem];
114 if (pos.sqrdist(otherPos) <= range * range)
115 visitor->visit(elem);
120 elem->strictRangeQuery(pos, range, visitor);
◆ tryToJoinChildQuadrants()
| void inet::QuadTree::tryToJoinChildQuadrants |
( |
| ) |
|
|
protected |
194 unsigned int quadrantSum = 0;
199 if (elem->hasChild())
201 quadrantSum += elem->points.size();
210 for (
auto& elem : quadrant->points)
Referenced by remove(), and tryToJoinChildQuadrants().
◆ whichQuadrant()
| unsigned int inet::QuadTree::whichQuadrant |
( |
const Coord & |
pos | ) |
const |
|
protected |
37 for (
unsigned int i = 0; i < 4; i++)
40 throw cRuntimeError(
"QuadTree failed to determine to which quadrant point (%f, %f, %f) belongs to", pos.x, pos.y, pos.z);
Referenced by splitPoints().
◆ boundaryMax
| Coord inet::QuadTree::boundaryMax |
|
protected |
◆ boundaryMin
| Coord inet::QuadTree::boundaryMin |
|
protected |
◆ lastPosition
| std::map<const cObject *, Coord>* inet::QuadTree::lastPosition |
|
protected |
◆ parent
◆ points
◆ quadrantCapacity
| unsigned int inet::QuadTree::quadrantCapacity |
|
protected |
◆ quadrants
The documentation for this class was generated from the following files:
void setBoundary(Coord *minBoundaries, Coord *maxBoundaries) const
Definition: QuadTree.cc:44
bool doesIntersectWithQuadrant(const Coord &pos, double range) const
Definition: QuadTree.cc:130
Points points
Definition: QuadTree.h:33
std::vector< T >::iterator find(std::vector< T > &v, const Tk &a)
Definition: stlutils.h:44
double x
Definition: Coord.h:36
Coord boundaryMax
Definition: QuadTree.h:32
bool hasChild() const
Definition: QuadTree.cc:187
bool remove(const cObject *point)
Definition: QuadTree.cc:142
void splitPoints()
Definition: QuadTree.cc:68
QuadTree * parent
Definition: QuadTree.h:35
Coord boundaryMin
Definition: QuadTree.h:31
unsigned int whichQuadrant(const Coord &pos) const
Definition: QuadTree.cc:35
std::map< const cObject *, Coord > * lastPosition
Definition: QuadTree.h:27
bool insert(const cObject *point, const Coord &pos)
Definition: QuadTree.cc:14
void setToLeaf()
Definition: QuadTree.cc:90
double y
Definition: Coord.h:37
void tryToJoinChildQuadrants()
Definition: QuadTree.cc:192
bool isInRectangleRange(const Coord &pointCoord) const
Definition: QuadTree.cc:124
QuadTree * quadrants[4]
Definition: QuadTree.h:34
QuadTree(const Coord &boundaryMin, const Coord &boundaryMax, unsigned int quadrantCapacity, QuadTree *parent)
Definition: QuadTree.cc:240
unsigned int quadrantCapacity
Definition: QuadTree.h:30
QuadTree * searchQuadrant(const Coord &lastPos)
Definition: QuadTree.cc:169