[MOAB-dev] r1232 - MOAB/trunk
kraftche at mcs.anl.gov
kraftche at mcs.anl.gov
Mon Aug 13 17:24:33 CDT 2007
Author: kraftche
Date: 2007-08-13 17:24:33 -0500 (Mon, 13 Aug 2007)
New Revision: 1232
Modified:
MOAB/trunk/MBAdaptiveKDTree.cpp
MOAB/trunk/MBAdaptiveKDTree.hpp
Log:
add method to query sibling of current iterator position
Modified: MOAB/trunk/MBAdaptiveKDTree.cpp
===================================================================
--- MOAB/trunk/MBAdaptiveKDTree.cpp 2007-08-12 14:44:06 UTC (rev 1231)
+++ MOAB/trunk/MBAdaptiveKDTree.cpp 2007-08-13 22:24:33 UTC (rev 1232)
@@ -633,6 +633,31 @@
return MB_SUCCESS;
}
+MBErrorCode MBAdaptiveKDTreeIter::sibling_side(
+ MBAdaptiveKDTree::Axis& axis_out,
+ bool& neg_out ) const
+{
+ if (mStack.size() < 2) // at tree root
+ return MB_ENTITY_NOT_FOUND;
+
+ MBEntityHandle parent = mStack[mStack.size()-2].entity;
+ MBAdaptiveKDTree::Plane plane;
+ MBErrorCode rval = tool()->get_split_plane( parent, plane );
+ if (MB_SUCCESS != rval)
+ return MB_FAILURE;
+
+ childVect.clear();
+ rval = tool()->moab()->get_child_meshsets( parent, childVect );
+ if (MB_SUCCESS != rval || childVect.size() != 2)
+ return MB_FAILURE;
+
+ axis_out = static_cast<MBAdaptiveKDTree::Axis>(plane.norm);
+ neg_out = (childVect[1] == handle());
+ assert(childVect[neg_out] == handle());
+ return MB_SUCCESS;
+}
+
+
static MBErrorCode intersect_children_with_elems( MBInterface* moab,
const MBRange& elems,
MBAdaptiveKDTree::Plane plane,
Modified: MOAB/trunk/MBAdaptiveKDTree.hpp
===================================================================
--- MOAB/trunk/MBAdaptiveKDTree.hpp 2007-08-12 14:44:06 UTC (rev 1231)
+++ MOAB/trunk/MBAdaptiveKDTree.hpp 2007-08-13 22:24:33 UTC (rev 1232)
@@ -54,10 +54,10 @@
};
//! Get split plane for tree node
- MBErrorCode get_split_plane( MBEntityHandle entity, Plane& plane );
+ MBErrorCode get_split_plane( MBEntityHandle node, Plane& plane );
//! Set split plane for tree node
- MBErrorCode set_split_plane( MBEntityHandle entity, const Plane& plane );
+ MBErrorCode set_split_plane( MBEntityHandle node, const Plane& plane );
//! Get bounding box for entire tree
MBErrorCode get_tree_box( MBEntityHandle root_node,
@@ -209,7 +209,7 @@
double mBox[2][3]; //!< min and max corners of bounding box
MBAdaptiveKDTree* treeTool; //!< tool for tree
std::vector<StackObj> mStack; //!< stack storing path through tree
- std::vector<MBEntityHandle> childVect; //!< tempory storage of child handles
+ mutable std::vector<MBEntityHandle> childVect; //!< tempory storage of child handles
//! Descend tree to left most leaf from current position
//! No-op if at leaf.
@@ -247,6 +247,20 @@
//! Advance to next leaf
//! Returns MB_ENTITY_NOT_FOUND if at end.
MBErrorCode step();
+
+ //! 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.)
+ //!
+ //!\param axis_out The principal axis orthogonal to the side of the box
+ //!\param 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.
+ //!\return MB_ENTITY_NOT FOUND if root node.
+ //! MB_FAILURE if internal error.
+ //! MB_SUCCESS otherwise.
+ MBErrorCode sibling_side( MBAdaptiveKDTree::Axis& axis_out, bool& neg_out ) const;
//! Get adjacent leaf nodes on side indicated by norm and neg.
//!
More information about the moab-dev
mailing list