33 #ifndef __H__UG__ntree__
34 #define __H__UG__ntree__
47 template <
int tree_dim,
int world_dim,
class elem_t,
class common_data_t>
55 const common_data_t& commonData);
58 const common_data_t& commonData);
83 const common_data_t& commonData);
161 template <
int tree_dim,
int world_dim,
class TElem,
class TCommonData>
242 size_t level(
size_t nodeId)
const;
253 template <
size_t n,
size_t exponent>
257 struct pow<n, 0> {
static const size_t val = 1;};
259 template <
size_t n,
size_t exponent>
this iterator is used by the ntree class to provide access to the elements of a given node
Definition: ntree_iterator.h:43
The n-tree class can be used to construct space partitioning trees of dimensions 1,...
Definition: ntree.h:163
static const size_t s_invalidIndex
marks an index as invalid
Definition: ntree.h:266
std::vector< Entry > m_entries
Definition: ntree.h:335
void add_entry_to_node(Node &node, size_t entryInd)
adds an entry to the given node
Definition: ntree_impl.hpp:297
traits::vector_t vector_t
Definition: ntree.h:172
size_t num_elements(size_t nodeId) const
returns the number of elements that the given node contains
Definition: ntree_impl.hpp:417
size_t num_delayed_elements() const
returns the number of elements which have been added but are not yet accessible in the tree.
Definition: ntree_impl.hpp:116
void add_element(const elem_t &elem)
adds an element to the tree.
Definition: ntree_impl.hpp:124
elem_iterator_t elems_end(size_t nodeId) const
returns an iterator to the end of the element-sequence of a given node
Definition: ntree_impl.hpp:409
void enable_warnings(bool enable)
enabled or disable warning messages
Definition: ntree.h:183
void clear()
Definition: ntree_impl.hpp:62
const NTreeDesc & desc() const
returns the balancing-parameters of the tree.
Definition: ntree_impl.hpp:79
void split_leaf_node(size_t nodeIndex)
splits a node into 2^tree_dim child nodes and assigns entries to those children.
Definition: ntree_impl.hpp:188
size_t num_child_nodes(size_t nodeId) const
returns the number of children of a node
Definition: ntree_impl.hpp:376
size_t num_nodes() const
returns the total number of nodes in the tree
Definition: ntree_impl.hpp:368
size_t size() const
returns the number of entries in the tree (delayed entries excluded)
Definition: ntree_impl.hpp:108
bool m_warningsEnabled
Definition: ntree.h:337
NTreeDesc m_desc
Definition: ntree.h:332
ntree_traits< tree_dim, world_dim, elem_t, common_data_t > traits
Definition: ntree.h:170
bool warnings_enabled() const
Definition: ntree.h:184
void clear_nodes()
clear only the nodes
Definition: ntree_impl.hpp:52
TCommonData common_data_t
Definition: ntree.h:169
TElem elem_t
Definition: ntree.h:165
bool empty() const
returns true if the tree is empty
Definition: ntree_impl.hpp:100
common_data_t m_commonData
Definition: ntree.h:333
ntree()
Definition: ntree_impl.hpp:43
vector_t calculate_center_of_mass(Node &node)
calculates the center of mass of a given node
Definition: ntree_impl.hpp:345
const box_t & bounding_box(size_t nodeId) const
returns the smallest box which contains all elements of the given node
Definition: ntree_impl.hpp:434
void rebalance()
rebalances the whole tree
Definition: ntree_impl.hpp:161
const common_data_t & common_data() const
returns the common-data stored in the tree
Definition: ntree_impl.hpp:93
size_t level(size_t nodeId) const
returns the number tree-level in which the node is located
Definition: ntree_impl.hpp:425
size_t find_leaf_node(const vector_t &point, size_t curNode=0)
returns an index to the leaf-node which contains the given point
Definition: ntree_impl.hpp:276
size_t m_numDelayedElements
Definition: ntree.h:336
void update_loose_bounding_box(Node &node)
updates the loose bounding box of the given node
Definition: ntree_impl.hpp:315
static const size_t s_numChildren
the number of children each non-leaf node has
Definition: ntree.h:263
const_ntree_element_iterator< elem_t, Entry > elem_iterator_t
Definition: ntree.h:174
traits::box_t box_t
Definition: ntree.h:173
void set_desc(const NTreeDesc &desc)
sets the balancing-parameters of the tree.
Definition: ntree_impl.hpp:72
elem_iterator_t elems_begin(size_t nodeId) const
returns an iterator to the first element of a given node
Definition: ntree_impl.hpp:397
void set_common_data(const common_data_t &commonData)
sets the common-data which the tree passes on to callback methods
Definition: ntree_impl.hpp:86
const size_t * child_node_ids(size_t nodeId) const
returns an array of child-id's for the given node
Definition: ntree_impl.hpp:387
traits::real_t real_t
Definition: ntree.h:171
std::vector< Node > m_nodes
m_nodes[0] is always considered to be the root node.
Definition: ntree.h:334
size_t maxDepth
Definition: ntree.h:101
NTreeDesc()
Definition: ntree.h:105
size_t splitThreshold
Definition: ntree.h:102
An Entry combines an element with the index to the next entry in a leaf-node's entry list.
Definition: ntree.h:273
Entry(const elem_t &e)
Definition: ntree.h:279
elem_t elem
Definition: ntree.h:274
size_t nextEntryInd
Definition: ntree.h:277
size_t numEntries
number of entries in the node
Definition: ntree.h:290
Node(const Node &n)
Definition: ntree.h:303
size_t lastEntryInd
index into m_entries. s_invalidIndex: no entry
Definition: ntree.h:289
box_t tightBox
tight bounding box - disjunct partition of the root box
Definition: ntree.h:292
box_t looseBox
loose bounding box - contains all bounding boxes of its entries
Definition: ntree.h:293
Node()
Definition: ntree.h:295
size_t firstEntryInd
< index into m_nodes. s_invalidIndex: no child node.
Definition: ntree.h:288
size_t level
Definition: ntree.h:291
size_t childNodeInd[s_numChildren]
Definition: ntree.h:287
static template implementation to raise n to the power exponent
Definition: ntree.h:260
static const size_t val
Definition: ntree.h:260
static void calculate_bounding_box(box_t &boxOut, const elem_t &e, const common_data_t &commonData)
static void calculate_center(vector_t ¢erOut, const elem_t &e, const common_data_t &commonData)
static bool box_box_intersection(const box_t &box1, const box_t &box2)
returns true if the given boxes intersect
static void merge_boxes(box_t &boxOut, const box_t &box1, const box_t &box2)
returns the smallest box that contains both box1 and box2
static bool box_contains_point(const box_t &box, const vector_t &point)
int real_t
Definition: ntree.h:50
static vector_t box_diagonal(const box_t &box)
int vector_t
Definition: ntree.h:51
int box_t
Definition: ntree.h:52
static void split_box(box_t *boxesOut, const box_t &box, const vector_t &splitPoint)
splits the given box into (2^tree_dim sub-boxes).
static void grow_box(box_t &boxOut, const box_t &box, const vector_t &offset)
adds the given offset to box.max and subtracts it from box.min
static bool contains_point(const elem_t &e, const vector_t &point, const common_data_t &commonData)