34 #ifndef __H__UG__kd_tree__
35 #define __H__UG__kd_tree__
59 template <
class po
int_t,
class data_t,
class real_t =
float>
98 void add_element(
const point_t& point,
const data_t& data,
bool delayInsertion =
false);
An Element represents a point with an associated data value.
Definition: kd_tree.h:64
int nextElemInd
Definition: kd_tree.h:73
point_t point
Definition: kd_tree.h:67
data_t data
Definition: kd_tree.h:68
size_t num_delayed_elements() const
returns the number of elements which are scheduled for delayed insertion
Element closest_element(const point_t &point) const
finds the closest tree-element to a given point in space
real_t estimate_balance_quality()
estimates the balance quality of the tree in the range [0, 1].
std::vector< Element > m_elements
Definition: kd_tree.h:144
void add_element(const point_t &point, const data_t &data, bool delayInsertion=false)
adds an element to the tree.
bool empty() const
returns true if the tree is empty
void rebalance()
rebalances the whole tree
size_t size() const
returns the number of elements in the tree
size_t m_numDelayedElements
Definition: kd_tree.h:145
KDTreeDesc m_desc
Definition: kd_tree.h:141
void closest_elements(vector< Element > &elemsOut, const point_t &point, size_t n) const
returns the n closest tree-elements to a given point in space
int find_leaf_node(const point_t &point)
returns an index to the leaf-node which contains the given point
std::vector< Node > m_nodes
m_nodes[0] is always considered to be the root node.
Definition: kd_tree.h:143
void set_desc(const KDTreeDesc &desc)
sets the balancing-parameters of the tree. Triggers a rebalance if a value changed.
void split_leaf_node(Node &node)
splits a node into two child nodes and assigns elements to those children.
KDTreeSplitStrategy
Definition: kd_tree.h:40
@ KDTSS_CIRCULAR
Definition: kd_tree.h:41
@ KDTSS_LARGEST
Definition: kd_tree.h:42
Definition: kd_tree.h:122
float splitValue
Definition: kd_tree.h:127
int firstElemInd
< index into m_nodes. -1: no child node.
Definition: kd_tree.h:124
int numElements
number of elements in the node
Definition: kd_tree.h:126
int childNodeInds[2]
Definition: kd_tree.h:123
int splitDim
Definition: kd_tree.h:128
int lastElemInd
index into m_elements. -1: no element
Definition: kd_tree.h:125
int splitThreshold
Definition: kd_tree.h:53
KDTreeSplitStrategy strategy
Definition: kd_tree.h:54
KDTreeDesc(int nDim, int nSplitThreshold, KDTreeSplitStrategy nStrategy)
Definition: kd_tree.h:47
int dim
Definition: kd_tree.h:52
KDTreeDesc()
Definition: kd_tree.h:46