BSP tree, for sorting and searching entities spatially. More...
#include <BSPTree.hpp>
Classes | |
struct | Plane |
struct to store a plane More... | |
Public Types | |
enum | Axis { X = 0 , Y = 1 , Z = 2 } |
Enumerate split plane directions. More... | |
Public Member Functions | |
BSPTree (Interface *iface, const char *tagname=0, unsigned meshset_creation_flags=MESHSET_SET) | |
BSPTree (Interface *iface, bool destroy_created_trees, const char *tagname=0, unsigned meshset_creation_flags=MESHSET_SET) | |
~BSPTree () | |
ErrorCode | get_split_plane (EntityHandle node, Plane &plane) |
Get split plane for tree node. More... | |
ErrorCode | set_split_plane (EntityHandle node, const Plane &plane) |
Set split plane for tree node. More... | |
ErrorCode | get_tree_box (EntityHandle root_node, double corner_coords[8][3]) |
Get bounding box for entire tree. More... | |
ErrorCode | get_tree_box (EntityHandle root_node, double corner_coords[24]) |
Get bounding box for entire tree. More... | |
ErrorCode | set_tree_box (EntityHandle root_node, const double box_min[3], const double box_max[3]) |
Set bounding box for entire tree. More... | |
ErrorCode | set_tree_box (EntityHandle root_node, const double corner_coords[8][3]) |
ErrorCode | create_tree (const double box_min[3], const double box_max[3], EntityHandle &root_handle) |
Create tree root node. More... | |
ErrorCode | create_tree (const double corner_coords[8][3], EntityHandle &root_handle) |
ErrorCode | create_tree (EntityHandle &root_handle) |
Create tree root node. More... | |
ErrorCode | find_all_trees (Range &results) |
Find all tree roots. More... | |
ErrorCode | delete_tree (EntityHandle root_handle) |
Destroy a tree. More... | |
Interface * | moab () |
ErrorCode | get_tree_iterator (EntityHandle tree_root, BSPTreeIter &result) |
Get iterator for tree. More... | |
ErrorCode | get_tree_end_iterator (EntityHandle tree_root, BSPTreeIter &result) |
Get iterator at right-most ('last') leaf. More... | |
ErrorCode | split_leaf (BSPTreeIter &leaf, Plane plane) |
Split leaf of tree Updates iterator location to point to first new leaf node. More... | |
ErrorCode | split_leaf (BSPTreeIter &leaf, Plane plane, EntityHandle &left_child, EntityHandle &right_child) |
Split leaf of tree Updates iterator location to point to first new leaf node. More... | |
ErrorCode | split_leaf (BSPTreeIter &leaf, Plane plane, const Range &left_entities, const Range &right_entities) |
Split leaf of tree Updates iterator location to point to first new leaf node. More... | |
ErrorCode | split_leaf (BSPTreeIter &leaf, Plane plane, const std::vector< EntityHandle > &left_entities, const std::vector< EntityHandle > &right_entities) |
Split leaf of tree Updates iterator location to point to first new leaf node. More... | |
ErrorCode | merge_leaf (BSPTreeIter &iter) |
Merge the leaf pointed to by the current iterator with it's sibling. If the sibling is not a leaf, multiple merges may be done. More... | |
ErrorCode | leaf_containing_point (EntityHandle tree_root, const double point[3], EntityHandle &leaf_out) |
Get leaf containing input position. More... | |
ErrorCode | leaf_containing_point (EntityHandle tree_root, const double xyz[3], BSPTreeIter &result) |
Get iterator at leaf containing input position. More... | |
Static Public Member Functions | |
static double | epsilon () |
Private Member Functions | |
ErrorCode | init_tags (const char *tagname=0) |
Private Attributes | |
Interface * | mbInstance |
Tag | planeTag |
Tag | rootTag |
unsigned | meshSetFlags |
bool | cleanUpTrees |
std::vector< EntityHandle > | createdTrees |
BSP tree, for sorting and searching entities spatially.
Definition at line 42 of file BSPTree.hpp.
enum moab::BSPTree::Axis |
moab::BSPTree::BSPTree | ( | Interface * | iface, |
const char * | tagname = 0 , |
||
unsigned | meshset_creation_flags = MESHSET_SET |
||
) |
moab::BSPTree::BSPTree | ( | Interface * | iface, |
bool | destroy_created_trees, | ||
const char * | tagname = 0 , |
||
unsigned | meshset_creation_flags = MESHSET_SET |
||
) |
moab::BSPTree::~BSPTree | ( | ) |
Definition at line 121 of file BSPTree.cpp.
References cleanUpTrees, createdTrees, delete_tree(), ErrorCode, MB_SUCCESS, moab(), rootTag, and moab::Interface::tag_get_by_ptr().
ErrorCode moab::BSPTree::create_tree | ( | const double | box_min[3], |
const double | box_max[3], | ||
EntityHandle & | root_handle | ||
) |
Create tree root node.
Definition at line 203 of file BSPTree.cpp.
References box_max(), box_min(), and moab::corners_from_box().
Referenced by create_tree().
ErrorCode moab::BSPTree::create_tree | ( | const double | corner_coords[8][3], |
EntityHandle & | root_handle | ||
) |
Definition at line 186 of file BSPTree.cpp.
References moab::Interface::create_meshset(), createdTrees, moab::Interface::delete_entities(), ErrorCode, MB_SUCCESS, meshSetFlags, moab(), and set_tree_box().
ErrorCode moab::BSPTree::create_tree | ( | EntityHandle & | root_handle | ) |
ErrorCode moab::BSPTree::delete_tree | ( | EntityHandle | root_handle | ) |
Destroy a tree.
Definition at line 210 of file BSPTree.cpp.
References children, createdTrees, moab::Interface::delete_entities(), ErrorCode, moab::Interface::get_child_meshsets(), MB_SUCCESS, moab(), rootTag, and moab::Interface::tag_delete_data().
Referenced by ~BSPTree().
|
inlinestatic |
Definition at line 54 of file BSPTree.hpp.
Referenced by moab::BSPTreeBoxIter::side_on_plane(), and moab::BSPTreeBoxIter::splits().
Find all tree roots.
Definition at line 234 of file BSPTree.cpp.
References moab::Interface::get_entities_by_type_and_tag(), MBENTITYSET, moab(), and rootTag.
|
inline |
Get split plane for tree node.
Definition at line 166 of file BSPTree.hpp.
References moab(), planeTag, and moab::Interface::tag_get_data().
Referenced by moab::BSPTreeIter::calculate_polyhedron(), moab::BSPTreeBoxIter::get_neighbors(), moab::BSPTreeIter::get_parent_split_plane(), leaf_containing_point(), moab::BSPTreePlaneIter::operator++(), moab::BSPTreeBoxIter::sibling_side(), moab::BSPTreeBoxIter::step(), moab::BSPTreeBoxIter::step_to_first_leaf(), and moab::BSPTreeBoxIter::up().
ErrorCode moab::BSPTree::get_tree_box | ( | EntityHandle | root_node, |
double | corner_coords[24] | ||
) |
Get bounding box for entire tree.
Definition at line 174 of file BSPTree.cpp.
References moab(), rootTag, and moab::Interface::tag_get_data().
ErrorCode moab::BSPTree::get_tree_box | ( | EntityHandle | root_node, |
double | corner_coords[8][3] | ||
) |
Get bounding box for entire tree.
Definition at line 169 of file BSPTree.cpp.
References moab(), rootTag, and moab::Interface::tag_get_data().
Referenced by moab::BSPTreeIter::calculate_polyhedron(), moab::BSPTreeBoxIter::initialize(), and moab::BSPTreeIter::intersect_ray().
ErrorCode moab::BSPTree::get_tree_end_iterator | ( | EntityHandle | tree_root, |
BSPTreeIter & | result | ||
) |
Get iterator at right-most ('last') leaf.
Definition at line 246 of file BSPTree.cpp.
References ErrorCode, moab::BSPTreeIter::initialize(), MB_SUCCESS, moab::BSPTreeIter::RIGHT, and moab::BSPTreeIter::step_to_first_leaf().
ErrorCode moab::BSPTree::get_tree_iterator | ( | EntityHandle | tree_root, |
BSPTreeIter & | result | ||
) |
Get iterator for tree.
Definition at line 239 of file BSPTree.cpp.
References ErrorCode, moab::BSPTreeIter::initialize(), moab::BSPTreeIter::LEFT, MB_SUCCESS, and moab::BSPTreeIter::step_to_first_leaf().
|
private |
Definition at line 93 of file BSPTree.cpp.
References ErrorCode, MB_BSP_TREE_DEFAULT_TAG_NAME, MB_SUCCESS, MB_TAG_CREAT, MB_TAG_DENSE, MB_TAG_SPARSE, MB_TYPE_DOUBLE, moab(), planeTag, rootTag, and moab::Interface::tag_get_handle().
Referenced by BSPTree().
ErrorCode moab::BSPTree::leaf_containing_point | ( | EntityHandle | tree_root, |
const double | point[3], | ||
EntityHandle & | leaf_out | ||
) |
Get leaf containing input position.
Does not take into account global bounding box of tree.
Definition at line 1135 of file BSPTree.cpp.
References moab::BSPTree::Plane::above(), children, ErrorCode, moab::Interface::get_child_meshsets(), get_split_plane(), MB_SUCCESS, and moab().
ErrorCode moab::BSPTree::leaf_containing_point | ( | EntityHandle | tree_root, |
const double | xyz[3], | ||
BSPTreeIter & | result | ||
) |
Get iterator at leaf containing input position.
Returns MB_ENTITY_NOT_FOUND if point is not within bounding box of tree.
Definition at line 1156 of file BSPTree.cpp.
References moab::BSPTree::Plane::above(), moab::BSPTreeIter::childVect, moab::BSPTreeIter::down(), ErrorCode, moab::Interface::get_child_meshsets(), get_split_plane(), moab::BSPTreeIter::handle(), moab::BSPTreeIter::initialize(), MB_SUCCESS, and moab().
ErrorCode moab::BSPTree::merge_leaf | ( | BSPTreeIter & | iter | ) |
Merge the leaf pointed to by the current iterator with it's sibling. If the sibling is not a leaf, multiple merges may be done.
Definition at line 325 of file BSPTree.cpp.
References moab::Interface::add_entities(), moab::Range::back(), moab::BSPTreeIter::childVect, moab::Range::clear(), moab::Interface::delete_entities(), moab::BSPTreeIter::depth(), ErrorCode, moab::Interface::get_child_meshsets(), moab::Interface::get_entities_by_handle(), moab::BSPTreeIter::handle(), MB_CHK_ERR, MB_SUCCESS, moab(), moab::Interface::remove_child_meshset(), and moab::BSPTreeIter::up().
|
inline |
Definition at line 197 of file BSPTree.hpp.
References mbInstance.
Referenced by moab::BSPTreeIter::calculate_polyhedron(), create_tree(), delete_tree(), moab::BSPTreeIter::down(), moab::BSPTreeBoxIter::down(), find_all_trees(), moab::BSPTreeBoxIter::get_neighbors(), get_split_plane(), get_tree_box(), init_tags(), moab::BSPTreeIter::is_sibling(), leaf_containing_point(), merge_leaf(), moab::BSPTreePlaneIter::operator++(), set_split_plane(), set_tree_box(), moab::BSPTreeIter::sibling_is_forward(), split_leaf(), moab::BSPTreeIter::step(), moab::BSPTreeBoxIter::step(), moab::BSPTreeIter::step_to_first_leaf(), moab::BSPTreeBoxIter::step_to_first_leaf(), and ~BSPTree().
ErrorCode moab::BSPTree::set_split_plane | ( | EntityHandle | node, |
const Plane & | plane | ||
) |
Set split plane for tree node.
Definition at line 136 of file BSPTree.cpp.
References moab::BSPTree::Plane::coeff, moab::Util::is_finite(), moab(), moab::BSPTree::Plane::norm, planeTag, and moab::Interface::tag_set_data().
Referenced by split_leaf().
ErrorCode moab::BSPTree::set_tree_box | ( | EntityHandle | root_node, |
const double | box_min[3], | ||
const double | box_max[3] | ||
) |
Set bounding box for entire tree.
Definition at line 157 of file BSPTree.cpp.
References box_max(), box_min(), and moab::corners_from_box().
Referenced by create_tree().
ErrorCode moab::BSPTree::set_tree_box | ( | EntityHandle | root_node, |
const double | corner_coords[8][3] | ||
) |
Definition at line 164 of file BSPTree.cpp.
References moab(), rootTag, and moab::Interface::tag_set_data().
ErrorCode moab::BSPTree::split_leaf | ( | BSPTreeIter & | leaf, |
Plane | plane | ||
) |
Split leaf of tree Updates iterator location to point to first new leaf node.
Definition at line 280 of file BSPTree.cpp.
Referenced by split_leaf().
ErrorCode moab::BSPTree::split_leaf | ( | BSPTreeIter & | leaf, |
Plane | plane, | ||
const Range & | left_entities, | ||
const Range & | right_entities | ||
) |
Split leaf of tree Updates iterator location to point to first new leaf node.
Definition at line 286 of file BSPTree.cpp.
References children, moab::Interface::delete_entities(), ErrorCode, moab::BSPTreeIter::handle(), MB_SUCCESS, moab(), moab::Interface::remove_child_meshset(), and split_leaf().
ErrorCode moab::BSPTree::split_leaf | ( | BSPTreeIter & | leaf, |
Plane | plane, | ||
const std::vector< EntityHandle > & | left_entities, | ||
const std::vector< EntityHandle > & | right_entities | ||
) |
Split leaf of tree Updates iterator location to point to first new leaf node.
Definition at line 304 of file BSPTree.cpp.
References children, moab::Interface::delete_entities(), ErrorCode, moab::BSPTreeIter::handle(), MB_SUCCESS, moab(), moab::Interface::remove_child_meshset(), and split_leaf().
ErrorCode moab::BSPTree::split_leaf | ( | BSPTreeIter & | leaf, |
Plane | plane, | ||
EntityHandle & | left_child, | ||
EntityHandle & | right_child | ||
) |
Split leaf of tree Updates iterator location to point to first new leaf node.
Definition at line 253 of file BSPTree.cpp.
References children, moab::Interface::create_meshset(), moab::Interface::delete_entities(), ErrorCode, moab::BSPTreeIter::handle(), moab::BSPTreeIter::LEFT, MB_SUCCESS, meshSetFlags, moab(), set_split_plane(), and moab::BSPTreeIter::step_to_first_leaf().
|
private |
Definition at line 48 of file BSPTree.hpp.
Referenced by ~BSPTree().
|
private |
Definition at line 49 of file BSPTree.hpp.
Referenced by create_tree(), delete_tree(), and ~BSPTree().
|
private |
Definition at line 45 of file BSPTree.hpp.
Referenced by moab().
|
private |
Definition at line 47 of file BSPTree.hpp.
Referenced by create_tree(), and split_leaf().
|
private |
Definition at line 46 of file BSPTree.hpp.
Referenced by get_split_plane(), init_tags(), and set_split_plane().
|
private |
Definition at line 46 of file BSPTree.hpp.
Referenced by delete_tree(), find_all_trees(), get_tree_box(), init_tags(), set_tree_box(), and ~BSPTree().