[MOAB-dev] r5509 - in MOAB/trunk: src src/moab tools/mbcoupler
tautges at mcs.anl.gov
tautges at mcs.anl.gov
Sat Apr 28 11:23:46 CDT 2012
Author: tautges
Date: 2012-04-28 11:23:46 -0500 (Sat, 28 Apr 2012)
New Revision: 5509
Modified:
MOAB/trunk/src/AdaptiveKDTree.cpp
MOAB/trunk/src/moab/AdaptiveKDTree.hpp
MOAB/trunk/tools/mbcoupler/Coupler.cpp
MOAB/trunk/tools/mbcoupler/Coupler.hpp
Log:
In AdaptiveKDTree, adding capability to get distances out of leaves_within_distance.
In Coupler, adding ability to specify absolute and relative distance tolerances to
locate_points; if relative tolerance is specified, absolute tolerance is computed as relative
tolerance times the box diagonal or the root box.
Modified: MOAB/trunk/src/AdaptiveKDTree.cpp
===================================================================
--- MOAB/trunk/src/AdaptiveKDTree.cpp 2012-04-28 04:02:25 UTC (rev 5508)
+++ MOAB/trunk/src/AdaptiveKDTree.cpp 2012-04-28 16:23:46 UTC (rev 5509)
@@ -1445,7 +1445,7 @@
ErrorCode AdaptiveKDTree::leaf_containing_point( EntityHandle tree_root,
const double point[3],
- EntityHandle& leaf_out )
+ EntityHandle& leaf_out)
{
std::vector<EntityHandle> children;
Plane plane;
@@ -1527,11 +1527,12 @@
ErrorCode AdaptiveKDTree::leaves_within_distance( EntityHandle tree_root,
const double from_point[3],
const double distance,
- std::vector<EntityHandle>& result_list )
+ std::vector<EntityHandle>& result_list,
+ std::vector<double> *result_dists)
{
const double dist_sqr = distance * distance;
const CartVect from(from_point);
- std::vector<NodeDistance> list; // list of subtrees to traverse
+ std::vector<NodeDistance> list, result_list_nodes; // list of subtrees to traverse, and results
// pre-allocate space for default max tree depth
Settings tmp_settings;
list.reserve( tmp_settings.maxTreeDepth );
@@ -1573,7 +1574,7 @@
children.clear();
rval = moab()->get_child_meshsets( node.handle, children );
if (children.empty()) {
- result_list.push_back( node.handle );
+ result_list_nodes.push_back( node);
continue;
}
@@ -1616,6 +1617,19 @@
}
}
+ // separate loops to avoid if test inside loop
+ result_list.reserve(result_list_nodes.size());
+ for (std::vector<NodeDistance>::iterator vit = result_list_nodes.begin();
+ vit != result_list_nodes.end(); vit++)
+ result_list.push_back((*vit).handle);
+
+ if (result_dists && distance > 0.0) {
+ result_dists->reserve(result_list_nodes.size());
+ for (std::vector<NodeDistance>::iterator vit = result_list_nodes.begin();
+ vit != result_list_nodes.end(); vit++)
More information about the moab-dev
mailing list