Adaptive KD tree, for sorting and searching entities spatially. More...
#include <AdaptiveKDTree.hpp>
Classes | |
struct | Plane |
Split plane. More... | |
Public Types | |
enum | Axis { X = 0 , Y = 1 , Z = 2 } |
Enumeriate split plane directions. More... | |
enum | CandidatePlaneSet { SUBDIVISION = 0 , SUBDIVISION_SNAP , VERTEX_MEDIAN , VERTEX_SAMPLE } |
methods for selecting candidate split planes More... | |
Public Member Functions | |
AdaptiveKDTree (Interface *iface) | |
AdaptiveKDTree (Interface *iface, const Range &entities, EntityHandle *tree_root_set=NULL, FileOptions *opts=NULL) | |
Constructor (build the tree on construction) Construct a tree object, and build the tree with entities input. See comments for build_tree() for detailed description of arguments. More... | |
~AdaptiveKDTree () | |
ErrorCode | parse_options (FileOptions &options) |
Parse options for tree creation. More... | |
virtual ErrorCode | build_tree (const Range &entities, EntityHandle *tree_root_set=NULL, FileOptions *options=NULL) |
virtual ErrorCode | reset_tree () |
Reset the tree, optionally checking we have the right root. More... | |
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... | |
ErrorCode | point_search (const double *point, AdaptiveKDTreeIter &leaf_it, const double iter_tol=1.0e-10, const double inside_tol=1.0e-6, bool *multiple_leaves=NULL, EntityHandle *start_node=NULL) |
Get leaf containing input position. 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) |
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... | |
ErrorCode | get_info (EntityHandle root, double min[3], double max[3], unsigned int &dep) |
Return some basic information about the tree Stats are returned for tree starting from input node or tree root (root = 0) More... | |
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_iterator (EntityHandle tree_root, AdaptiveKDTreeIter &result) |
Get iterator for tree. More... | |
ErrorCode | get_last_iterator (EntityHandle tree_root, AdaptiveKDTreeIter &result) |
Get iterator at right-most ('last') leaf. More... | |
ErrorCode | get_sub_tree_iterator (EntityHandle tree_root, const double box_min[3], const double box_max[3], AdaptiveKDTreeIter &result) |
Get iterator for tree or subtree. More... | |
ErrorCode | split_leaf (AdaptiveKDTreeIter &leaf, Plane plane) |
Split leaf of tree Updates iterator location to point to first new leaf node. More... | |
ErrorCode | split_leaf (AdaptiveKDTreeIter &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 (AdaptiveKDTreeIter &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 (AdaptiveKDTreeIter &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 (AdaptiveKDTreeIter &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 | closest_triangle (EntityHandle tree_root, const double from_coords[3], double closest_point_out[3], EntityHandle &triangle_out) |
Find triangle closest to input position. More... | |
ErrorCode | sphere_intersect_triangles (EntityHandle tree_root, const double center[3], double radius, std::vector< EntityHandle > &triangles) |
ErrorCode | ray_intersect_triangles (EntityHandle tree_root, const double tolerance, const double ray_unit_dir[3], const double ray_base_pt[3], std::vector< EntityHandle > &triangles_out, std::vector< double > &distance_out, int result_count_limit=0, double distance_limit=-1.0) |
ErrorCode | compute_depth (EntityHandle root, unsigned int &min_depth, unsigned int &max_depth) |
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_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... | |
ErrorCode | find_all_trees (Range &results) |
Find all trees, by bounding box tag. 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 Member Functions | |
ErrorCode | init () |
ErrorCode | find_close_triangle (EntityHandle root, const double from_point[3], double pt[3], EntityHandle &triangle) |
find a triangle near the input point More... | |
ErrorCode | make_tag (Interface *iface, std::string name, TagType storage, DataType type, int count, void *default_val, Tag &tag_handle, std::vector< Tag > &created_tags) |
ErrorCode | intersect_children_with_elems (const Range &elems, AdaptiveKDTree::Plane plane, double eps, CartVect box_min, CartVect box_max, Range &left_tris, Range &right_tris, Range &both_tris, double &metric_value) |
ErrorCode | best_subdivision_snap_plane (int num_planes, const AdaptiveKDTreeIter &iter, Range &best_left, Range &best_right, Range &best_both, AdaptiveKDTree::Plane &best_plane, std::vector< double > &tmp_data, double eps) |
ErrorCode | best_subdivision_plane (int num_planes, const AdaptiveKDTreeIter &iter, Range &best_left, Range &best_right, Range &best_both, AdaptiveKDTree::Plane &best_plane, double eps) |
ErrorCode | best_vertex_median_plane (int num_planes, const AdaptiveKDTreeIter &iter, Range &best_left, Range &best_right, Range &best_both, AdaptiveKDTree::Plane &best_plane, std::vector< double > &coords, double eps) |
ErrorCode | best_vertex_sample_plane (int num_planes, const AdaptiveKDTreeIter &iter, Range &best_left, Range &best_right, Range &best_both, AdaptiveKDTree::Plane &best_plane, std::vector< double > &coords, std::vector< EntityHandle > &indices, double eps) |
Private Attributes | |
Tag | planeTag |
Tag | axisTag |
unsigned | splitsPerDir |
CandidatePlaneSet | planeSet |
bool | spherical |
double | radius |
Static Private Attributes | |
static const char * | treeName = "AKDTree" |
Friends | |
class | AdaptiveKDTreeIter |
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 |
Adaptive KD tree, for sorting and searching entities spatially.
Definition at line 23 of file AdaptiveKDTree.hpp.
Enumeriate split plane directions.
Enumerator | |
---|---|
X | |
Y | |
Z |
Definition at line 148 of file AdaptiveKDTree.hpp.
methods for selecting candidate split planes
Definition at line 248 of file AdaptiveKDTree.hpp.
moab::AdaptiveKDTree::AdaptiveKDTree | ( | Interface * | iface | ) |
Definition at line 36 of file AdaptiveKDTree.cpp.
References moab::Tree::boxTagName, ErrorCode, init(), MB_SUCCESS, and treeName.
moab::AdaptiveKDTree::AdaptiveKDTree | ( | Interface * | iface, |
const Range & | entities, | ||
EntityHandle * | tree_root_set = NULL , |
||
FileOptions * | opts = NULL |
||
) |
Constructor (build the tree on construction) Construct a tree object, and build the tree with entities input. See comments for build_tree() for detailed description of arguments.
iface | MOAB instance |
entities | Entities to build tree around |
tree_root | Root set for tree (see function description) |
opts | Options for tree (see function description) |
Definition at line 46 of file AdaptiveKDTree.cpp.
References moab::Tree::boxTagName, build_tree(), entities, ErrorCode, init(), MB_SUCCESS, parse_options(), and treeName.
moab::AdaptiveKDTree::~AdaptiveKDTree | ( | ) |
Definition at line 69 of file AdaptiveKDTree.cpp.
References moab::Tree::cleanUp, moab::Tree::myRoot, and reset_tree().
|
private |
Definition at line 942 of file AdaptiveKDTree.cpp.
References moab::AdaptiveKDTreeIter::box_max(), box_max(), moab::AdaptiveKDTreeIter::box_min(), box_min(), entities, ErrorCode, moab::Interface::get_entities_by_handle(), moab::AdaptiveKDTreeIter::handle(), intersect_children_with_elems(), MB_SUCCESS, moab::Tree::moab(), moab::Range::size(), moab::Range::swap(), and moab::AdaptiveKDTreeIter::tool().
Referenced by build_tree().
|
private |
Definition at line 990 of file AdaptiveKDTree.cpp.
References box_max(), box_min(), entities, ErrorCode, moab::Interface::get_adjacencies(), moab::Interface::get_coords(), moab::Interface::get_entities_by_handle(), moab::AdaptiveKDTreeIter::handle(), intersect_children_with_elems(), MB_SUCCESS, moab::Tree::moab(), moab::Range::size(), moab::Range::swap(), moab::AdaptiveKDTreeIter::tool(), and moab::Interface::UNION.
Referenced by build_tree().
|
private |
Definition at line 1083 of file AdaptiveKDTree.cpp.
References moab::AdaptiveKDTreeIter::box_max(), box_max(), moab::AdaptiveKDTreeIter::box_min(), box_min(), entities, ErrorCode, moab::Interface::get_adjacencies(), moab::Interface::get_coords(), moab::Interface::get_entities_by_handle(), moab::AdaptiveKDTreeIter::handle(), intersect_children_with_elems(), MB_SUCCESS, moab::Tree::moab(), moab::Range::size(), moab::Range::swap(), moab::AdaptiveKDTreeIter::tool(), and moab::Interface::UNION.
Referenced by build_tree().
|
private |
Definition at line 1156 of file AdaptiveKDTree.cpp.
References moab::AdaptiveKDTreeIter::box_max(), box_max(), moab::AdaptiveKDTreeIter::box_min(), box_min(), entities, ErrorCode, moab::Interface::get_adjacencies(), moab::Interface::get_coords(), moab::Interface::get_entities_by_handle(), moab::AdaptiveKDTreeIter::handle(), intersect_children_with_elems(), MB_SUCCESS, moab::Tree::moab(), moab::Range::size(), moab::Range::swap(), moab::AdaptiveKDTreeIter::tool(), and moab::Interface::UNION.
Referenced by build_tree().
|
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 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 80 of file AdaptiveKDTree.cpp.
References moab::Interface::add_entities(), moab::FileOptions::all_seen(), moab::CartVect::array(), best_subdivision_plane(), best_subdivision_snap_plane(), best_vertex_median_plane(), best_vertex_sample_plane(), moab::BoundBox::bMax, moab::BoundBox::bMin, moab::TreeStats::compute_stats(), moab::Tree::create_root(), moab::AdaptiveKDTreeIter::depth(), entities, ErrorCode, moab::Interface::get_number_entities_by_handle(), moab::AdaptiveKDTreeIter::handle(), moab::AdaptiveKDTreeIter::initialize(), moab::TreeStats::initTime, moab::AdaptiveKDTreeIter::LEFT, moab::Tree::maxDepth, moab::Tree::maxPerLeaf, MB_ENTITY_NOT_FOUND, MB_SUCCESS, moab::Tree::mbImpl, moab::Range::merge(), moab::Tree::minWidth, moab::Tree::moab(), moab::Tree::myRoot, moab::AdaptiveKDTree::Plane::norm, parse_options(), planeSet, radius, moab::TreeStats::reset(), reset_tree(), spherical, split_leaf(), splitsPerDir, moab::AdaptiveKDTreeIter::step(), SUBDIVISION, SUBDIVISION_SNAP, moab::CpuTimer::time_elapsed(), moab::Tree::treeStats, moab::BoundBox::update(), VERTEX_MEDIAN, and VERTEX_SAMPLE.
Referenced by AdaptiveKDTree(), moab::TempestRemapper::ConstructCoveringSet(), moab::Coupler::initialize_tree(), moab::Intx2Mesh::intersect_meshes(), moab::Intx2Mesh::intersect_meshes_kdtree(), main(), moab::MergeMesh::merge_all(), merge_duplicate_vertices(), moab::MergeMesh::merge_entities(), and moab::ReadNCDF::update().
ErrorCode moab::AdaptiveKDTree::closest_triangle | ( | EntityHandle | tree_root, |
const double | from_coords[3], | ||
double | closest_point_out[3], | ||
EntityHandle & | triangle_out | ||
) |
Find triangle closest to input position.
from_coords | The input position to test against |
closest_point_out | The closest point on the set of triangles in the tree |
triangle_out | The triangle closest to the input position |
Find the triangles in a set that are closer to the input position than any triangles in the 'closest_tris' list.
closest_tris is assumed to contain a list of triangles for which the first is the closest known triangle to the input position and the first entry in 'closest_pts' is the closest location on that triangle. Any other values in the lists must be other triangles for which the closest point is within the input tolerance of the closest closest point. This function will update the lists as appropriate if any closer triangles or triangles within the tolerance of the current closest location are found. The first entry is maintained as the closest of the list of triangles.
Definition at line 1763 of file AdaptiveKDTree.cpp.
References moab::CartVect::array(), moab::closest_to_triangles(), distance_search(), ErrorCode, find_close_triangle(), moab::CartVect::get(), MB_SUCCESS, and moab::Tree::moab().
ErrorCode moab::AdaptiveKDTree::compute_depth | ( | EntityHandle | root, |
unsigned int & | min_depth, | ||
unsigned int & | max_depth | ||
) |
Definition at line 2031 of file AdaptiveKDTree.cpp.
References moab::AdaptiveKDTreeIter::depth(), moab::Interface::get_number_entities_by_handle(), get_tree_iterator(), moab::AdaptiveKDTreeIter::handle(), moab::AdaptiveKDTreeIter::LEFT, MB_SUCCESS, moab::Tree::moab(), moab::AdaptiveKDTreeIter::step(), and moab::AdaptiveKDTreeIter::step_to_first_leaf().
Referenced by get_info().
|
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.
point | Point to be located in tree |
distance | Distance within which to query |
leaves_out | Leaves within distance or containing point |
iter_tol | Tolerance for convergence of point search |
inside_tol | Tolerance for inside element calculation |
dists_out | If non-NULL, will contain distsances to leaves |
params_out | If non-NULL, will contain parameters of the point in the ents in leaves_out |
start_node | Start from this tree node (non-NULL) instead of tree root (NULL) |
when we pop it from the list.)
when we pop it from the list.)
Implements moab::Tree.
Definition at line 1388 of file AdaptiveKDTree.cpp.
References moab::CartVect::array(), moab::BoundBox::bMax, moab::BoundBox::bMin, children, moab::BoundBox::contains_point(), moab::AdaptiveKDTree::Plane::coord, moab::NodeDistance::dist, ErrorCode, moab::ElemEvaluator::find_containing_entity(), moab::Tree::get_bounding_box(), moab::Interface::get_child_meshsets(), get_split_plane(), moab::NodeDistance::handle, moab::TreeStats::leavesVisited, moab::Tree::maxDepth, MB_SUCCESS, moab::Tree::moab(), moab::Tree::myEval, moab::Tree::myRoot, moab::TreeStats::nodesVisited, moab::AdaptiveKDTree::Plane::norm, moab::TreeStats::numTraversals, moab::TreeStats::traversalLeafObjectTests, and moab::Tree::treeStats.
Referenced by closest_triangle(), moab::MergeMesh::find_merged_to(), moab::Intx2Mesh::intersect_meshes(), moab::Intx2Mesh::intersect_meshes_kdtree(), merge_duplicate_vertices(), moab::Coupler::nat_param(), sphere_intersect_triangles(), and moab::ReadNCDF::update().
|
private |
find a triangle near the input point
Definition at line 1593 of file AdaptiveKDTree.cpp.
References children, moab::Range::clear(), moab::closest_to_triangles(), moab::Range::empty(), ErrorCode, moab::CartVect::get(), moab::Interface::get_child_meshsets(), moab::Interface::get_entities_by_type(), get_split_plane(), MB_ENTITY_NOT_FOUND, MB_SUCCESS, MBTRI, moab::Tree::moab(), and split.
Referenced by closest_triangle().
|
virtual |
Return some basic information about the tree Stats are returned for tree starting from input node or tree root (root = 0)
root | If non-0, give stats below and including root |
min | Minimum corner of bounding box |
max | Maximum corner of bounding box |
max_dep | Maximum depth of tree below root |
Reimplemented from moab::Tree.
Definition at line 2055 of file AdaptiveKDTree.cpp.
References moab::BoundBox::bMax, moab::BoundBox::bMin, compute_depth(), ErrorCode, moab::CartVect::get(), moab::Tree::get_bounding_box(), and MB_SUCCESS.
Referenced by moab::Coupler::initialize_tree().
ErrorCode moab::AdaptiveKDTree::get_last_iterator | ( | EntityHandle | tree_root, |
AdaptiveKDTreeIter & | result | ||
) |
Get iterator at right-most ('last') leaf.
Definition at line 327 of file AdaptiveKDTree.cpp.
References moab::Tree::boxTag, ErrorCode, moab::AdaptiveKDTreeIter::initialize(), MB_SUCCESS, moab::Tree::moab(), moab::AdaptiveKDTreeIter::RIGHT, and moab::Interface::tag_get_data().
ErrorCode moab::AdaptiveKDTree::get_split_plane | ( | EntityHandle | node, |
Plane & | plane | ||
) |
Get split plane for tree node.
Definition at line 285 of file AdaptiveKDTree.cpp.
References axisTag, moab::AdaptiveKDTree::Plane::coord, ErrorCode, MB_SUCCESS, moab::Tree::moab(), moab::AdaptiveKDTree::Plane::norm, planeTag, and moab::Interface::tag_get_data().
Referenced by distance_search(), find_close_triangle(), moab::AdaptiveKDTreeIter::get_neighbors(), moab::AdaptiveKDTreeIter::get_parent_split_plane(), merge_leaf(), point_search(), ray_intersect_triangles(), moab::AdaptiveKDTreeIter::sibling_side(), moab::AdaptiveKDTreeIter::step(), and moab::AdaptiveKDTreeIter::step_to_first_leaf().
ErrorCode moab::AdaptiveKDTree::get_sub_tree_iterator | ( | EntityHandle | tree_root, |
const double | box_min[3], | ||
const double | box_max[3], | ||
AdaptiveKDTreeIter & | result | ||
) |
Get iterator for tree or subtree.
Definition at line 336 of file AdaptiveKDTree.cpp.
References moab::AdaptiveKDTreeIter::initialize(), and moab::AdaptiveKDTreeIter::LEFT.
Referenced by get_tree_iterator().
ErrorCode moab::AdaptiveKDTree::get_tree_iterator | ( | EntityHandle | tree_root, |
AdaptiveKDTreeIter & | result | ||
) |
Get iterator for tree.
Definition at line 318 of file AdaptiveKDTree.cpp.
References moab::Tree::boxTag, ErrorCode, get_sub_tree_iterator(), MB_SUCCESS, moab::Tree::moab(), and moab::Interface::tag_get_data().
Referenced by compute_depth(), moab::MergeMesh::find_merged_to(), moab::Coupler::nat_param(), print(), and moab::ReadNCDF::update().
|
private |
Definition at line 240 of file AdaptiveKDTree.cpp.
References axisTag, moab::Tree::boxTagName, moab::AdaptiveKDTree::Plane::coord, ErrorCode, make_tag(), MB_SUCCESS, MB_TAG_DENSE, MB_TAG_MESH, MB_TYPE_DOUBLE, MB_TYPE_OPAQUE, moab::Tree::mbImpl, moab::Tree::moab(), planeTag, moab::Interface::tag_set_data(), and treeName.
Referenced by AdaptiveKDTree().
|
private |
Definition at line 777 of file AdaptiveKDTree.cpp.
References moab::Range::begin(), moab::BoundBox::bMax, moab::BoundBox::bMin, moab::GeomUtil::box_elem_overlap(), box_max(), box_min(), moab::TreeStats::boxElemTests, moab::Range::clear(), moab::TreeStats::constructLeafObjectTests, moab::AdaptiveKDTree::Plane::coord, dim, moab::Range::end(), ErrorCode, moab::Interface::get_connectivity(), moab::Interface::get_coords(), moab::Range::insert(), left_box, moab::Range::lower_bound(), MB_SUCCESS, MBEDGE, MBENTITYSET, MBPOLYHEDRON, moab::Tree::moab(), moab::AdaptiveKDTree::Plane::norm, radius, right_box, moab::Range::size(), spherical, moab::Tree::tree_stats(), moab::TYPE_FROM_HANDLE(), and moab::BoundBox::update().
Referenced by best_subdivision_plane(), best_subdivision_snap_plane(), best_vertex_median_plane(), and best_vertex_sample_plane().
|
private |
Definition at line 209 of file AdaptiveKDTree.cpp.
References axisTag, ErrorCode, iface, MB_SUCCESS, MB_TAG_CREAT, and planeTag.
Referenced by init().
ErrorCode moab::AdaptiveKDTree::merge_leaf | ( | AdaptiveKDTreeIter & | 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 419 of file AdaptiveKDTree.cpp.
References moab::Interface::add_entities(), moab::Range::back(), moab::AdaptiveKDTreeIter::childVect, moab::Range::clear(), moab::AdaptiveKDTreeIter::StackObj::coord, moab::Interface::delete_entities(), moab::AdaptiveKDTreeIter::depth(), moab::AdaptiveKDTreeIter::StackObj::entity, ErrorCode, moab::Interface::get_child_meshsets(), moab::Interface::get_entities_by_handle(), get_split_plane(), moab::AdaptiveKDTreeIter::handle(), MB_CHK_ERR, MB_SUCCESS, moab::AdaptiveKDTreeIter::mBox, moab::Tree::moab(), moab::AdaptiveKDTreeIter::mStack, moab::AdaptiveKDTree::Plane::norm, and moab::Interface::remove_child_meshset().
|
virtual |
Parse options for tree creation.
options | Options passed in by application |
Implements moab::Tree.
Definition at line 176 of file AdaptiveKDTree.cpp.
References ErrorCode, moab::FileOptions::get_int_option(), moab::FileOptions::get_real_option(), moab::FileOptions::get_toggle_option(), MB_ENTITY_NOT_FOUND, MB_SUCCESS, moab::Tree::parse_common_options(), planeSet, radius, spherical, splitsPerDir, SUBDIVISION, and VERTEX_SAMPLE.
Referenced by AdaptiveKDTree(), build_tree(), moab::Intx2Mesh::intersect_meshes(), and moab::Intx2Mesh::intersect_meshes_kdtree().
ErrorCode moab::AdaptiveKDTree::point_search | ( | const double * | point, |
AdaptiveKDTreeIter & | leaf_it, | ||
const double | iter_tol = 1.0e-10 , |
||
const double | inside_tol = 1.0e-6 , |
||
bool * | multiple_leaves = NULL , |
||
EntityHandle * | start_node = NULL |
||
) |
Get leaf containing input position.
Does not take into account global bounding box of tree.
point | Point to be located in tree |
leaf_it | Iterator to 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) |
Definition at line 1321 of file AdaptiveKDTree.cpp.
References moab::BoundBox::bMax, moab::BoundBox::bMin, moab::Tree::boundBox, moab::AdaptiveKDTreeIter::childVect, moab::BoundBox::contains_point(), moab::AdaptiveKDTree::Plane::coord, ErrorCode, moab::Interface::get_child_meshsets(), get_split_plane(), moab::AdaptiveKDTreeIter::handle(), moab::TreeStats::leavesVisited, MB_ENTITY_NOT_FOUND, MB_SUCCESS, moab::AdaptiveKDTreeIter::mBox, moab::Tree::moab(), moab::AdaptiveKDTreeIter::mStack, moab::Tree::myRoot, moab::TreeStats::nodesVisited, moab::AdaptiveKDTree::Plane::norm, moab::TreeStats::numTraversals, moab::Tree::treeStats, and moab::AdaptiveKDTreeIter::treeTool.
|
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 1266 of file AdaptiveKDTree.cpp.
References moab::CartVect::array(), children, moab::BoundBox::contains_point(), moab::AdaptiveKDTree::Plane::coord, ErrorCode, moab::ElemEvaluator::find_containing_entity(), moab::Tree::get_bounding_box(), moab::Interface::get_child_meshsets(), get_split_plane(), moab::TreeStats::leavesVisited, MB_SUCCESS, moab::Tree::moab(), moab::Tree::myEval, moab::Tree::myRoot, moab::TreeStats::nodesVisited, moab::AdaptiveKDTree::Plane::norm, moab::TreeStats::numTraversals, moab::TreeStats::traversalLeafObjectTests, and moab::Tree::treeStats.
Referenced by moab::TempestRemapper::ConstructCoveringSet(), main(), and moab::Coupler::nat_param().
|
virtual |
print various things about this tree
Implements moab::Tree.
Definition at line 2129 of file AdaptiveKDTree.cpp.
References moab::SimpleStat< T >::add(), moab::SimpleStat< T >::avg(), moab::Range::begin(), moab::BoundBox::bMax, moab::BoundBox::bMin, moab::AdaptiveKDTreeIter::box_max(), moab::AdaptiveKDTreeIter::box_min(), moab::SimpleStat< T >::count, moab::AdaptiveKDTreeIter::depth(), moab::SimpleStat< T >::dev(), moab::Range::end(), ErrorCode, moab::Interface::estimated_memory_use(), moab::Tree::get_bounding_box(), moab::Interface::get_child_meshsets(), moab::Interface::get_entities_by_dimension(), moab::Interface::get_entities_by_type(), moab::Interface::get_number_entities_by_dimension(), moab::Interface::get_number_entities_by_handle(), get_tree_iterator(), moab::AdaptiveKDTreeIter::handle(), moab::Range::insert(), moab::SimpleStat< T >::max, MB_SUCCESS, MBVERTEX, moab::mem_to_string(), moab::Range::merge(), moab::SimpleStat< T >::min, moab::Tree::moab(), moab::Tree::myRoot, moab::SimpleStat< T >::rms(), size, moab::Range::size(), moab::AdaptiveKDTreeIter::step(), and moab::SimpleStat< T >::sum.
ErrorCode moab::AdaptiveKDTree::ray_intersect_triangles | ( | EntityHandle | tree_root, |
const double | tolerance, | ||
const double | ray_unit_dir[3], | ||
const double | ray_base_pt[3], | ||
std::vector< EntityHandle > & | triangles_out, | ||
std::vector< double > & | distance_out, | ||
int | result_count_limit = 0 , |
||
double | distance_limit = -1.0 |
||
) |
Definition at line 1851 of file AdaptiveKDTree.cpp.
References moab::NodeSeg::beg, moab::Range::begin(), moab::BoundBox::bMax, moab::BoundBox::bMin, children, moab::Range::clear(), moab::AdaptiveKDTree::Plane::coord, moab::NodeSeg::end, moab::Range::end(), ErrorCode, moab::Tree::get_bounding_box(), moab::Interface::get_child_meshsets(), moab::Interface::get_connectivity(), moab::Interface::get_coords(), moab::Interface::get_entities_by_type(), get_split_plane(), moab::NodeSeg::handle, moab::Util::is_finite(), MB_SUCCESS, MBTRI, moab::Tree::moab(), moab::AdaptiveKDTree::Plane::norm, moab::GeomUtil::ray_tri_intersect(), and moab::GeomUtil::segment_box_intersect().
|
inlinevirtual |
Reset the tree, optionally checking we have the right root.
Implements moab::Tree.
Definition at line 528 of file AdaptiveKDTree.hpp.
References moab::Tree::delete_tree_sets().
Referenced by build_tree(), main(), and ~AdaptiveKDTree().
ErrorCode moab::AdaptiveKDTree::set_split_plane | ( | EntityHandle | node, |
const Plane & | plane | ||
) |
Set split plane for tree node.
Definition at line 303 of file AdaptiveKDTree.cpp.
References axisTag, moab::AdaptiveKDTree::Plane::coord, ErrorCode, MB_SUCCESS, moab::Tree::moab(), moab::AdaptiveKDTree::Plane::norm, planeTag, and moab::Interface::tag_set_data().
Referenced by split_leaf().
ErrorCode moab::AdaptiveKDTree::sphere_intersect_triangles | ( | EntityHandle | tree_root, |
const double | center[3], | ||
double | radius, | ||
std::vector< EntityHandle > & | triangles | ||
) |
Definition at line 1801 of file AdaptiveKDTree.cpp.
References moab::Range::begin(), center(), moab::GeomUtil::closest_location_on_tri(), distance_search(), moab::Range::end(), ErrorCode, moab::Interface::get_connectivity(), moab::Interface::get_coords(), moab::Interface::get_entities_by_type(), MB_SUCCESS, MBTRI, and moab::Tree::moab().
ErrorCode moab::AdaptiveKDTree::split_leaf | ( | AdaptiveKDTreeIter & | leaf, |
Plane | plane | ||
) |
Split leaf of tree Updates iterator location to point to first new leaf node.
Definition at line 371 of file AdaptiveKDTree.cpp.
Referenced by build_tree(), and split_leaf().
ErrorCode moab::AdaptiveKDTree::split_leaf | ( | AdaptiveKDTreeIter & | 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 377 of file AdaptiveKDTree.cpp.
References children, moab::Interface::delete_entities(), ErrorCode, moab::AdaptiveKDTreeIter::handle(), MB_SUCCESS, moab::Tree::moab(), moab::Interface::remove_child_meshset(), and split_leaf().
ErrorCode moab::AdaptiveKDTree::split_leaf | ( | AdaptiveKDTreeIter & | 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 398 of file AdaptiveKDTree.cpp.
References children, moab::Interface::delete_entities(), ErrorCode, moab::AdaptiveKDTreeIter::handle(), MB_SUCCESS, moab::Tree::moab(), moab::Interface::remove_child_meshset(), and split_leaf().
ErrorCode moab::AdaptiveKDTree::split_leaf | ( | AdaptiveKDTreeIter & | 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 344 of file AdaptiveKDTree.cpp.
References children, moab::Interface::create_meshset(), moab::Interface::delete_entities(), ErrorCode, moab::AdaptiveKDTreeIter::handle(), moab::AdaptiveKDTreeIter::LEFT, MB_SUCCESS, moab::Tree::meshsetFlags, moab::Tree::moab(), set_split_plane(), and moab::AdaptiveKDTreeIter::step_to_first_leaf().
|
friend |
Definition at line 264 of file AdaptiveKDTree.hpp.
|
private |
Definition at line 331 of file AdaptiveKDTree.hpp.
Referenced by get_split_plane(), init(), make_tag(), and set_split_plane().
|
private |
Definition at line 335 of file AdaptiveKDTree.hpp.
Referenced by build_tree(), and parse_options().
|
private |
Definition at line 331 of file AdaptiveKDTree.hpp.
Referenced by get_split_plane(), init(), make_tag(), and set_split_plane().
|
private |
Definition at line 338 of file AdaptiveKDTree.hpp.
Referenced by build_tree(), intersect_children_with_elems(), and parse_options().
|
private |
Definition at line 337 of file AdaptiveKDTree.hpp.
Referenced by build_tree(), intersect_children_with_elems(), and parse_options().
|
private |
Definition at line 333 of file AdaptiveKDTree.hpp.
Referenced by build_tree(), and parse_options().
|
staticprivate |
Definition at line 329 of file AdaptiveKDTree.hpp.
Referenced by AdaptiveKDTree(), and init().