Library of Assembled Shared Sources
|
a KD tree for point-like objects More...
#include <kd_tree.h>
Public Member Functions | |
KdTree () | |
Constructs an empty k-d tree. | |
KdTree (TObjectIterator first, TObjectIterator last) | |
Constructs a k-d tree from objects in range [first, last). | |
void | reset () |
Resets to an empty tree. | |
void | reset (TObjectIterator first, TObjectIterator last) |
Resets to a new k-d tree of objects in range [first, last). | |
Neighbour | nearestNeighbour (const TPoint &target) const |
Locates the object that's nearest to a target position. | |
Neighbour | nearestNeighbour (const TPoint &target, TParam maxRadius) const |
Locates the object that's nearest to a target position, within a maximum range. | |
TValue | rangeSearch (const TPoint &target, TParam maxRadius, size_t maxCount, TNeighbourhood &neighbourhood) const |
Locates objects within a spherical range around a target position. | |
template<typename OutputIterator> | |
OutputIterator | rangeSearch (const TPoint &target, TParam maxRadius, OutputIterator first) const |
Find all objects in a radius of maxRadius of target. | |
void | swap (TSelf &other) |
Swap the representation of two k-d trees. | |
bool | isEmpty () const |
returns true if there are no objects in the k-d tree | |
void | clear () |
resest the k-d tree to an empty one. | |
template<typename RandomAccessIterator> | |
RandomAccessIterator | rangeSearch (const TPoint &target, TParam maxRadius, size_t maxCount, RandomAccessIterator first) const |
Find up to a fixed number of objects in a radius of maxRadius of target. | |
a KD tree for point-like objects
the KD tree does NOT own the objects. You must keep them yourself!
lass::spat::KdTree< O, OT >::KdTree | ( | TObjectIterator | first, |
TObjectIterator | last ) |
Constructs a k-d tree from objects in range [first, last).
Definition at line 80 of file kd_tree.inl.
void lass::spat::KdTree< O, OT >::reset | ( | TObjectIterator | first, |
TObjectIterator | last ) |
Resets to a new k-d tree of objects in range [first, last).
Definition at line 129 of file kd_tree.inl.
KdTree< O, OT >::TValue lass::spat::KdTree< O, OT >::rangeSearch | ( | const TPoint & | target, |
TParam | maxRadius, | ||
size_t | maxCount, | ||
TNeighbourhood & | neighbourhood ) const |
Locates objects within a spherical range around a target position.
target | [in] the center of the spherical range |
maxRadius | [in] the radius of the range |
maxCount | [in] the maximum number of objects to be returned.
|
neighbourhood | [out] a std::vector that will be filled with the found objects. The vector will be cleared before use. |
Definition at line 239 of file kd_tree.inl.
References isEmpty(), and rangeSearch().
Referenced by rangeSearch().
OutputIterator lass::spat::KdTree< O, OT >::rangeSearch | ( | const TPoint & | target, |
TParam | maxRadius, | ||
OutputIterator | first ) const |
Find all objects in a radius of maxRadius of target.
target | [in] center of range. |
maxRadius | [in] radius of range |
first | [in] output iterator dereferencable to Neighbour. |
Definition at line 297 of file kd_tree.inl.
References isEmpty().
RandomAccessIterator lass::spat::KdTree< ObjectType, ObjectTraits >::rangeSearch | ( | const TPoint & | target, |
TParam | maxRadius, | ||
size_t | maxCount, | ||
RandomAccessIterator | first ) const |
Find up to a fixed number of objects in a radius of maxRadius of target.
target | [in] center of range. |
maxRadius | [in] radius of range |
maxCount | [in] maximum number of objects to be found. |
first | [in] random access iterator dereferencable to Neighbour, [first, first + maxCount + 1) must be a valid range. |
Definition at line 334 of file kd_tree.inl.