The class used internally to define the GNAT. More...
#include <hpp/fcl/knn/nearest_neighbors_GNAT.h>
Public Member Functions | |
Node (int degree, int capacity, const _T &pivot) | |
Construct a node of given degree with at most capacity data elements and wit given pivot. More... | |
~Node () | |
void | updateRadius (double dist) |
Update minRadius_ and maxRadius_, given that an element was added with distance dist to the pivot. More... | |
void | updateRange (unsigned int i, double dist) |
Update minRange_[i] and maxRange_[i], given that an element was added to the i-th child of the parent that has distance dist to this Node's pivot. More... | |
void | add (GNAT &gnat, const _T &data) |
Add an element to the tree rooted at this node. More... | |
bool | needToSplit (const GNAT &gnat) const |
Return true iff the node needs to be split into child nodes. More... | |
void | split (GNAT &gnat) |
The split operation finds pivot elements for the child nodes and moves each data element of this node to the appropriate child node. More... | |
bool | insertNeighborK (NearQueue &nbh, std::size_t k, const _T &data, const _T &key, double dist) const |
Insert data in nbh if it is a near neighbor. Return true iff data was added to nbh. More... | |
void | nearestK (const GNAT &gnat, const _T &data, std::size_t k, NearQueue &nbh, NodeQueue &nodeQueue, bool &isPivot) const |
Compute the k nearest neighbors of data in the tree. More... | |
void | insertNeighborR (NearQueue &nbh, double r, const _T &data, double dist) const |
Insert data in nbh if it is a near neighbor. More... | |
void | nearestR (const GNAT &gnat, const _T &data, double r, NearQueue &nbh, NodeQueue &nodeQueue) const |
Return all elements that are within distance r in nbh. More... | |
void | list (const GNAT &gnat, std::vector< _T > &data) const |
Public Attributes | |
unsigned int | degree_ |
Number of child nodes. More... | |
const _T | pivot_ |
Data element stored in this Node. More... | |
double | minRadius_ |
Minimum distance between the pivot element and the elements stored in data_. More... | |
double | maxRadius_ |
Maximum distance between the pivot element and the elements stored in data_. More... | |
std::vector< double > | minRange_ |
The i-th element in minRange_ is the minimum distance between the pivot and any data_ element in the i-th child node of this node's parent. More... | |
std::vector< double > | maxRange_ |
The i-th element in maxRange_ is the maximum distance between the pivot and any data_ element in the i-th child node of this node's parent. More... | |
std::vector< _T > | data_ |
The data elements stored in this node (in addition to the pivot element). More... | |
std::vector< Node * > | children_ |
The child nodes of this node. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &out, const Node &node) |
The class used internally to define the GNAT.
|
inline |
Construct a node of given degree with at most capacity data elements and wit given pivot.
References fcl::NearestNeighborsGNAT< _T >::Node::data_.
|
inline |
References fcl::NearestNeighborsGNAT< _T >::Node::children_.
|
inline |
Add an element to the tree rooted at this node.
References fcl::NearestNeighborsGNAT< _T >::Node::children_, fcl::NearestNeighborsGNAT< _T >::Node::data_, fcl::NearestNeighbors< _T >::distFun_, fcl::NearestNeighborsGNAT< _T >::Node::needToSplit(), fcl::NearestNeighborsGNAT< _T >::Node::pivot_, fcl::NearestNeighborsGNAT< _T >::rebuildDataStructure(), fcl::NearestNeighborsGNAT< _T >::rebuildSize_, fcl::NearestNeighborsGNAT< _T >::removed_, fcl::NearestNeighborsGNAT< _T >::size_, fcl::NearestNeighborsGNAT< _T >::Node::split(), and fcl::NearestNeighborsGNAT< _T >::Node::updateRange().
Referenced by fcl::NearestNeighborsGNAT< _T >::add().
|
inline |
Insert data in nbh if it is a near neighbor. Return true iff data was added to nbh.
Referenced by fcl::NearestNeighborsGNAT< _T >::Node::nearestK(), and fcl::NearestNeighborsGNAT< _T >::nearestKInternal().
|
inline |
Insert data in nbh if it is a near neighbor.
Referenced by fcl::NearestNeighborsGNAT< _T >::Node::nearestR(), and fcl::NearestNeighborsGNAT< _T >::nearestRInternal().
|
inline |
|
inline |
Compute the k nearest neighbors of data in the tree.
For k=1, isPivot is true if the nearest neighbor is a pivot (which is important during removal; removing pivots is a special case). The nodeQueue, which contains other Nodes that need to be checked for nearest neighbors, is updated.
References fcl::NearestNeighborsGNAT< _T >::Node::children_, fcl::NearestNeighborsGNAT< _T >::Node::data_, fcl::NearestNeighbors< _T >::distFun_, fcl::NearestNeighborsGNAT< _T >::Node::insertNeighborK(), fcl::NearestNeighborsGNAT< _T >::isRemoved(), fcl::NearestNeighborsGNAT< _T >::Node::maxRadius_, fcl::NearestNeighborsGNAT< _T >::Node::maxRange_, fcl::NearestNeighborsGNAT< _T >::Node::minRadius_, fcl::NearestNeighborsGNAT< _T >::Node::minRange_, and fcl::NearestNeighborsGNAT< _T >::Node::pivot_.
Referenced by fcl::NearestNeighborsGNAT< _T >::nearestKInternal().
|
inline |
Return all elements that are within distance r in nbh.
The nodeQueue, which contains other Nodes that need to be checked for nearest neighbors, is updated.
References fcl::NearestNeighborsGNAT< _T >::Node::children_, fcl::NearestNeighborsGNAT< _T >::Node::data_, fcl::NearestNeighbors< _T >::distFun_, fcl::NearestNeighborsGNAT< _T >::Node::insertNeighborR(), fcl::NearestNeighborsGNAT< _T >::isRemoved(), fcl::NearestNeighborsGNAT< _T >::Node::maxRadius_, fcl::NearestNeighborsGNAT< _T >::Node::maxRange_, fcl::NearestNeighborsGNAT< _T >::Node::minRadius_, fcl::NearestNeighborsGNAT< _T >::Node::minRange_, and fcl::NearestNeighborsGNAT< _T >::Node::pivot_.
Referenced by fcl::NearestNeighborsGNAT< _T >::nearestRInternal().
|
inline |
Return true iff the node needs to be split into child nodes.
References fcl::NearestNeighborsGNAT< _T >::Node::data_, fcl::NearestNeighborsGNAT< _T >::Node::degree_, and fcl::NearestNeighborsGNAT< _T >::maxNumPtsPerLeaf_.
Referenced by fcl::NearestNeighborsGNAT< _T >::add(), fcl::NearestNeighborsGNAT< _T >::Node::add(), and fcl::NearestNeighborsGNAT< _T >::Node::split().
|
inline |
The split operation finds pivot elements for the child nodes and moves each data element of this node to the appropriate child node.
References fcl::NearestNeighborsGNAT< _T >::Node::children_, fcl::NearestNeighborsGNAT< _T >::Node::data_, fcl::NearestNeighborsGNAT< _T >::Node::degree_, fcl::details::max(), fcl::NearestNeighborsGNAT< _T >::maxDegree_, fcl::NearestNeighborsGNAT< _T >::maxNumPtsPerLeaf_, fcl::NearestNeighborsGNAT< _T >::Node::maxRadius_, fcl::details::min(), fcl::NearestNeighborsGNAT< _T >::minDegree_, fcl::NearestNeighborsGNAT< _T >::Node::minRadius_, fcl::NearestNeighborsGNAT< _T >::Node::needToSplit(), fcl::NearestNeighborsGNAT< _T >::pivotSelector_, fcl::NearestNeighborsGNAT< _T >::Node::updateRadius(), and fcl::NearestNeighborsGNAT< _T >::Node::updateRange().
Referenced by fcl::NearestNeighborsGNAT< _T >::add(), and fcl::NearestNeighborsGNAT< _T >::Node::add().
|
inline |
Update minRadius_ and maxRadius_, given that an element was added with distance dist to the pivot.
References fcl::NearestNeighborsGNAT< _T >::Node::maxRadius_, and fcl::NearestNeighborsGNAT< _T >::Node::minRadius_.
Referenced by fcl::NearestNeighborsGNAT< _T >::Node::split().
|
inline |
Update minRange_[i] and maxRange_[i], given that an element was added to the i-th child of the parent that has distance dist to this Node's pivot.
References fcl::NearestNeighborsGNAT< _T >::Node::maxRange_, and fcl::NearestNeighborsGNAT< _T >::Node::minRange_.
Referenced by fcl::NearestNeighborsGNAT< _T >::Node::add(), and fcl::NearestNeighborsGNAT< _T >::Node::split().
|
friend |
std::vector<Node*> fcl::NearestNeighborsGNAT< _T >::Node::children_ |
The child nodes of this node.
By definition, only internal nodes have child nodes.
Referenced by fcl::NearestNeighborsGNAT< _T >::Node::add(), fcl::NearestNeighborsGNAT< _T >::Node::list(), fcl::NearestNeighborsGNAT< _T >::Node::nearestK(), fcl::NearestNeighborsGNAT< _T >::Node::nearestR(), fcl::NearestNeighborsGNAT< _T >::Node::split(), and fcl::NearestNeighborsGNAT< _T >::Node::~Node().
std::vector<_T> fcl::NearestNeighborsGNAT< _T >::Node::data_ |
The data elements stored in this node (in addition to the pivot element).
An internal node has no elements stored in data_.
Referenced by fcl::NearestNeighborsGNAT< _T >::add(), fcl::NearestNeighborsGNAT< _T >::Node::add(), fcl::NearestNeighborsGNAT< _T >::Node::list(), fcl::NearestNeighborsGNAT< _T >::Node::nearestK(), fcl::NearestNeighborsGNAT< _T >::Node::nearestR(), fcl::NearestNeighborsGNAT< _T >::Node::needToSplit(), fcl::NearestNeighborsGNAT< _T >::Node::Node(), and fcl::NearestNeighborsGNAT< _T >::Node::split().
unsigned int fcl::NearestNeighborsGNAT< _T >::Node::degree_ |
Number of child nodes.
Referenced by fcl::NearestNeighborsGNAT< _T >::Node::needToSplit(), and fcl::NearestNeighborsGNAT< _T >::Node::split().
double fcl::NearestNeighborsGNAT< _T >::Node::maxRadius_ |
Maximum distance between the pivot element and the elements stored in data_.
Referenced by fcl::NearestNeighborsGNAT< _T >::Node::nearestK(), fcl::NearestNeighborsGNAT< _T >::Node::nearestR(), fcl::NearestNeighborsGNAT< _T >::Node::split(), and fcl::NearestNeighborsGNAT< _T >::Node::updateRadius().
std::vector<double> fcl::NearestNeighborsGNAT< _T >::Node::maxRange_ |
The i-th element in maxRange_ is the maximum distance between the pivot and any data_ element in the i-th child node of this node's parent.
Referenced by fcl::NearestNeighborsGNAT< _T >::Node::nearestK(), fcl::NearestNeighborsGNAT< _T >::Node::nearestR(), and fcl::NearestNeighborsGNAT< _T >::Node::updateRange().
double fcl::NearestNeighborsGNAT< _T >::Node::minRadius_ |
Minimum distance between the pivot element and the elements stored in data_.
Referenced by fcl::NearestNeighborsGNAT< _T >::Node::nearestK(), fcl::NearestNeighborsGNAT< _T >::Node::nearestR(), fcl::NearestNeighborsGNAT< _T >::Node::split(), and fcl::NearestNeighborsGNAT< _T >::Node::updateRadius().
std::vector<double> fcl::NearestNeighborsGNAT< _T >::Node::minRange_ |
The i-th element in minRange_ is the minimum distance between the pivot and any data_ element in the i-th child node of this node's parent.
Referenced by fcl::NearestNeighborsGNAT< _T >::Node::nearestK(), fcl::NearestNeighborsGNAT< _T >::Node::nearestR(), and fcl::NearestNeighborsGNAT< _T >::Node::updateRange().
const _T fcl::NearestNeighborsGNAT< _T >::Node::pivot_ |
Data element stored in this Node.
Referenced by fcl::NearestNeighborsGNAT< _T >::Node::add(), fcl::NearestNeighborsGNAT< _T >::Node::list(), fcl::NearestNeighborsGNAT< _T >::Node::nearestK(), fcl::NearestNeighborsGNAT< _T >::nearestKInternal(), fcl::NearestNeighborsGNAT< _T >::Node::nearestR(), and fcl::NearestNeighborsGNAT< _T >::nearestRInternal().