last update 20 Sep 2009 |
#include <cvrKdTree.h>
Public Types | |
typedef std::vector< element * > | points_type |
Public Member Functions | |
node () | |
node (const node &other) | |
~node () | |
void | add (element *f) |
bool | isLeaf () const |
const std::string & | name () const |
kdTree< T, D, U >::node & | copy (const node &other) |
kdTree< T, D, U >::node & | operator= (const node &other) |
kdTree< T, D, U >::node * | clone () const |
kdTree< T, D, U >::node * | newInstance () const |
virtual bool | read (ioHandler &handler, const bool complete=true) |
virtual bool | write (ioHandler &handler, const bool complete=true) const |
Public Attributes | |
Attributes | |
points_type | points |
node * | left |
node * | right |
int | splitDim |
value_type | partition |
Protected Member Functions | |
void | clearPoints () |
void | subdivide (const int maxCount, int &levels, int &leaves) |
int | getDimWithHighestVariance () const |
value_type | getMedianVal (const int searchDim) const |
bool | getPoint (const T &key, element &elem) const |
bool | getPoint (const T &key, std::list< element > &elems) const |
void | add (std::list< element * > &pts) |
Implementation must be here due to MS VC++ bug
typedef std::vector<element*> cvr::kdTree< T, D, U >::kdTree::node::points_type |
type used for the container of elements.
A std::vector is for the search much more appropriate because the access through iterators is about a factor 5 faster than the std::list type.
cvr::kdTree< T, D, U >::kdTree::node::node | ( | ) |
constructor
cvr::kdTree< T, D, U >::kdTree::node::node | ( | const node & | other | ) |
copy constructor.
Makes a deep copy, i.e. the pointers will be different
cvr::kdTree< T, D, U >::kdTree::node::~node | ( | ) |
destructor
void cvr::kdTree< T, D, U >::kdTree::node::add | ( | std::list< element * > & | pts | ) | [inline, protected] |
void cvr::kdTree< T, D, U >::kdTree::node::add | ( | element * | f | ) | [inline] |
void cvr::kdTree< T, D, U >::kdTree::node::clearPoints | ( | ) | [inline, protected] |
deep clear points
kdTree<T,D,U>::node* cvr::kdTree< T, D, U >::kdTree::node::clone | ( | ) | const [virtual] |
kdTree<T,D,U>::node& cvr::kdTree< T, D, U >::kdTree::node::copy | ( | const node & | other | ) |
copy method
int cvr::kdTree< T, D, U >::kdTree::node::getDimWithHighestVariance | ( | ) | const [protected] |
get the dimension of the data with the highest variance.
We assume the whole data set to be considered is located at the points vector.
value_type cvr::kdTree< T, D, U >::kdTree::node::getMedianVal | ( | const int | searchDim | ) | const [inline, protected] |
get the median value at the given search dimension
searchDim | search dimension |
bool cvr::kdTree< T, D, U >::kdTree::node::getPoint | ( | const T & | key, | |
std::list< element > & | elems | |||
) | const [inline, protected] |
search for exactly the given key in the list of elements.
If found, return true, otherwise return false and leave the element instance untouched.
For floating types this method usually returns false, because the exact match of the key is very unprobable. This method is therefore used mostly for integer value_types
bool cvr::kdTree< T, D, U >::kdTree::node::getPoint | ( | const T & | key, | |
element & | elem | |||
) | const [inline, protected] |
search for exactly the given key in the list of elements.
If found, return true, otherwise return false and leave the element instance untouched.
For floating types this method usually returns false, because the exact match of the key is very unprobable. This method is therefore used mostly for integer value_types
bool cvr::kdTree< T, D, U >::kdTree::node::isLeaf | ( | ) | const [inline] |
return true if this node is a leaf.
const std::string& cvr::kdTree< T, D, U >::kdTree::node::name | ( | ) | const [virtual] |
kdTree<T,D,U>::node* cvr::kdTree< T, D, U >::kdTree::node::newInstance | ( | ) | const [virtual] |
kdTree<T,D,U>::node& cvr::kdTree< T, D, U >::kdTree::node::operator= | ( | const node & | other | ) | [inline] |
alias for copy method
virtual bool cvr::kdTree< T, D, U >::kdTree::node::read | ( | ioHandler & | handler, | |
const bool | complete = true | |||
) | [virtual] |
read the node from the given ioHandler
handler | the ioHandler to be used | |
complete | if true (the default) the enclosing begin/end will be also read, otherwise only the data block will be read. |
Reimplemented from cvr::ioObject.
void cvr::kdTree< T, D, U >::kdTree::node::subdivide | ( | const int | maxCount, | |
int & | levels, | |||
int & | leaves | |||
) | [protected] |
split the data stored at this node considering the axis with the highest variance.
maxCount | maximum bucket size (how many elements are allowed to be in a leaf node) | |
levels | number of levels required until now for this tree. | |
leaves | at the end this variable (which should be initialized with zero externally) contains the number of leaves in the tree |
virtual bool cvr::kdTree< T, D, U >::kdTree::node::write | ( | ioHandler & | handler, | |
const bool | complete = true | |||
) | const [virtual] |
write the node to the given ioHandler
handler | the ioHandler to be used | |
complete | if true (the default) the enclosing begin/end will be also written, otherwise only the data block will be written. |
Reimplemented from cvr::ioObject.
node* cvr::kdTree< T, D, U >::kdTree::node::left |
the left subtree (lower coordinate) from the split plane
value_type cvr::kdTree< T, D, U >::kdTree::node::partition |
Value at the split dimension where the splitting takes place.
Usually this value corresponds to the median at the given split dimension.
points_type cvr::kdTree< T, D, U >::kdTree::node::points |
node* cvr::kdTree< T, D, U >::kdTree::node::right |
the right subtree (higher coordinate) from the split plane
int cvr::kdTree< T, D, U >::kdTree::node::splitDim |
the dimension in which the subnodes are split.
This is called in the original paper "discriminator"