cheshirekow  v0.1.0
mpblocks::kd_tree::Node< Traits > Class Template Reference

Base class for nodes in the kd tree. More...

#include <mpblocks/kd_tree/Node.h>

Inheritance diagram for mpblocks::kd_tree::Node< Traits >:
mpblocks::dubins::kd_tree::Traits< Format >::Node mpblocks::kd_tree::Traits::Node

Public Types

typedef Traits::Format_t Format_t
 
typedef Traits::HyperRect HyperRect_t
 
typedef NearestSearchIface
< Traits
NNIface_t
 
typedef Traits::Node Node_t
 
typedef ListPair< TraitsPair_t
 
typedef Vector_t Point_t
 
typedef RangeSearchIface< TraitsRangeIface_t
 
typedef Node< TraitsThis_t
 
typedef Eigen::Matrix
< Format_t, Traits::NDim, 1 > 
Vector_t
 

Public Member Functions

void construct (Node_t *parent, unsigned int i)
 construct a new node More...
 
template<typename BackInserter >
void enumerate (HyperRect_t &container, BackInserter bs)
 
void findNearest (const Point_t &q, HyperRect_t &rect, NNIface_t &search)
 perform a generic Nearest Neighbor query, different queries provide different implementations of the search structure More...
 
void findRange (RangeIface_t &search, HyperRect_t &rect)
 find all nodes in the tree that lie inside the specified range ( can be arbitrary volume, which is implemented by the deriving class of the interface ) More...
 
Node_tgetParent ()
 return the parent node More...
 
const Point_tgetPoint ()
 returns a Point_t of the point stored at this node More...
 
void insert (Node_t *)
 recursively inserts point as a new node in the tree More...
 
 Node ()
 does nothing, see construct More...
 
void setPoint (const Point_t &p)
 fill point data (convenience method) More...
 

Protected Attributes

Node_tm_greaterChild
 child node who's i'th value is larger More...
 
unsigned int m_i
 dimension that this node splits on, also index of hyperplane's constant component More...
 
Node_tm_parent
 parent node More...
 
Point_t m_point
 the point that this node contains More...
 
Node_tm_smallerChild
 child node who's i'th value is smaller More...
 
Node_tm_this
 

Detailed Description

template<class Traits>
class mpblocks::kd_tree::Node< Traits >

Base class for nodes in the kd tree.

The Node data structure carries all the information that is actually required by the kd tree structure, including ancestry pointers and the point value for this node.

As a kind of design anomoly, the kd-tree employs the Curiously Recuring Template Pattern in the following way: the actual node type is expected to derive from Node<Traits>. Traits should contain a type Node which is the actual node type. Thus Node should be an inner class of Traits. Because kd_tree::Node<Traits> is a base class of the actual Node type we can cast it and use it as a kd_tree::Node<Traits> when working in the kd tree, but you can define the node structure to have all the extra information and methods you want.

The reason for this is that in applications the Node type really needs to have some sophisticated features. However, we need to ensure that it provides the proper interface and data storage to work inside the kd tree. It was easier to get things working if the Node knew its derived type, so that it can construct nodes and things.

No, I do not think this is good design... But it works.

Definition at line 58 of file Node.h.

Member Typedef Documentation

template<class Traits>
typedef Traits::Format_t mpblocks::kd_tree::Node< Traits >::Format_t

Definition at line 63 of file Node.h.

template<class Traits>
typedef Traits::HyperRect mpblocks::kd_tree::Node< Traits >::HyperRect_t

Definition at line 65 of file Node.h.

template<class Traits>
typedef NearestSearchIface<Traits> mpblocks::kd_tree::Node< Traits >::NNIface_t

Definition at line 74 of file Node.h.

template<class Traits>
typedef Traits::Node mpblocks::kd_tree::Node< Traits >::Node_t

Definition at line 64 of file Node.h.

template<class Traits>
typedef ListPair<Traits> mpblocks::kd_tree::Node< Traits >::Pair_t

