Bounding Volume Hierarchy (sorta like a tree), for sorting and searching entities spatially. More...
#include <BVHTree.hpp>
Classes | |
class | Bucket |
class | HandleData |
class | HandleData_comparator |
class | Node |
class | Split_comparator |
class | SplitData |
class | TreeNode |
Public Member Functions | |
BVHTree (Interface *impl) | |
~BVHTree () | |
virtual ErrorCode | reset_tree () |
Destroy the tree maintained by this object, optionally checking we have the right root. More... | |
virtual ErrorCode | parse_options (FileOptions &opts) |
Parse options for this tree, including common options for all trees. More... | |
virtual ErrorCode | get_bounding_box (BoundBox &box, EntityHandle *tree_node=NULL) const |
Get bounding box for tree below tree_node, or entire tree If no tree has been built yet, returns +/- DBL_MAX for all dimensions. Note for some tree types, boxes are not available for non-root nodes, and this function will return failure if non-root is passed in. More... | |
virtual ErrorCode | build_tree (const Range &entities, EntityHandle *tree_root_set=NULL, FileOptions *options=NULL) |
virtual ErrorCode | point_search (const double *point, EntityHandle &leaf_out, const double iter_tol=1.0e-10, const double inside_tol=1.0e-6, bool *multiple_leaves=NULL, EntityHandle *start_node=NULL, CartVect *params=NULL) |
Get leaf containing input position. More... | |
virtual ErrorCode | distance_search (const double from_point[3], const double distance, std::vector< EntityHandle > &result_list, const double iter_tol=1.0e-10, const double inside_tol=1.0e-6, std::vector< double > *result_dists=NULL, std::vector< CartVect > *result_params=NULL, EntityHandle *tree_root=NULL) |
Find all leaves within a given distance from point If dists_out input non-NULL, also returns distances from each leaf; if point i is inside leaf, 0 is given as dists_out[i]. If params_out is non-NULL and myEval is non-NULL, will evaluate individual entities in tree nodes and return containing entities in leaves_out. In those cases, if params_out is also non-NULL, will return parameters in those elements in that vector. More... | |
virtual ErrorCode | print () |
print various things about this tree More... | |
Public Member Functions inherited from moab::Tree | |
Tree (Interface *iface) | |
Constructor (bare) More... | |
virtual | ~Tree () |
Destructor. More... | |
ErrorCode | delete_tree_sets () |
Delete the entity sets associated with the tree, starting with the root and traversing children. More... | |
virtual ErrorCode | get_info (EntityHandle root, double min[3], double max[3], unsigned int &max_dep) |
Return some basic information about the tree Stats are returned for tree starting from input node or tree root (root = 0) More... | |
ErrorCode | find_all_trees (Range &results) |
Find all trees, by bounding box tag. More... | |
virtual ErrorCode | distance_search (const double *point, const double distance, std::vector< EntityHandle > &leaves_out, const double iter_tol=1.0e-10, const double inside_tol=1.0e-6, std::vector< double > *dists_out=NULL, std::vector< CartVect > *params_out=NULL, EntityHandle *start_node=NULL)=0 |
Find all leaves within a given distance from point If dists_out input non-NULL, also returns distances from each leaf; if point i is inside leaf, 0 is given as dists_out[i]. If params_out is non-NULL and myEval is non-NULL, will evaluate individual entities in tree nodes and return containing entities in leaves_out. In those cases, if params_out is also non-NULL, will return parameters in those elements in that vector. More... | |
Interface * | moab () |
Return the MOAB interface associated with this tree. More... | |
const Interface * | moab () const |
Return the MOAB interface associated with this tree. More... | |
double | get_max_depth () |
Get max depth set on tree. More... | |
double | get_max_per_leaf () |
Get max entities per leaf set on tree. More... | |
TreeStats & | tree_stats () |
Get tree traversal stats object. More... | |
const TreeStats & | tree_stats () const |
Get tree traversal stats object. More... | |
ErrorCode | create_root (const double box_min[3], const double box_max[3], EntityHandle &root_handle) |
Create tree root and tag with bounding box. More... | |
ElemEvaluator * | get_eval () |
get/set the ElemEvaluator More... | |
void | set_eval (ElemEvaluator *eval) |
get/set the ElemEvaluator More... | |
Private Types | |
typedef std::vector< HandleData > | HandleDataVec |
Private Member Functions | |
BVHTree (const BVHTree &s) | |
void | establish_buckets (HandleDataVec::const_iterator begin, HandleDataVec::const_iterator end, const BoundBox &interval, std::vector< std::vector< Bucket > > &buckets) const |
unsigned int | set_interval (BoundBox &interval, std::vector< Bucket >::const_iterator begin, std::vector< Bucket >::const_iterator end) const |
void | initialize_splits (std::vector< std::vector< SplitData > > &splits, const std::vector< std::vector< Bucket > > &buckets, const SplitData &data) const |
void | order_elements (HandleDataVec::iterator &begin, HandleDataVec::iterator &end, SplitData &data) const |
void | median_order (HandleDataVec::iterator &begin, HandleDataVec::iterator &end, SplitData &data) const |
void | choose_best_split (const std::vector< std::vector< SplitData > > &splits, SplitData &data) const |
void | find_split (HandleDataVec::iterator &begin, HandleDataVec::iterator &end, SplitData &data) const |
ErrorCode | find_point (const std::vector< double > &point, const unsigned int &index, const double iter_tol, const double inside_tol, std::pair< EntityHandle, CartVect > &result) |
EntityHandle | bruteforce_find (const double *point, const double iter_tol=1.0e-10, const double inside_tol=1.0e-6) |
int | local_build_tree (std::vector< Node > &tree_nodes, HandleDataVec::iterator begin, HandleDataVec::iterator end, const int index, const BoundBox &box, const int depth=0) |
ErrorCode | construct_element_vec (std::vector< HandleData > &handle_data_vec, const Range &elements, BoundBox &bounding_box) |
ErrorCode | convert_tree (std::vector< Node > &tree_nodes) |
ErrorCode | print_nodes (std::vector< Node > &nodes) |
Private Attributes | |
Range | entityHandles |
std::vector< TreeNode > | myTree |
int | splitsPerDir |
EntityHandle | startSetHandle |
Static Private Attributes | |
static MOAB_EXPORT const char * | treeName = "BVHTree" |
Additional Inherited Members | |
Protected Member Functions inherited from moab::Tree | |
ErrorCode | parse_common_options (FileOptions &options) |
Parse options common to all trees. More... | |
Tag | get_box_tag (bool create_if_missing=true) |
Get the box tag, possibly constructing it first. More... | |
Protected Attributes inherited from moab::Tree | |
Interface * | mbImpl |
BoundBox | boundBox |
int | maxPerLeaf |
int | maxDepth |
int | treeDepth |
double | minWidth |
unsigned int | meshsetFlags |
bool | cleanUp |
EntityHandle | myRoot |
Tag | boxTag |
std::string | boxTagName |
TreeStats | treeStats |
ElemEvaluator * | myEval |
Bounding Volume Hierarchy (sorta like a tree), for sorting and searching entities spatially.
Definition at line 31 of file BVHTree.hpp.
|
private |
Definition at line 139 of file BVHTree.hpp.
|
inline |
Definition at line 357 of file BVHTree.hpp.
References moab::Tree::boxTagName, and treeName.
|
inline |
|
private |
|
private |
Definition at line 547 of file BVHTree.cpp.
References moab::CartVect::array(), dim, ErrorCode, moab::ElemEvaluator::find_containing_entity(), moab::TreeStats::leavesVisited, MB_SUCCESS, moab::Tree::myEval, myTree, moab::TreeStats::numTraversals, startSetHandle, moab::TreeStats::traversalLeafObjectTests, and moab::Tree::treeStats.
|
virtual |
Build the tree Build a tree with the entities input. If a non-NULL tree_root_set pointer is input, use the pointed-to set as the root of this tree (*tree_root_set!=0) otherwise construct a new root set and pass its handle back in *tree_root_set. Options vary by tree type; see Tree.hpp for common options; options specific to AdaptiveKDTree: SPLITS_PER_DIR: number of candidate splits considered per direction; default = 3 CANDIDATE_PLANE_SET: method used to decide split planes; see CandidatePlaneSet enum (below) for possible values; default = 1 (SUBDIVISION_SNAP)
entities | Entities with which to build the tree |
tree_root | Root set for tree (see function description) |
opts | Options for tree (see function description) |
Implements moab::Tree.
Definition at line 11 of file BVHTree.cpp.
References moab::Interface::add_entities(), moab::FileOptions::all_seen(), moab::CartVect::array(), moab::BoundBox::bMax, moab::BoundBox::bMin, moab::Tree::boundBox, moab::TreeStats::compute_stats(), construct_element_vec(), convert_tree(), moab::Tree::create_root(), entities, ErrorCode, moab::TreeStats::initTime, moab::BoundBox::intersects_box(), local_build_tree(), moab::Tree::maxPerLeaf, MB_SUCCESS, moab::Tree::mbImpl, moab::Tree::moab(), parse_options(), moab::TreeStats::reset(), startSetHandle, moab::CpuTimer::time_elapsed(), moab::Tree::treeDepth, moab::Tree::treeStats, and moab::BoundBox::update().
|
inlineprivate |
Definition at line 398 of file BVHTree.hpp.
Referenced by find_split().
|
inlineprivate |
Definition at line 410 of file BVHTree.hpp.
References moab::Range::begin(), bounding_box, moab::Range::end(), ErrorCode, moab::Interface::get_connectivity(), moab::Interface::get_coords(), moab::CN::MAX_NODES_PER_ELEMENT, MB_SUCCESS, moab::Tree::mbImpl, and moab::BoundBox::update().
Referenced by build_tree().
Definition at line 94 of file BVHTree.cpp.
References moab::Interface::add_child_meshset(), moab::Interface::add_entities(), moab::ReadUtilIface::create_entity_sets(), ErrorCode, moab::Range::insert(), MB_SUCCESS, moab::Tree::mbImpl, moab::Tree::meshsetFlags, myTree, moab::Interface::query_interface(), moab::Interface::release_interface(), and startSetHandle.
Referenced by build_tree().
|
virtual |
Find all leaves within a given distance from point If dists_out input non-NULL, also returns distances from each leaf; if point i is inside leaf, 0 is given as dists_out[i]. If params_out is non-NULL and myEval is non-NULL, will evaluate individual entities in tree nodes and return containing entities in leaves_out. In those cases, if params_out is also non-NULL, will return parameters in those elements in that vector.
from_point | Point to be located in tree |
distance | Distance within which to query |
result_list | Leaves within distance or containing point |
iter_tol | Tolerance for convergence of point search |
inside_tol | Tolerance for inside element calculation |
result_dists | If non-NULL, will contain distsances to leaves |
result_params | If non-NULL, will contain parameters of the point in the ents in leaves_out |
tree_root | Start from this tree node (non-NULL) instead of tree root (NULL) |
Definition at line 646 of file BVHTree.cpp.
References moab::CartVect::array(), child, dim, moab::BoundBox::distance_squared(), ErrorCode, moab::ElemEvaluator::find_containing_entity(), get_bounding_box(), moab::TreeStats::leavesVisited, moab::Tree::maxDepth, MB_SUCCESS, moab::Tree::myEval, moab::Tree::myRoot, myTree, moab::TreeStats::nodesVisited, moab::TreeStats::numTraversals, startSetHandle, moab::TreeStats::traversalLeafObjectTests, and moab::Tree::treeStats.
|
private |
Definition at line 150 of file BVHTree.cpp.
References moab::BVHTree::Bucket::boundingBox, moab::BVHTree::Bucket::bucket_index(), dim, moab::BoundBox::intersects_box(), moab::BVHTree::Bucket::mySize, size, splitsPerDir, and moab::BoundBox::update().
Referenced by find_split().
|
private |
Definition at line 466 of file BVHTree.cpp.
References moab::CartVect::array(), children, moab::BVHTree::TreeNode::dim, entities, ErrorCode, moab::Interface::get_child_meshsets(), moab::Interface::get_entities_by_handle(), moab::TreeStats::leavesVisited, moab::BVHTree::TreeNode::Lmax, MB_SUCCESS, moab::Tree::mbImpl, moab::Tree::myEval, myTree, moab::TreeStats::nodesVisited, moab::TreeStats::numTraversals, moab::ElemEvaluator::reverse_eval(), moab::BVHTree::TreeNode::Rmin, moab::ElemEvaluator::set_ent_handle(), startSetHandle, moab::TreeStats::traversalLeafObjectTests, and moab::Tree::treeStats.
|
private |
Definition at line 320 of file BVHTree.cpp.
References moab::BVHTree::SplitData::boundingBox, choose_best_split(), moab::BVHTree::SplitData::dim, establish_buckets(), initialize_splits(), moab::BoundBox::intersects_box(), left_box, moab::BVHTree::SplitData::leftBox, moab::BVHTree::SplitData::Lmax, median_order(), moab::BVHTree::SplitData::nl, moab::BVHTree::SplitData::nr, order_elements(), right_box, moab::BVHTree::SplitData::rightBox, moab::BVHTree::SplitData::Rmin, and splitsPerDir.
Referenced by local_build_tree().
|
virtual |
Get bounding box for tree below tree_node, or entire tree If no tree has been built yet, returns +/- DBL_MAX for all dimensions. Note for some tree types, boxes are not available for non-root nodes, and this function will return failure if non-root is passed in.
box | The box for this tree |
tree_node | If non-NULL, node for which box is requested, tree root if NULL |
Reimplemented from moab::Tree.
Definition at line 571 of file BVHTree.cpp.
References moab::Tree::boundBox, MB_SUCCESS, myTree, and startSetHandle.
Referenced by distance_search(), and point_search().
|
private |
Definition at line 225 of file BVHTree.cpp.
References moab::BoundBox::bMax, moab::BoundBox::bMin, moab::BVHTree::SplitData::boundingBox, moab::BoundBox::intersects_box(), set_interval(), and moab::BoundBox::update().
Referenced by find_split().
|
private |
Definition at line 418 of file BVHTree.cpp.
References moab::BVHTree::SplitData::boundingBox, moab::BVHTree::SplitData::dim, entities, find_split(), moab::BoundBox::intersects_box(), moab::BVHTree::SplitData::leftBox, moab::BVHTree::SplitData::Lmax, moab::Tree::maxDepth, moab::Tree::maxPerLeaf, moab::BVHTree::SplitData::nl, moab::BVHTree::SplitData::rightBox, and moab::BVHTree::SplitData::Rmin.
Referenced by build_tree().
|
private |
Definition at line 278 of file BVHTree.cpp.
References moab::BoundBox::bMax, moab::BoundBox::bMin, moab::BVHTree::SplitData::boundingBox, moab::BVHTree::SplitData::dim, dim, moab::BoundBox::intersects_box(), moab::BVHTree::SplitData::leftBox, moab::BVHTree::SplitData::Lmax, moab::BVHTree::SplitData::nl, moab::BVHTree::SplitData::nr, moab::BVHTree::SplitData::rightBox, moab::BVHTree::SplitData::Rmin, moab::BVHTree::SplitData::split, and moab::BoundBox::update().
Referenced by find_split().
|
inlineprivate |
Definition at line 386 of file BVHTree.hpp.
References moab::BVHTree::SplitData::boundingBox, moab::BVHTree::Bucket::bucket_index(), moab::BVHTree::SplitData::dim, moab::BVHTree::SplitData::split, and splitsPerDir.
Referenced by find_split().
|
virtual |
Parse options for this tree, including common options for all trees.
opts | Options |
Implements moab::Tree.
Definition at line 137 of file BVHTree.cpp.
References ErrorCode, moab::FileOptions::get_int_option(), MB_SUCCESS, moab::Tree::parse_common_options(), and splitsPerDir.
Referenced by build_tree().
|
virtual |
Get leaf containing input position.
Does not take into account global bounding box of tree.
point | Point to be located in tree |
leaf_out | Leaf containing point |
iter_tol | Tolerance for convergence of point search |
inside_tol | Tolerance for inside element calculation |
multiple_leaves | Some tree types can have multiple leaves containing a point; if non-NULL, this parameter is returned true if multiple leaves contain the input point |
start_node | Start from this tree node (non-NULL) instead of tree root (NULL) |
Implements moab::Tree.
Definition at line 586 of file BVHTree.cpp.
References moab::CartVect::array(), child, moab::BoundBox::contains_point(), dim, ErrorCode, moab::ElemEvaluator::find_containing_entity(), get_bounding_box(), moab::TreeStats::leavesVisited, MB_SUCCESS, moab::Tree::myEval, moab::Tree::myRoot, myTree, moab::TreeStats::nodesVisited, moab::TreeStats::numTraversals, startSetHandle, moab::TreeStats::traversalLeafObjectTests, and moab::Tree::treeStats.
|
virtual |
print various things about this tree
Implements moab::Tree.
Definition at line 740 of file BVHTree.cpp.
References MB_SUCCESS, and myTree.
Definition at line 728 of file BVHTree.cpp.
References MB_SUCCESS.
|
inlinevirtual |
Destroy the tree maintained by this object, optionally checking we have the right root.
root | If non-NULL, check that this is the root, return failure if not |
Implements moab::Tree.
Definition at line 440 of file BVHTree.hpp.
References moab::Tree::delete_tree_sets().
Referenced by ~BVHTree().
|
inlineprivate |
Definition at line 362 of file BVHTree.hpp.
References moab::GeomUtil::first(), and moab::BoundBox::update().
Referenced by initialize_splits().
|
private |
Definition at line 323 of file BVHTree.hpp.
|
private |
Definition at line 324 of file BVHTree.hpp.
Referenced by bruteforce_find(), convert_tree(), distance_search(), find_point(), get_bounding_box(), point_search(), and print().
|
private |
Definition at line 325 of file BVHTree.hpp.
Referenced by establish_buckets(), find_split(), order_elements(), and parse_options().
|
private |
Definition at line 326 of file BVHTree.hpp.
Referenced by bruteforce_find(), build_tree(), convert_tree(), distance_search(), find_point(), get_bounding_box(), and point_search().
|
staticprivate |
Definition at line 327 of file BVHTree.hpp.
Referenced by BVHTree().