SpatiumLib
|
Quadtree spatial index for 2D points. More...
#include <Quadtree.h>
Public Member Functions | |
PointQuadtree (const BoundingBox< double, 2 > &bounds, size_t maxPointCountLeaf=100) | |
Constructor. More... | |
bool | addPoint (const std::array< double, 2 > &point) |
Add a point to the quadtree. More... | |
BoundingBox< double, 2 > | bounds () const |
size_t | maxPointCountLeaf () const |
Get the maximum point count in a leaf node. More... | |
![]() | |
Tree (std::shared_ptr< TreeNode< std::vector< std::array< double, 2 > > >> rootNode=std::make_shared< TreeNode< std::vector< std::array< double, 2 > > >>()) | |
Constructor. More... | |
Tree (const std::vector< std::array< double, 2 > > &rootObject, const std::shared_ptr< TreeNode< std::vector< std::array< double, 2 > > >> &rootNode=std::make_shared< TreeNode< std::vector< std::array< double, 2 > > >>()) | |
Constructor. More... | |
std::shared_ptr< TreeNode< std::vector< std::array< double, 2 > > > > | root () const |
Get the root node. More... | |
TreeIterator< std::vector< std::array< double, 2 > > > | begin () |
Get iterator pointing to the beginning of the tree (root node). More... | |
TreeIterator< std::vector< std::array< double, 2 > > > | end () |
Get iterator pointing to the end of the tree. More... | |
Static Public Member Functions | |
static PointQuadtree | buildFromPoints (const std::vector< std::array< double, 2 >> &points, size_t maxPointCountLeaf=100) |
Construct quadtree from points. More... | |
static size_t | determineChild (const BoundingBox< double, 2 > &boundsParent, const std::array< double, 2 > &point, BoundingBox< double, 2 > &boundsChild) |
Determine index of child (0 - 3) depening on bounding box of parent and positon of a point. Also outputs the bounding box of this child. More... | |
Protected Attributes | |
const BoundingBox< double, 2 > | m_boundingBox |
const size_t | m_maxPointCountLeaf |
![]() | |
const std::shared_ptr< TreeNode< std::vector< std::array< double, 2 > > > > | m_root |
Quadtree spatial index for 2D points.
|
inline |
Constructor.
|
inline |
Add a point to the quadtree.
This will traverse the tree topdown from root into its children untill the right leaf node is found. The leaf node will be split into 4 when the maximum point count for a leaf node is exceeded.
[in] | point | Point |
|
inline |
|
inlinestatic |
Construct quadtree from points.
[in] | points | Collection of points |
[in] | maxPointCountLeaf | Maximum number of points in a leaf node. Node will be split into 4 children when exceeded. |
|
inlinestatic |
Determine index of child (0 - 3) depening on bounding box of parent and positon of a point. Also outputs the bounding box of this child.
[in] | boundsParent | Bounding box of parent |
[in] | point | Point positon (must be within bounding box) |
[out] | boundsChild | Bounding box of child |
|
inline |
Get the maximum point count in a leaf node.
A node is split when it exceeds this number.
|
protected |
|
protected |