|
Stride Reference Manual
- generated for commit 9643b11
|
A k-d tree: a k-dimensional generalization of binary search trees This data structure allows for efficient lookup of points and range queries with an Axis-Aligned Bounding Box (when balanced). More...
#include <KdNode.h>


Public Member Functions | |
| KdTree () | |
| Constructor: builds an empty tree. More... | |
| void | Apply (std::function< bool(const P &)> f) const |
| Calls a function with each of the points in the tree. More... | |
| void | Apply (std::function< bool(const P &)> f, const AABBox< P > &box) const |
Calls a function with every point contained in box More... | |
| bool | Contains (const P &point) const |
| Test wether a point is contained in the tree. More... | |
| bool | Empty () const |
| Is the tree empty. More... | |
| std::size_t | GetHeight () const |
| Get the height of the tree (mostly for testing purposes). More... | |
| void | Insert (P point) |
| Insert a new point into the tree, using this often may result in an unbalanced tree. More... | |
| std::vector< P > | Query (const AABBox< P > &box) const |
Get all points in the tree that lie within box. More... | |
| std::size_t | Size () const |
| Get the size of the tree. More... | |
Static Public Member Functions | |
| static KdTree | Build (const std::vector< P > &points) |
| Build a balanced tree from the given set of points efficiently. More... | |
Static Private Member Functions | |
| template<std::size_t D> | |
| static std::unique_ptr< kd::Node< P, D > > | Construct (const std::vector< P > &points) |
Private Attributes | |
| std::size_t | m_size |
| The number of points in the tree. More... | |
| std::unique_ptr< kd::Node< P, 0 > > | m_root |
| The root node of the tree. More... | |
A k-d tree: a k-dimensional generalization of binary search trees This data structure allows for efficient lookup of points and range queries with an Axis-Aligned Bounding Box (when balanced).
The template parameter P should have the following attributes and operations:
static constexpr std::size_t dim: the number of dimensions of the point type.template <std::size_d D> get() const returns the coordinate of the Dth dimension of the point.template <std::size_t D> struct dimension_type has a member type type with return type for Get<D>.bool InBox(const AABB<P>& box) const indicates if a point falls withing the bounding box (only for range queries) | geopop::KdTree< P >::KdTree | ( | ) |
Constructor: builds an empty tree.
Definition at line 35 of file KdTree_def.h.
|
static |
Build a balanced tree from the given set of points efficiently.
| points | The points to insert in the resulting tree. |
Definition at line 40 of file KdTree_def.h.
References geopop::KdTree< P >::m_root, and geopop::KdTree< P >::m_size.
| void geopop::KdTree< P >::Apply | ( | std::function< bool(const P &)> | f | ) | const |
Calls a function with each of the points in the tree.
| f | A function that will be called with each point, if f returns false, traversal stops. |
Definition at line 49 of file KdTree_def.h.
References geopop::kd::BaseNode< P >::BorrowLeft(), geopop::kd::BaseNode< P >::BorrowRight(), geopop::kd::BaseNode< P >::GetPoint(), and geopop::KdTree< P >::m_root.
Referenced by geopop::KdTree< P >::Contains(), and geopop::KdTree< P >::Query().


| void geopop::KdTree< P >::Apply | ( | std::function< bool(const P &)> | f, |
| const AABBox< P > & | box | ||
| ) | const |
Calls a function with every point contained in box
| f | A function that will be called with each point within box, if f returns false, traversal stops. |
| box | The containing Axis-Aligned Bounding Box to search for points |
Definition at line 76 of file KdTree_def.h.
References geopop::kd::BaseNode< P >::BorrowSplitChild(), geopop::kd::BaseNode< P >::GetPoint(), geopop::AABBox< P >::lower, geopop::KdTree< P >::m_root, and geopop::AABBox< P >::upper.

| bool geopop::KdTree< P >::Contains | ( | const P & | point | ) | const |
Test wether a point is contained in the tree.
| point | The point to test. P should support bool operator==(const P&) const. |
Definition at line 100 of file KdTree_def.h.
References geopop::KdTree< P >::Apply().

| bool geopop::KdTree< P >::Empty | ( | ) | const |
Is the tree empty.
Definition at line 114 of file KdTree_def.h.
References geopop::KdTree< P >::Size().

| std::size_t geopop::KdTree< P >::GetHeight | ( | ) | const |
Get the height of the tree (mostly for testing purposes).
Definition at line 120 of file KdTree_def.h.
References geopop::kd::BaseNode< P >::BorrowLeft(), geopop::kd::BaseNode< P >::BorrowRight(), and geopop::KdTree< P >::m_root.

| void geopop::KdTree< P >::Insert | ( | P | point | ) |
Insert a new point into the tree, using this often may result in an unbalanced tree.
| point | The point to insert into the tree. |
Definition at line 139 of file KdTree_def.h.
References geopop::kd::BaseNode< P >::AddChild(), geopop::kd::BaseNode< P >::BorrowSplitChild(), geopop::KdTree< P >::m_root, and geopop::KdTree< P >::m_size.

| std::vector< P > geopop::KdTree< P >::Query | ( | const AABBox< P > & | box | ) | const |
Get all points in the tree that lie within box.
| box | The limiting AABB to search for points. |
box. Definition at line 158 of file KdTree_def.h.
References geopop::KdTree< P >::Apply().

| std::size_t geopop::KdTree< P >::Size | ( | ) | const |
Get the size of the tree.
Definition at line 171 of file KdTree_def.h.
References geopop::KdTree< P >::m_size.
Referenced by geopop::KdTree< P >::Empty().

|
staticprivate |
Definition at line 178 of file KdTree_def.h.
|
private |
The number of points in the tree.
Definition at line 108 of file KdTree.h.
Referenced by geopop::KdTree< P >::Build(), geopop::KdTree< P >::Insert(), and geopop::KdTree< P >::Size().
|
private |
The root node of the tree.
Definition at line 109 of file KdTree.h.
Referenced by geopop::KdTree< P >::Apply(), geopop::KdTree< P >::Build(), geopop::KdTree< P >::GetHeight(), and geopop::KdTree< P >::Insert().