33 #ifndef __H__UG__ntree_traverser__
34 #define __H__UG__ntree_traverser__
43 template <
class tree_t>
57 if(tree.num_child_nodes(node) == 0){
74 template <
class tree_t>
84 template <
class tree_t>
101 if(tree.level(node) ==
m_lvl)
104 if(tree.level(node) >=
m_lvl)
112 if(tree.level(node) ==
m_lvl){
137 template <
class tree_t>
146 template <
class tree_t>
168 if(!tree_t::traits::box_contains_point(tree.bounding_box(node),
m_point))
172 if(tree.num_child_nodes(node) == 0){
175 for(
typename tree_t::elem_iterator_t iter = tree.elems_begin(node);
176 iter != tree.elems_end(node); ++iter)
179 if(tree_t::traits::contains_point(*iter,
m_point, tree.common_data())){
209 template <
class tree_t>
211 const typename tree_t::vector_t& point)
216 typename tree_t::elem_t tmpElem;
225 template <
class tree_t>
231 typedef typename tree_t::box_t
box_t;
246 if(!tree_t::traits::box_box_intersection(tree.bounding_box(node),
m_bbox))
250 if(tree.num_child_nodes(node) == 0){
253 for(
typename tree_t::elem_iterator_t iter = tree.elems_begin(node);
254 iter != tree.elems_end(node); ++iter)
273 template <
class tree_t>
276 const typename tree_t::box_t& bbox)
282 return !elemsOut.empty();
308 template <
class TElem>
320 template <
class tree_t>
326 typedef typename tree_t::box_t
box_t;
331 const number small = 1.e-12) :
344 box_t box = tree.bounding_box(node);
348 tree_t::traits::grow_box(box, box, vsmall);
353 if(tree.num_child_nodes(node) == 0){
357 number smin = 0, smax = 0;
358 for(
typename tree_t::elem_iterator_t iter = tree.elems_begin(node);
359 iter != tree.elems_end(node); ++iter)
361 if(tree_t::traits::intersects_ray(
385 template <
class tree_t>
389 const typename tree_t::vector_t& rayFrom,
390 const typename tree_t::vector_t& rayDir,
391 const number small = 1.e-12)
396 intersectionsOut = trav.
result();
397 return !intersectionsOut.empty();
Definition: ntree_traverser.h:148
tree_t::vector_t vector_t
Definition: ntree_traverser.h:151
void visit_down(const tree_t &, size_t)
Definition: ntree_traverser.h:189
void end_traversal(const tree_t &)
Definition: ntree_traverser.h:191
size_t m_numElemsChecked
Definition: ntree_traverser.h:205
tree_t::elem_t elem_t
Definition: ntree_traverser.h:150
int visit_up(const tree_t &tree, size_t node)
Definition: ntree_traverser.h:164
Traverser_FindContainingElement(const vector_t &point)
Definition: ntree_traverser.h:153
elem_t m_elem
Definition: ntree_traverser.h:204
void begin_traversal(const tree_t &tree)
Definition: ntree_traverser.h:158
bool result(elem_t &foundElemOut) const
Definition: ntree_traverser.h:193
vector_t m_point
Definition: ntree_traverser.h:203
bool m_foundElem
Definition: ntree_traverser.h:206
size_t num_elems_checked() const
Definition: ntree_traverser.h:200
Definition: ntree_traverser.h:227
void end_traversal(const tree_t &)
Definition: ntree_traverser.h:264
const std::vector< elem_t > & result() const
Definition: ntree_traverser.h:266
tree_t::box_t box_t
Definition: ntree_traverser.h:231
void begin_traversal(const tree_t &tree)
Definition: ntree_traverser.h:237
tree_t::elem_t elem_t
Definition: ntree_traverser.h:229
Traverser_FindElementsInIntersectingNodes(const box_t &bbox)
Definition: ntree_traverser.h:233
std::vector< elem_t > m_foundElems
Definition: ntree_traverser.h:270
int visit_up(const tree_t &tree, size_t node)
Definition: ntree_traverser.h:242
box_t m_bbox
Definition: ntree_traverser.h:269
void visit_down(const tree_t &, size_t)
Definition: ntree_traverser.h:262
tree_t::vector_t vector_t
Definition: ntree_traverser.h:230
Definition: ntree_traverser.h:45
Traverser_FindLowestLeafNodeLevel()
Definition: ntree_traverser.h:47
void visit_down(const tree_t &, size_t)
Definition: ntree_traverser.h:64
int visit_up(const tree_t &tree, size_t node)
Definition: ntree_traverser.h:55
size_t m_lowestLeafNodeLvl
Definition: ntree_traverser.h:71
void end_traversal(const tree_t &)
Definition: ntree_traverser.h:66
void begin_traversal(const tree_t &tree)
Definition: ntree_traverser.h:50
size_t result() const
Definition: ntree_traverser.h:68
returns the minimum and maximum number of elements in all subtrees of nodes of the given level
Definition: ntree_traverser.h:86
size_t max_num_elements() const
Definition: ntree_traverser.h:127
size_t m_maxNumElements
Definition: ntree_traverser.h:132
size_t m_elemCount
Definition: ntree_traverser.h:133
bool m_firstEval
Definition: ntree_traverser.h:134
size_t m_minNumElements
Definition: ntree_traverser.h:131
void visit_down(const tree_t &tree, size_t node)
Definition: ntree_traverser.h:110
size_t m_lvl
Definition: ntree_traverser.h:130
int visit_up(const tree_t &tree, size_t node)
Definition: ntree_traverser.h:99
void end_traversal(const tree_t &)
Definition: ntree_traverser.h:124
size_t min_num_elements() const
Definition: ntree_traverser.h:126
void begin_traversal(const tree_t &tree)
Definition: ntree_traverser.h:92
Traverser_MinMaxNumElements(size_t lvl)
Definition: ntree_traverser.h:88
Definition: ntree_traverser.h:322
Traverser_RayElementIntersection(const vector_t &rayFrom, const vector_t rayDir, const number small=1.e-12)
Definition: ntree_traverser.h:329
tree_t::box_t box_t
Definition: ntree_traverser.h:326
RayElemIntersectionRecord< elem_t > intersection_record_t
Definition: ntree_traverser.h:327
vector_t m_rayFrom
Definition: ntree_traverser.h:379
tree_t::elem_t elem_t
Definition: ntree_traverser.h:324
const std::vector< intersection_record_t > & result() const
Definition: ntree_traverser.h:376
tree_t::vector_t vector_t
Definition: ntree_traverser.h:325
void end_traversal(const tree_t &)
Definition: ntree_traverser.h:374
std::vector< intersection_record_t > m_intersections
Definition: ntree_traverser.h:382
void visit_down(const tree_t &, size_t)
Definition: ntree_traverser.h:372
const number m_small
Definition: ntree_traverser.h:381
int visit_up(const tree_t &tree, size_t node)
Definition: ntree_traverser.h:342
void begin_traversal(const tree_t &tree)
Definition: ntree_traverser.h:337
vector_t m_rayDir
Definition: ntree_traverser.h:380
double number
Definition: types.h:124
vector_t::value_type VecLength(const vector_t &v)
returns the length of v. Slower than VecLengthSq.
Definition: math_vector_functions_common_impl.hpp:341
void VecSet(vector_t &vInOut, typename vector_t::value_type s)
Set each vector component to scalar (componentwise)
Definition: math_vector_functions_common_impl.hpp:539
void VecScale(vector_t &vOut, const vector_t &v, typename vector_t::value_type s)
scales a MathVector<N>
Definition: math_vector_functions_common_impl.hpp:252
size_t FindLowestLeafNodeLevel(const tree_t &tree)
Definition: ntree_traverser.h:75
bool FindElementsInIntersectingNodes(std::vector< typename tree_t::elem_t > &elemsOut, const tree_t &tree, const typename tree_t::box_t &bbox)
Definition: ntree_traverser.h:274
bool RayElementIntersections(std::vector< RayElemIntersectionRecord< typename tree_t::elem_t > > &intersectionsOut, const tree_t &tree, const typename tree_t::vector_t &rayFrom, const typename tree_t::vector_t &rayDir, const number small=1.e-12)
Definition: ntree_traverser.h:386
@ ABORT_TRAVERSAL
Definition: ntree_traversal.h:41
@ DONT_TRAVERSE_CHILDREN
Definition: ntree_traversal.h:39
@ TRAVERSE_CHILDREN
Definition: ntree_traversal.h:40
void TraverseDepthFirst(const tree_t &tree, traverser_t &traverser)
Definition: ntree_traversal.h:107
bool FindContainingElement(typename tree_t::elem_t &elemOut, const tree_t &tree, const typename tree_t::vector_t &point)
Definition: ntree_traverser.h:210
std::pair< size_t, size_t > GetMinMaxNumElements(const tree_t &tree, size_t lvl)
Definition: ntree_traverser.h:138
void TraverseBreadthFirst(const tree_t &tree, traverser_t &traverser)
Definition: ntree_traversal.h:45
Definition: ntree_traverser.h:310
number smin
relative coordinate where the ray enters the element
Definition: ntree_traverser.h:315
RayElemIntersectionRecord(number _smin, number _smax, TElem _elem)
Definition: ntree_traverser.h:312
TElem elem
the element that was intersected
Definition: ntree_traverser.h:317
number smax
relative coordinate where the ray leaves the element. May be equal to smin.
Definition: ntree_traverser.h:316
RayElemIntersectionRecord()
Definition: ntree_traverser.h:311