Cortex
10.0.0-a4
|
#include <KDTree.h>
Classes | |
class | Neighbour |
The Neighbour class is used to return information from the KDTree::nearestNNeighbours() query. More... | |
class | Node |
The Node class which is used to implement the branching structure in the KDTree. More... | |
Public Types | |
typedef PointIterator | Iterator |
typedef std::iterator_traits< PointIterator >::value_type | Point |
typedef VectorTraits< Point >::BaseType | BaseType |
typedef std::vector< Node > | NodeVector |
typedef NodeVector::size_type | NodeIndex |
Public Member Functions | |
KDTree () | |
KDTree (PointIterator first, PointIterator last, int maxLeafSize=4) | |
void | init (PointIterator first, PointIterator last, int maxLeafSize=4) |
PointIterator | nearestNeighbour (const Point &p) const |
PointIterator | nearestNeighbour (const Point &p, BaseType &distSquared) const |
unsigned int | nearestNeighbours (const Point &p, BaseType r, std::vector< PointIterator > &nearNeighbours) const |
unsigned int | nearestNNeighbours (const Point &p, unsigned int numNeighbours, std::vector< Neighbour > &nearNeighbours) const |
template<typename Box , typename OutputIterator > | |
void | enclosedPoints (const Box &bound, OutputIterator it) const |
NodeIndex | numNodes () const |
Returns the number of nodes in the tree. | |
const Node & | node (NodeIndex index) const |
NodeIndex | rootIndex () const |
Returns the index for the root node. | |
NodeIndex | lowChildIndex (NodeIndex parentIndex) const |
NodeIndex | highChildIndex (NodeIndex parentIndex) const |
The KDTree class provides accelerated searching of pointsets. It is templated so that it can operate on a wide variety of datatypes, and uses the VectorTraits.h and VectorOps.h functionality to assist in this.
IECore::KDTree< PointIterator >::KDTree | ( | ) |
Constructs an unititialised tree - you must call init() before using it.
IECore::KDTree< PointIterator >::KDTree | ( | PointIterator | first, |
PointIterator | last, | ||
int | maxLeafSize = 4 |
||
) |
Creates a tree for the fast searching of points. Note that the tree does not own the passed points - it is up to you to ensure that they remain valid and unchanged as long as the KDTree is in use.
void IECore::KDTree< PointIterator >::enclosedPoints | ( | const Box & | bound, |
OutputIterator | it | ||
) | const |
Finds all the points contained by the specified bound, outputting them to the specified iterator.
|
inline |
Returns the index for the "high" child of the specified Node. This will only be valid if parent.isBranch() is true.
void IECore::KDTree< PointIterator >::init | ( | PointIterator | first, |
PointIterator | last, | ||
int | maxLeafSize = 4 |
||
) |
Builds the tree for the specified points - the iterator range must remain valid and unchanged as long as the tree is in use. This method can be called again to rebuild the tree at any time.
|
inline |
Returns the index for the "low" child of the specified Node. This will only be valid if parent.isBranch() is true.
PointIterator IECore::KDTree< PointIterator >::nearestNeighbour | ( | const Point & | p | ) | const |
Returns an iterator to the nearest neighbour to the point p.
PointIterator IECore::KDTree< PointIterator >::nearestNeighbour | ( | const Point & | p, |
BaseType & | distSquared | ||
) | const |
Returns an iterator to the nearest neighbour to the point p, and places the squared distance between these two points in distSquared. The initial value of distSquared constrains the search to return only points which are closer than sqrt(distSquared) to p. In the event of no such point being found, an iterator to the end of the points is returned (the "last" parameter which was passed to the constructor).
unsigned int IECore::KDTree< PointIterator >::nearestNeighbours | ( | const Point & | p, |
BaseType | r, | ||
std::vector< PointIterator > & | nearNeighbours | ||
) | const |
Populates the passed vector of iterators with the neighbours of point p which are closer than radius r. Returns the number of points found.
unsigned int IECore::KDTree< PointIterator >::nearestNNeighbours | ( | const Point & | p, |
unsigned int | numNeighbours, | ||
std::vector< Neighbour > & | nearNeighbours | ||
) | const |
Populates the passed vector with the N closest neighbours to p, sorted with the closest first. Returns the number found.
|
inline |
Returns the specified Node of the tree. See rootIndex(), lowChildIndex() and highChildIndex() for means of getting appropriate indices. This can be used to implement algorithms not provided as member functions.
Referenced by IECoreMaya.FnDagNode::defaultShapeName(), IECoreMaya.ParameterUI::description(), IECoreMaya.ParameterUI::nodeName(), IECoreMaya.ParameterUI::plug(), IECoreMaya.ParameterUI::plugName(), IECoreMaya.ParameterUI::registerPopupMenuCallback(), and IECoreMaya.ClassVectorParameterUI::setCollapsed().