The QuadTreeSub class each nide below QuadTree will be a QuadTreeSub type.
More...
#include <quadtree.h>
|
void | _retrieve (std::vector< E > &list, const short maxLevel) const |
| retrieve all object's that are located within a given area More...
|
|
void | _retrieve (std::vector< E > &list, const geo::Area &area, const short maxLevel) const |
| retrieve all object's that are located within a given area More...
|
|
unsigned int | _size (unsigned int c) const |
|
short | quadrantIndex (const geo::Area &pRect) const |
| quadrantIndex located a possible quadrant index More...
|
|
bool | includes (const geo::Area &area) const |
|
void | split () |
| split Create 4 new quads below the current quad More...
|
|
template<typename E>
class lc::QuadTreeSub< E >
The QuadTreeSub class each nide below QuadTree will be a QuadTreeSub type.
Definition at line 25 of file quadtree.h.
Definition at line 27 of file quadtree.h.
const double _verticalMidpoint
short maxLevels() const
maxLevels Maximum number of level's possible This value should be copied from one level to a other le...
std::vector< E > _objects
const unsigned short _maxLevels
const double _horizontalMidpoint
short level() const
level returns the current level of this QuadTree
const unsigned short _maxObjects
short maxObjects() const
maxObjects Maximum number of objects on this level This value should be copied one level to a other l...
Definition at line 42 of file quadtree.h.
geo::Area bounds() const
bounds of the root portion of the tree
Definition at line 46 of file quadtree.h.
47 QuadTreeSub(0, other.bounds(), other.maxLevels(), other.maxObjects()) {
48 for (
auto i : other.retrieve()) {
void insert(const E entity, const lc::geo::Area &entityBoundingBox)
insert Insert entity into the qauad tree
Definition at line 53 of file quadtree.h.
53 :
QuadTreeSub(0, geo::Area(geo::Coordinate(0., 0.), geo::Coordinate(1., 1.)), 10, 25) {
template<typename E>
void lc::QuadTreeSub< E >::_retrieve |
( |
std::vector< E > & |
list, |
|
|
const short |
maxLevel |
|
) |
| const |
|
inlineprivate |
retrieve all object's that are located within a given area
- Parameters
-
Definition at line 326 of file quadtree.h.
std::vector< E > _objects
void _retrieve(std::vector< E > &list, const short maxLevel) const
retrieve all object's that are located within a given area
retrieve all object's that are located within a given area
- Parameters
-
Definition at line 342 of file quadtree.h.
std::vector< E > _objects
bool includes(const geo::Area &area) const
void _retrieve(std::vector< E > &list, const short maxLevel) const
retrieve all object's that are located within a given area
Return the number of items in this and lower nodes
Definition at line 366 of file quadtree.h.
367 if (
_nodes[0] !=
nullptr) {
std::vector< E > _objects
unsigned int _size(unsigned int c) const
bounds of the root portion of the tree
- Returns
Definition at line 223 of file quadtree.h.
clear Clear the quad tree by removing all levels and removing all stored entities
Definition at line 70 of file quadtree.h.
71 if (
_nodes[0] !=
nullptr) {
template<typename E>
template<typename U , typename T >
Call a function for each entity within this node and it's sub nodes
Definition at line 274 of file quadtree.h.
275 if (
_nodes[0] !=
nullptr) {
276 _nodes[0]->template each<U>(func);
277 _nodes[1]->template each<U>(func);
278 _nodes[2]->template each<U>(func);
279 _nodes[3]->template each<U>(func);
283 std::shared_ptr<U> b = std::dynamic_pointer_cast< U >(item);
std::vector< E > _objects
entityByID returns a entity by its ID
- Parameters
-
- Returns
Definition at line 205 of file quadtree.h.
std::vector< E > retrieve(const geo::Area &area, const short maxLevel=SHRT_MAX) const
retrieve all object's that are located within a given area
remove Remove entity from quad tree
- Parameters
-
Definition at line 143 of file quadtree.h.
145 if (
_nodes[0] !=
nullptr) {
155 for (
typename std::vector<E>::iterator it =
_objects.begin(); it !=
_objects.end(); it++) {
156 if ((*it)->id() == entity->id()) {
std::vector< E > _objects
bool erase(const E entity)
remove Remove entity from quad tree
short quadrantIndex(const geo::Area &pRect) const
quadrantIndex located a possible quadrant index
This if this node overlaps or includes a given area
Definition at line 414 of file quadtree.h.
const Coordinate minP() const
double x() const
Returns x of Coordinate.
double y() const
Returns y of Coordinate.
const Coordinate maxP() const
insert Insert entity into the qauad tree
- Parameters
-
Definition at line 90 of file quadtree.h.
92 if (
_nodes[0] !=
nullptr) {
95 if (entityIndex != -1) {
116 auto sentityBoundingBox = (*it)->boundingBox();
std::vector< E > _objects
const unsigned short _maxLevels
void insert(const E entity, const lc::geo::Area &entityBoundingBox)
insert Insert entity into the qauad tree
void split()
split Create 4 new quads below the current quad
const unsigned short _maxObjects
short quadrantIndex(const geo::Area &pRect) const
quadrantIndex located a possible quadrant index
maxLevels Maximum number of level's possible This value should be copied from one level to a other level within a single tree
- Returns
Definition at line 242 of file quadtree.h.
const unsigned short _maxLevels
maxObjects Maximum number of objects on this level This value should be copied one level to a other level within a single tree
- Returns
Definition at line 251 of file quadtree.h.
const unsigned short _maxObjects
optimise Optmise this tree. Current implementation will remove empty nodes up till the root node
- Returns
- true if this node doesn't contain any entities
Definition at line 294 of file quadtree.h.
295 if (
_nodes[0] !=
nullptr) {
301 if (ret1 && ret2 && ret3 && ret4) {
std::vector< E > _objects
bool optimise()
optimise Optmise this tree. Current implementation will remove empty nodes up till the root node ...
quadrantIndex located a possible quadrant index
- Parameters
-
- Returns
- -1 if it doesn't fit in any of the quadrants
Definition at line 380 of file quadtree.h.
384 bool bottomQuadrant = (pRect.minP().y() >
_bounds.
minP().
y()) &&
387 if (!(topQuadrant || bottomQuadrant)) {
391 bool leftQuadrant = (pRect.minP().x() >
_bounds.
minP().
x()) &&
396 if (!(leftQuadrant || rightQuandrant)) {
399 else if (topQuadrant && rightQuandrant) {
402 else if (topQuadrant && leftQuadrant) {
405 else if (bottomQuadrant && leftQuadrant) {
const Coordinate minP() const
const double _verticalMidpoint
double x() const
Returns x of Coordinate.
double y() const
Returns y of Coordinate.
const double _horizontalMidpoint
const Coordinate maxP() const
retrieve all object's that are located within a given area
- Parameters
-
Definition at line 172 of file quadtree.h.
void _retrieve(std::vector< E > &list, const short maxLevel) const
retrieve all object's that are located within a given area
template<typename E>
std::vector<E> lc::QuadTreeSub< E >::retrieve |
( |
const short |
maxLevel = SHRT_MAX | ) |
const |
|
inline |
retrieve all object's within this QuadTree up until some level
- Parameters
-
Definition at line 184 of file quadtree.h.
void _retrieve(std::vector< E > &list, const short maxLevel) const
retrieve all object's that are located within a given area
size all object's that are located within a given area
- Parameters
-
Definition at line 195 of file quadtree.h.
unsigned int _size(unsigned int c) const
split Create 4 new quads below the current quad
Definition at line 430 of file quadtree.h.
436 if (
_nodes[0] !=
nullptr) {
441 geo::Area(geo::Coordinate(x + subWidth, y + subHeight),
450 geo::Area(geo::Coordinate(x, y + subHeight),
459 geo::Area(geo::Coordinate(x, y),
460 geo::Coordinate(x + subWidth, y + subHeight)
468 geo::Area(geo::Coordinate(x + subWidth, y),
const Coordinate minP() const
double x() const
Returns x of Coordinate.
const unsigned short _maxLevels
double y() const
Returns y of Coordinate.
const Coordinate maxP() const
const unsigned short _maxObjects
double height() const
height Returns the height of this area
double width() const
width Returns the width of this area
walk Allows to walk over each node within the tree specifying a function that can be called for each QuadTreeSub
- Parameters
-
Definition at line 260 of file quadtree.h.
263 if (
_nodes[0] !=
nullptr) {
void walkQuad(const std::function< void(const QuadTreeSub< E > &)> &func)
walk Allows to walk over each node within the tree specifying a function that can be called for each ...
The documentation for this class was generated from the following file: