Go to the documentation of this file.
7 #ifndef INCLUDE_JET_KDTREE_H
8 #define INCLUDE_JET_KDTREE_H
21 template <
typename T,
size_t K>
56 typedef typename ContainerType::iterator
Iterator;
78 const Point& origin, T radius,
79 const std::function<
void(
size_t,
const Point&)>& callback)
const;
120 void reserve(
size_t numPoints,
size_t numNodes);
123 std::vector<Point> _points;
124 std::vector<Node> _nodes;
126 size_t build(
size_t nodeIndex,
size_t* itemIndices,
size_t nItems,
127 size_t currentDepth);
132 #include "detail/kdtree-inl.h"
134 #endif // INCLUDE_JET_KDTREE_H
bool hasNearbyPoint(const Point &origin, T radius) const
Iterator begin()
Returns the mutable begin iterator of the item.
Generic k-d tree structure.
Definition: kdtree.h:22
size_t item
Item index.
Definition: kdtree.h:37
1-D read-only array accessor class.
Definition: array_accessor1.h:184
BoundingBox< T, K > BBox
Definition: kdtree.h:25
size_t nearestPoint(const Point &origin) const
Returns index of the nearest point.
ContainerType::iterator Iterator
Definition: kdtree.h:56
ConstIterator begin() const
Returns the immutable begin iterator of the item.
void initLeaf(size_t it, const Point &pt)
Initializes leaf node.
void forEachNearbyPoint(const Point &origin, T radius, const std::function< void(size_t, const Point &)> &callback) const
size_t flags
Split axis if flags < K, leaf indicator if flags == K.
Definition: kdtree.h:30
ConstNodeIterator beginNode() const
Returns the immutable begin iterator of the node.
NodeContainerType::const_iterator ConstNodeIterator
Definition: kdtree.h:61
NodeContainerType::iterator NodeIterator
Definition: kdtree.h:60
constexpr size_t kMaxSize
Max size_t.
Definition: constants.h:79
size_t child
Right child index. Note that left child index is this node index + 1.
Definition: kdtree.h:34
void reserve(size_t numPoints, size_t numNodes)
Reserves memory space for this tree.
Point point
Point stored in the node.
Definition: kdtree.h:40
Definition: advection_solver2.h:18
KdTree()
Constructs an empty kD-tree instance.
Simple K-d tree node.
Definition: kdtree.h:28
bool isLeaf() const
Returns true if leaf.
Node()
Default contructor.
ConstIterator end() const
Returns the immutable end iterator of the item.
ContainerType::const_iterator ConstIterator
Definition: kdtree.h:57
Iterator end()
Returns the mutable end iterator of the item.
Generic N-D axis-aligned bounding box class.
Definition: bounding_box.h:21
NodeIterator beginNode()
Returns the mutable begin iterator of the node.
void build(const ConstArrayAccessor1< Point > &points)
Builds internal acceleration structure for given points list.
std::vector< Point > ContainerType
Definition: kdtree.h:55
void initInternal(size_t axis, size_t it, size_t c, const Point &pt)
Initializes internal node.
ConstNodeIterator endNode() const
Returns the immutable end iterator of the node.
NodeIterator endNode()
Returns the mutable end iterator of the node.
std::vector< Node > NodeContainerType
Definition: kdtree.h:59
Vector< T, K > Point
Definition: kdtree.h:24