Iterate over leaves of an adaptive kD-tree. More...
#include <AdaptiveKDTree.hpp>
Classes | |
struct | StackObj |
Public Types | |
enum | Direction { LEFT = 0 , RIGHT = 1 } |
Public Member Functions | |
AdaptiveKDTreeIter () | |
ErrorCode | initialize (AdaptiveKDTree *tool, EntityHandle root, const double box_min[3], const double box_max[3], Direction direction) |
AdaptiveKDTree * | tool () const |
EntityHandle | handle () const |
Get handle for current leaf. More... | |
const double * | box_min () const |
Get min corner of axis-aligned box for current leaf. More... | |
const double * | box_max () const |
Get max corner of axis-aligned box for current leaf. More... | |
double | volume () const |
bool | intersects (const AdaptiveKDTree::Plane &plane) const |
test if a plane intersects the leaf box More... | |
unsigned | depth () const |
Get depth in tree. root is at depth of 1. More... | |
ErrorCode | step (Direction direction) |
Advance the iterator either left or right in the tree Note: stepping past the end of the tree will invalidate the iterator. It will not be work step the other direction. More... | |
ErrorCode | step () |
Advance to next leaf Returns MB_ENTITY_NOT_FOUND if at end. Note: steping past the end of the tree will invalidate the iterator. Calling back() will not work. More... | |
ErrorCode | back () |
Move back to previous leaf Returns MB_ENTITY_NOT_FOUND if at beginning. Note: steping past the start of the tree will invalidate the iterator. Calling step() will not work. More... | |
ErrorCode | sibling_side (AdaptiveKDTree::Axis &axis_out, bool &neg_out) const |
Return the side of the box bounding this tree node that is shared with the immediately adjacent sibling (the tree node that shares a common parent node with this node in the binary tree.) More... | |
ErrorCode | get_neighbors (AdaptiveKDTree::Axis norm, bool neg, std::vector< AdaptiveKDTreeIter > &results, double epsilon=0.0) const |
Get adjacent leaf nodes on side indicated by norm and neg. More... | |
ErrorCode | get_parent_split_plane (AdaptiveKDTree::Plane &plane) const |
Get split plane that separates this node from its immediate sibling. More... | |
bool | is_sibling (const AdaptiveKDTreeIter &other_leaf) const |
Return true if thos node and the passed node share the same immediate parent. More... | |
bool | is_sibling (EntityHandle other_leaf) const |
Return true if thos node and the passed node share the same immediate parent. More... | |
bool | sibling_is_forward () const |
Returns true if calling step() will advance to the immediate sibling of the current node. Returns false if current node is root or back() will move to the immediate sibling. More... | |
bool | intersect_ray (const double ray_point[3], const double ray_vect[3], double &t_enter, double &t_exit) const |
Find range of overlap between ray and leaf. More... | |
Private Types | |
enum | { BMIN = 0 , BMAX = 1 } |
Private Member Functions | |
ErrorCode | step_to_first_leaf (Direction direction) |
Descend tree to left most leaf from current position No-op if at leaf. More... | |
Private Attributes | |
CartVect | mBox [2] |
min and max corners of bounding box More... | |
AdaptiveKDTree * | treeTool |
tool for tree More... | |
std::vector< StackObj > | mStack |
stack storing path through tree More... | |
std::vector< EntityHandle > | childVect |
temporary storage of child handles More... | |
Friends | |
class | AdaptiveKDTree |
Iterate over leaves of an adaptive kD-tree.
Definition at line 342 of file AdaptiveKDTree.hpp.
|
private |
Enumerator | |
---|---|
BMIN | |
BMAX |
Definition at line 360 of file AdaptiveKDTree.hpp.
Enumerator | |
---|---|
LEFT | |
RIGHT |
Definition at line 345 of file AdaptiveKDTree.hpp.
|
inline |
Definition at line 378 of file AdaptiveKDTree.hpp.
|
inline |
Move back to previous leaf Returns MB_ENTITY_NOT_FOUND if at beginning. Note: steping past the start of the tree will invalidate the iterator. Calling step() will not work.
Definition at line 446 of file AdaptiveKDTree.hpp.
Referenced by get_neighbors().
|
inline |
Get max corner of axis-aligned box for current leaf.
Definition at line 404 of file AdaptiveKDTree.hpp.
References moab::CartVect::array(), BMAX, and mBox.
Referenced by moab::AdaptiveKDTree::best_subdivision_plane(), moab::AdaptiveKDTree::best_vertex_median_plane(), moab::AdaptiveKDTree::best_vertex_sample_plane(), intersect_ray(), and moab::AdaptiveKDTree::print().
|
inline |
Get min corner of axis-aligned box for current leaf.
Definition at line 398 of file AdaptiveKDTree.hpp.
References moab::CartVect::array(), BMIN, and mBox.
Referenced by moab::AdaptiveKDTree::best_subdivision_plane(), moab::AdaptiveKDTree::best_vertex_median_plane(), moab::AdaptiveKDTree::best_vertex_sample_plane(), intersect_ray(), and moab::AdaptiveKDTree::print().
|
inline |
Get depth in tree. root is at depth of 1.
Definition at line 422 of file AdaptiveKDTree.hpp.
References mStack.
Referenced by moab::AdaptiveKDTree::build_tree(), moab::AdaptiveKDTree::compute_depth(), moab::AdaptiveKDTree::merge_leaf(), and moab::AdaptiveKDTree::print().
ErrorCode moab::AdaptiveKDTreeIter::get_neighbors | ( | AdaptiveKDTree::Axis | norm, |
bool | neg, | ||
std::vector< AdaptiveKDTreeIter > & | results, | ||
double | epsilon = 0.0 |
||
) | const |
Get adjacent leaf nodes on side indicated by norm and neg.
E.g. if norm == X and neg == true, then get neighbor(s) adjacent to the side of the box contained in the plane with normal to the X axis and with the x coordinate equal to the minimum x of the bounding box.
E.g. if norm == Y and neg == false, then get neighbor(s) adjacent to the side of the box with y = maximum y of bounding box.
norm | Normal vector for box side (X, Y, or Z) |
neg | Which of two planes with norm (true->smaller coord, false->larger coord) |
results | List to which to append results. This function does not clear existing values in list. |
epsilon | Tolerance on overlap. A positive value E will result in nodes that are separated by as much as E to be considered touching. A negative value -E will cause leaves that do not overlap by at least E to be considered non-overlapping. Amongst other things, this value can be used to control whether or not leaves adjacent at only their edges or corners are returned. |
Definition at line 578 of file AdaptiveKDTree.cpp.
References back(), BMAX, BMIN, childVect, moab::AdaptiveKDTree::Plane::coord, moab::AdaptiveKDTreeIter::StackObj::coord, moab::AdaptiveKDTreeIter::StackObj::entity, ErrorCode, moab::Interface::get_child_meshsets(), moab::AdaptiveKDTree::get_split_plane(), MB_SUCCESS, mBox, moab::Tree::moab(), mStack, moab::AdaptiveKDTree::Plane::norm, and treeTool.
ErrorCode moab::AdaptiveKDTreeIter::get_parent_split_plane | ( | AdaptiveKDTree::Plane & | plane | ) | const |
Get split plane that separates this node from its immediate sibling.
Definition at line 722 of file AdaptiveKDTree.cpp.
References moab::AdaptiveKDTree::get_split_plane(), MB_ENTITY_NOT_FOUND, mStack, and tool().
|
inline |
Get handle for current leaf.
Definition at line 392 of file AdaptiveKDTree.hpp.
References mStack.
Referenced by moab::AdaptiveKDTree::best_subdivision_plane(), moab::AdaptiveKDTree::best_subdivision_snap_plane(), moab::AdaptiveKDTree::best_vertex_median_plane(), moab::AdaptiveKDTree::best_vertex_sample_plane(), moab::AdaptiveKDTree::build_tree(), moab::AdaptiveKDTree::compute_depth(), moab::MergeMesh::find_merged_to(), is_sibling(), moab::AdaptiveKDTree::merge_leaf(), moab::Coupler::nat_param(), moab::AdaptiveKDTree::point_search(), moab::AdaptiveKDTree::print(), sibling_is_forward(), sibling_side(), and moab::AdaptiveKDTree::split_leaf().
ErrorCode moab::AdaptiveKDTreeIter::initialize | ( | AdaptiveKDTree * | tool, |
EntityHandle | root, | ||
const double | box_min[3], | ||
const double | box_max[3], | ||
Direction | direction | ||
) |
Definition at line 475 of file AdaptiveKDTree.cpp.
References BMAX, BMIN, mBox, mStack, step_to_first_leaf(), and treeTool.
Referenced by moab::AdaptiveKDTree::build_tree(), moab::AdaptiveKDTree::get_last_iterator(), and moab::AdaptiveKDTree::get_sub_tree_iterator().
bool moab::AdaptiveKDTreeIter::intersect_ray | ( | const double | ray_point[3], |
const double | ray_vect[3], | ||
double & | t_enter, | ||
double & | t_exit | ||
) | const |
Find range of overlap between ray and leaf.
ray_point | Coordinates of start point of ray |
ray_vect | Directionion vector for ray such that the ray is defined by r(t) = ray_point + t * ray_vect for t > 0. |
t_enter | Output: if return value is true, this value is the parameter location along the ray at which the ray entered the leaf. If return value is false, then this value is undefined. |
t_exit | Output: if return value is true, this value is the parameter location along the ray at which the ray exited the leaf. If return value is false, then this value is undefined. |
Definition at line 767 of file AdaptiveKDTree.cpp.
References box_max(), box_min(), moab::GeomUtil::ray_box_intersect(), moab::TreeStats::traversalLeafObjectTests, moab::Tree::treeStats, and treeTool.
|
inline |
test if a plane intersects the leaf box
Definition at line 416 of file AdaptiveKDTree.hpp.
References BMAX, BMIN, moab::AdaptiveKDTree::Plane::coord, mBox, and moab::AdaptiveKDTree::Plane::norm.
bool moab::AdaptiveKDTreeIter::is_sibling | ( | const AdaptiveKDTreeIter & | other_leaf | ) | const |
Return true if thos node and the passed node share the same immediate parent.
Definition at line 731 of file AdaptiveKDTree.cpp.
bool moab::AdaptiveKDTreeIter::is_sibling | ( | EntityHandle | other_leaf | ) | const |
Return true if thos node and the passed node share the same immediate parent.
Definition at line 738 of file AdaptiveKDTree.cpp.
References childVect, ErrorCode, moab::Interface::get_child_meshsets(), handle(), MB_SUCCESS, moab::Tree::moab(), mStack, and tool().
bool moab::AdaptiveKDTreeIter::sibling_is_forward | ( | ) | const |
Returns true if calling step() will advance to the immediate sibling of the current node. Returns false if current node is root or back() will move to the immediate sibling.
Definition at line 752 of file AdaptiveKDTree.cpp.
References childVect, ErrorCode, moab::Interface::get_child_meshsets(), handle(), MB_SUCCESS, moab::Tree::moab(), mStack, and tool().
ErrorCode moab::AdaptiveKDTreeIter::sibling_side | ( | AdaptiveKDTree::Axis & | axis_out, |
bool & | neg_out | ||
) | const |
Return the side of the box bounding this tree node that is shared with the immediately adjacent sibling (the tree node that shares a common parent node with this node in the binary tree.)
axis_out | The principal axis orthogonal to the side of the box |
neg_out | true if the side of the box is toward the decreasing direction of the principal axis indicated by axis_out, false if it is toward the increasing direction. |
Definition at line 702 of file AdaptiveKDTree.cpp.
References childVect, ErrorCode, moab::Interface::get_child_meshsets(), moab::AdaptiveKDTree::get_split_plane(), handle(), MB_ENTITY_NOT_FOUND, MB_SUCCESS, moab::Tree::moab(), mStack, moab::AdaptiveKDTree::Plane::norm, and tool().
|
inline |
Advance the iterator either left or right in the tree Note: stepping past the end of the tree will invalidate the iterator. It will not be work step the other direction.
Definition at line 520 of file AdaptiveKDTree.cpp.
References childVect, moab::AdaptiveKDTree::Plane::coord, moab::AdaptiveKDTreeIter::StackObj::coord, moab::AdaptiveKDTreeIter::StackObj::entity, ErrorCode, moab::Interface::get_child_meshsets(), moab::AdaptiveKDTree::get_split_plane(), moab::TreeStats::leavesVisited, MB_ENTITY_NOT_FOUND, MB_SUCCESS, mBox, moab::Tree::moab(), mStack, moab::TreeStats::nodesVisited, moab::AdaptiveKDTree::Plane::norm, step_to_first_leaf(), moab::Tree::treeStats, and treeTool.
Referenced by moab::AdaptiveKDTree::build_tree(), moab::AdaptiveKDTree::compute_depth(), moab::MergeMesh::find_merged_to(), and moab::AdaptiveKDTree::print().
Descend tree to left most leaf from current position No-op if at leaf.
Definition at line 493 of file AdaptiveKDTree.cpp.
References childVect, moab::AdaptiveKDTree::Plane::coord, ErrorCode, moab::Interface::get_child_meshsets(), moab::AdaptiveKDTree::get_split_plane(), moab::TreeStats::leavesVisited, MB_SUCCESS, mBox, moab::Tree::moab(), mStack, moab::TreeStats::nodesVisited, moab::AdaptiveKDTree::Plane::norm, moab::Tree::treeStats, and treeTool.
Referenced by moab::AdaptiveKDTree::compute_depth(), initialize(), moab::AdaptiveKDTree::split_leaf(), and step().
|
inline |
Definition at line 386 of file AdaptiveKDTree.hpp.
References treeTool.
Referenced by moab::AdaptiveKDTree::best_subdivision_plane(), moab::AdaptiveKDTree::best_subdivision_snap_plane(), moab::AdaptiveKDTree::best_vertex_median_plane(), moab::AdaptiveKDTree::best_vertex_sample_plane(), get_parent_split_plane(), is_sibling(), sibling_is_forward(), and sibling_side().
|
inline |
|
friend |
Definition at line 375 of file AdaptiveKDTree.hpp.
|
mutableprivate |
temporary storage of child handles
Definition at line 369 of file AdaptiveKDTree.hpp.
Referenced by get_neighbors(), is_sibling(), moab::AdaptiveKDTree::merge_leaf(), moab::AdaptiveKDTree::point_search(), sibling_is_forward(), sibling_side(), step(), and step_to_first_leaf().
|
private |
min and max corners of bounding box
Definition at line 366 of file AdaptiveKDTree.hpp.
Referenced by box_max(), box_min(), get_neighbors(), initialize(), intersects(), moab::AdaptiveKDTree::merge_leaf(), moab::AdaptiveKDTree::point_search(), step(), step_to_first_leaf(), and volume().
|
private |
stack storing path through tree
Definition at line 368 of file AdaptiveKDTree.hpp.
Referenced by depth(), get_neighbors(), get_parent_split_plane(), handle(), initialize(), is_sibling(), moab::AdaptiveKDTree::merge_leaf(), moab::AdaptiveKDTree::point_search(), sibling_is_forward(), sibling_side(), step(), and step_to_first_leaf().
|
private |
tool for tree
Definition at line 367 of file AdaptiveKDTree.hpp.
Referenced by get_neighbors(), initialize(), intersect_ray(), moab::AdaptiveKDTree::point_search(), step(), step_to_first_leaf(), and tool().