Definition at line 72 of file Node.h.

template<class Traits>
typedef Vector_t mpblocks::kd_tree::Node< Traits >::Point_t

Definition at line 69 of file Node.h.

template<class Traits>
typedef RangeSearchIface<Traits> mpblocks::kd_tree::Node< Traits >::RangeIface_t

Definition at line 75 of file Node.h.

template<class Traits>
typedef Node<Traits> mpblocks::kd_tree::Node< Traits >::This_t

Definition at line 71 of file Node.h.

template<class Traits>
typedef Eigen::Matrix<Format_t,Traits::NDim,1> mpblocks::kd_tree::Node< Traits >::Vector_t

Definition at line 68 of file Node.h.

Constructor & Destructor Documentation

template<class Traits >
mpblocks::kd_tree::Node< Traits >::Node ( )

does nothing, see construct

Definition at line 38 of file Node.hpp.

Member Function Documentation

template<class Traits >
void mpblocks::kd_tree::Node< Traits >::construct ( Node_t parent,
unsigned int  i 
)

construct a new node

Parameters
[in]parentthe parent node of this node (0 for root node)
[in]ithe index of the dimensions on which this node splits the space

Definition at line 47 of file Node.hpp.

template<class Traits >
template<typename BackInserter >
void mpblocks::kd_tree::Node< Traits >::enumerate ( HyperRect_t container,
BackInserter  bs 
)

Definition at line 226 of file Node.hpp.

template<class Traits >
void mpblocks::kd_tree::Node< Traits >::findNearest ( const Point_t q,
HyperRect_t rect,
NNIface_t search 
)

perform a generic Nearest Neighbor query, different queries provide different implementations of the search structure

Parameters
qquery point for search
recthyper rectangle containing this node
searchimplementation of search

Definition at line 99 of file Node.hpp.

template<class Traits >
void mpblocks::kd_tree::Node< Traits >::findRange ( RangeIface_t search,
HyperRect_t rect 
)

find all nodes in the tree that lie inside the specified range ( can be arbitrary volume, which is implemented by the deriving class of the interface )

Definition at line 177 of file Node.hpp.

template<class Traits>
Node_t* mpblocks::kd_tree::Node< Traits >::getParent ( )
inline

return the parent node

Definition at line 105 of file Node.h.

template<class Traits >
const Node< Traits >::Point_t & mpblocks::kd_tree::Node< Traits >::getPoint ( )

returns a Point_t of the point stored at this node

Definition at line 65 of file Node.hpp.

template<class Traits >
void mpblocks::kd_tree::Node< Traits >::insert ( Node_t node)

recursively inserts point as a new node in the tree

Definition at line 71 of file Node.hpp.

template<class Traits >
void mpblocks::kd_tree::Node< Traits >::setPoint ( const Point_t p)

fill point data (convenience method)

Definition at line 58 of file Node.hpp.

Member Data Documentation

template<class Traits>
Node_t* mpblocks::kd_tree::Node< Traits >::m_greaterChild
protected

child node who's i'th value is larger

Definition at line 83 of file Node.h.

template<class Traits>
unsigned int mpblocks::kd_tree::Node< Traits >::m_i
protected

dimension that this node splits on, also index of hyperplane's constant component

Definition at line 78 of file Node.h.

template<class Traits>
Node_t* mpblocks::kd_tree::Node< Traits >::m_parent
protected

parent node

Definition at line 81 of file Node.h.

template<class Traits>
Point_t mpblocks::kd_tree::Node< Traits >::m_point
protected

the point that this node contains

Definition at line 80 of file Node.h.

template<class Traits>
Node_t* mpblocks::kd_tree::Node< Traits >::m_smallerChild
protected

child node who's i'th value is smaller

Definition at line 82 of file Node.h.

template<class Traits>
Node_t* mpblocks::kd_tree::Node< Traits >::m_this
protected

Definition at line 84 of file Node.h.


The documentation for this class was generated from the following files: