Image Component Library (ICL)
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
icl::math::KDTree Class Reference

Simple KD-Tree implementation. More...

#include <KDTree.h>

Inheritance diagram for icl::math::KDTree:
icl::utils::Uncopyable

Classes

struct  Node
 Keeps data of node. More...
 

Public Member Functions

 KDTree (std::vector< math::DynMatrix< icl64f > > &list)
 Constructor. More...
 
 KDTree (std::vector< math::DynMatrix< icl64f > * > &list)
 Constructor. More...
 
 KDTree ()
 Constructor. More...
 
 ~KDTree ()
 Destructor. More...
 
void buildTree (std::vector< math::DynMatrix< icl64f > * > &list)
 builds a kd-tree More...
 
void buildTree (std::vector< math::DynMatrix< icl64f > > &list)
 builds a kd-tree More...
 
void print ()
 Prints the tree on standard output. More...
 
math::DynMatrix< icl64f > * nearestNeighbour (const math::DynMatrix< icl64f > &point)
 Returns pointer to nearest neighbour to passed point. More...
 
math::DynMatrix< icl64f > * nearestNeighbour (const math::DynMatrix< icl64f > *point)
 Returns pointer to nearest neighbour to passed point. More...
 

Private Member Functions

void print (Node *node)
 internal print call More...
 
void buildTree (std::vector< math::DynMatrix< icl64f > > &list, unsigned int depth, Node *node)
 internal call to fill the KDTree with data More...
 
void buildTree (std::vector< math::DynMatrix< icl64f > * > &list, unsigned int depth, Node *node)
 internal call to fill the KDTree with data More...
 
void sortList (std::vector< math::DynMatrix< icl64f > > &list, unsigned int dim)
 internal call to sort list by dimension of the vector (unused, instead std::sort) More...
 
void sortList (std::vector< math::DynMatrix< icl64f > * > &list, unsigned int dim)
 internal call to sort list by dimension of the vector (unused, instead std::sort) More...
 
void releaseTree ()
 internal call to release data from KDTree More...
 

Private Attributes

Node root
 the root node of the tree More...
 

Additional Inherited Members

- Protected Member Functions inherited from icl::utils::Uncopyable
 Uncopyable ()
 Empty base constructor. More...
 

Detailed Description

Simple KD-Tree implementation.

This class implements a simple kd-tree. You can create an object of this class with or without given point data. After creating a kd-tree without data you can use the buildTree method to insert data points or to rebuild the kd-tree with new data points. Note: If point data was passed to the KD-Tree constructor, it only references by the KD-Tree instance. Therefore, that tree instance will only stay valid as long as the referenced data does

Constructor & Destructor Documentation

◆ KDTree() [1/3]

icl::math::KDTree::KDTree ( std::vector< math::DynMatrix< icl64f > > &  list)

Constructor.

Creates a new KDTree object, with data from list.

Parameters
listlist of points for the kd-tree

◆ KDTree() [2/3]

icl::math::KDTree::KDTree ( std::vector< math::DynMatrix< icl64f > * > &  list)

Constructor.

Creates a new KDTree object, with data from list.

Parameters
listlist of points for the kd-tree

◆ KDTree() [3/3]

icl::math::KDTree::KDTree ( )
inline

Constructor.

Creates a new KDTree object. Default constructor

◆ ~KDTree()

icl::math::KDTree::~KDTree ( )

Destructor.

Member Function Documentation

◆ buildTree() [1/4]

void icl::math::KDTree::buildTree ( std::vector< math::DynMatrix< icl64f > > &  list,
unsigned int  depth,
Node node 
)
private

internal call to fill the KDTree with data

◆ buildTree() [2/4]

void icl::math::KDTree::buildTree ( std::vector< math::DynMatrix< icl64f > * > &  list,
unsigned int  depth,
Node node 
)
private

internal call to fill the KDTree with data

◆ buildTree() [3/4]

void icl::math::KDTree::buildTree ( std::vector< math::DynMatrix< icl64f > * > &  list)
inline

builds a kd-tree

Fills empty kd-tree or the current one with new data.

Parameters
listlist of points for the kd-tree

◆ buildTree() [4/4]

void icl::math::KDTree::buildTree ( std::vector< math::DynMatrix< icl64f > > &  list)
inline

builds a kd-tree

Fills empty KDTree object or the current one with new data.

Parameters
listlist of points for the kd-tree

◆ nearestNeighbour() [1/2]

math::DynMatrix<icl64f>* icl::math::KDTree::nearestNeighbour ( const math::DynMatrix< icl64f > &  point)

Returns pointer to nearest neighbour to passed point.

Parameters
pointthe point to search nearest neighbor for
Returns
the pointer to nearest neighbour

◆ nearestNeighbour() [2/2]

math::DynMatrix<icl64f>* icl::math::KDTree::nearestNeighbour ( const math::DynMatrix< icl64f > *  point)

Returns pointer to nearest neighbour to passed point.

Parameters
pointthe point to search nearest neighbor for
Returns
the pointer to nearest neighbour

◆ print() [1/2]

void icl::math::KDTree::print ( Node node)
private

internal print call

◆ print() [2/2]

void icl::math::KDTree::print ( )

Prints the tree on standard output.

◆ releaseTree()

void icl::math::KDTree::releaseTree ( )
private

internal call to release data from KDTree

◆ sortList() [1/2]

void icl::math::KDTree::sortList ( std::vector< math::DynMatrix< icl64f > > &  list,
unsigned int  dim 
)
private

internal call to sort list by dimension of the vector (unused, instead std::sort)

◆ sortList() [2/2]

void icl::math::KDTree::sortList ( std::vector< math::DynMatrix< icl64f > * > &  list,
unsigned int  dim 
)
private

internal call to sort list by dimension of the vector (unused, instead std::sort)

Member Data Documentation

◆ root

Node icl::math::KDTree::root
private

the root node of the tree


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