[MOAB-dev] r2889 - MOAB/trunk
kraftche at cae.wisc.edu
kraftche at cae.wisc.edu
Sat May 16 15:09:02 CDT 2009
Author: kraftche
Date: 2009-05-16 15:09:01 -0500 (Sat, 16 May 2009)
New Revision: 2889
Modified:
MOAB/trunk/MBBSPTree.cpp
MOAB/trunk/MBBSPTree.hpp
MOAB/trunk/bsp_tree_test.cpp
Log:
add neighbor query for BSP trees for which every leaf is a box
Modified: MOAB/trunk/MBBSPTree.cpp
===================================================================
--- MOAB/trunk/MBBSPTree.cpp 2009-05-16 20:08:25 UTC (rev 2888)
+++ MOAB/trunk/MBBSPTree.cpp 2009-05-16 20:09:01 UTC (rev 2889)
@@ -541,6 +541,62 @@
return (MBBSPTreeBoxIter::SideBits)result;
}
+static inline void copy_coords( const double src[3], double dest[3] )
+{
+ dest[0] = src[0];
+ dest[1] = src[1];
+ dest[2] = src[2];
+}
+
+MBErrorCode MBBSPTreeBoxIter::face_corners( const SideBits face,
+ const double hex_corners[8][3],
+ double face_corners[4][3] )
+{
+ switch (face) {
+ case MBBSPTreeBoxIter::B0154:
+ copy_coords( hex_corners[0], face_corners[0] );
+ copy_coords( hex_corners[1], face_corners[1] );
+ copy_coords( hex_corners[5], face_corners[2] );
+ copy_coords( hex_corners[4], face_corners[3] );
+ break;
+ case MBBSPTreeBoxIter::B1265:
+ copy_coords( hex_corners[1], face_corners[0] );
+ copy_coords( hex_corners[2], face_corners[1] );
+ copy_coords( hex_corners[6], face_corners[2] );
+ copy_coords( hex_corners[5], face_corners[3] );
+ break;
+ case MBBSPTreeBoxIter::B2376:
+ copy_coords( hex_corners[2], face_corners[0] );
+ copy_coords( hex_corners[3], face_corners[1] );
+ copy_coords( hex_corners[7], face_corners[2] );
+ copy_coords( hex_corners[6], face_corners[3] );
+ break;
+ case MBBSPTreeBoxIter::B3047:
+ copy_coords( hex_corners[3], face_corners[0] );
+ copy_coords( hex_corners[0], face_corners[1] );
+ copy_coords( hex_corners[4], face_corners[2] );
+ copy_coords( hex_corners[7], face_corners[3] );
+ break;
+ case MBBSPTreeBoxIter::B3210:
+ copy_coords( hex_corners[3], face_corners[0] );
+ copy_coords( hex_corners[2], face_corners[1] );
+ copy_coords( hex_corners[1], face_corners[2] );
+ copy_coords( hex_corners[0], face_corners[3] );
+ break;
+ case MBBSPTreeBoxIter::B4567:
+ copy_coords( hex_corners[4], face_corners[0] );
+ copy_coords( hex_corners[5], face_corners[1] );
+ copy_coords( hex_corners[6], face_corners[2] );
+ copy_coords( hex_corners[7], face_corners[3] );
+ break;
+ default:
+ return MB_FAILURE; // child is not a box
+ }
+
+ return MB_SUCCESS;
+
+}
+
/** \brief Clip an edge using a plane
*
* Given an edge from keep_end_coords to cut_end_coords,
@@ -846,6 +902,113 @@
return MB_SUCCESS;
}
+MBErrorCode MBBSPTreeBoxIter::get_neighbors(
+ SideBits side,
+ std::vector<MBBSPTreeBoxIter>& results,
+ double epsilon ) const
+{
+ MBEntityHandle handle;
+ MBBSPTree::Plane plane;
+ MBErrorCode rval;
+ int n;
+
+ Corners face;
+ rval = face_corners( side, leafCoords, face.coords );
+ if (MB_SUCCESS != rval)
+ return rval;
+
+ // Move up tree until we find the split that created the specified side.
+ // Push the sibling at that level onto the iterator stack as
+ // all neighbors will be rooted at that node.
+ MBBSPTreeBoxIter iter( *this ); // temporary iterator (don't modifiy *this)
+ for (;;) {
+ handle = iter.handle();
+
+ rval = iter.up();
+ if (MB_SUCCESS != rval) // reached root - no neighbors on that side
+ return (rval == MB_ENTITY_NOT_FOUND) ? MB_SUCCESS : rval;
+
+ iter.childVect.clear();
+ rval = tool()->moab()->get_child_meshsets( iter.handle(), iter.childVect );
+ if (MB_SUCCESS!= rval)
+ return rval;
+
+ rval = tool()->get_split_plane( iter.handle(), plane );
+ if (MB_SUCCESS != rval)
+ return rval;
+ SideBits s = side_above_plane( iter.leafCoords, plane );
+
+ if (handle == iter.childVect[0] && s == side) {
+ rval = iter.down( plane, RIGHT );
+ if (MB_SUCCESS != rval)
+ return rval;
+ break;
+ }
+ else if (handle == iter.childVect[1] && opposite_face(s) == side) {
+ rval = iter.down( plane, LEFT );
+ if (MB_SUCCESS != rval)
+ return rval;
+ break;
+ }
+ }
+
+ // now move down tree, searching for adjacent boxes
+ std::vector<MBBSPTreeBoxIter> list;
+ // loop over all potential paths to neighbors (until list is empty)
+ for (;;) {
+ // follow a single path to a leaf, append any other potential
+ // paths to neighbors to 'list'
+ for (;;) {
+ rval = tool()->moab()->num_child_meshsets( iter.handle(), &n );
+ if (MB_SUCCESS != rval)
+ return rval;
+
+ // if leaf
+ if (!n) {
+ results.push_back( iter );
+ break;
+ }
+
+ rval = tool()->get_split_plane( iter.handle(), plane );
+ if (MB_SUCCESS != rval)
+ return rval;
+
+ bool some_above = false, some_below = false;
+ for (int i = 0; i < 4; ++i) {
+ double signed_d = plane.signed_distance( face.coords[i] );
+ if (signed_d > -epsilon)
+ some_above = true;
+ if (signed_d < epsilon)
+ some_below = true;
+ }
+
+ if (some_above && some_below) {
+ list.push_back( iter );
+ list.back().down( plane, RIGHT );
+ iter.down( plane, LEFT );
+ }
+ else if (some_above) {
+ iter.down( plane, RIGHT );
+ }
+ else if (some_below) {
+ iter.down( plane, LEFT );
+ }
+ else {
+ // tolerance issue -- epsilon to small? 2D box?
+ return MB_FAILURE;
+ }
+ }
+
+ if (list.empty())
+ break;
+
+ iter = list.back();
+ list.pop_back();
+ }
+
+ return MB_SUCCESS;
+}
+
MBErrorCode MBBSPTree::leaf_containing_point( MBEntityHandle tree_root,
const double point[3],
MBEntityHandle& leaf_out )
Modified: MOAB/trunk/MBBSPTree.hpp
===================================================================
--- MOAB/trunk/MBBSPTree.hpp 2009-05-16 20:08:25 UTC (rev 2888)
+++ MOAB/trunk/MBBSPTree.hpp 2009-05-16 20:09:01 UTC (rev 2889)
@@ -304,6 +304,10 @@
static SideBits opposite_face( const SideBits& bits )
{ return (SideBits)((~bits) & 0xFF); }
+ static MBErrorCode face_corners( const SideBits face,
+ const double hex_corners[8][3],
+ double face_corners_out[4][3] );
+
//! Advance the iterator either left or right in the tree
//! Note: stepping past the end of the tree will invalidate
//! the iterator. It will *not* work to subsequently
@@ -335,6 +339,22 @@
//! MB_SUCCESS otherwise.
MBErrorCode sibling_side( SideBits& side_out ) const;
+ //! Get adjacent leaf nodes on indicated side
+ //!
+ //!\param side Face of box for which to retrieve neighbors
+ //!\param results List to which to append results. This function does
+ //! *not* clear existing values in list.
+ //!\param epsilon Tolerance on overlap. A positive value E will
+ //! result in nodes that are separated by as much as E
+ //! to be considered touching. A negative value -E will
+ //! cause leaves that do not overlap by at least E to be
+ //! considered non-overlapping. Amongst other things,
+ //! this value can be used to control whether or not
+ //! leaves adjacent at only their edges or corners are
+ //! returned.
+ MBErrorCode get_neighbors( SideBits side,
+ std::vector<MBBSPTreeBoxIter>& results,
+ double epsilon = 0.0 ) const;
};
#endif
Modified: MOAB/trunk/bsp_tree_test.cpp
===================================================================
--- MOAB/trunk/bsp_tree_test.cpp 2009-05-16 20:08:25 UTC (rev 2888)
+++ MOAB/trunk/bsp_tree_test.cpp 2009-05-16 20:09:01 UTC (rev 2889)
@@ -1,6 +1,7 @@
#include "MBCore.hpp"
#include "TestUtil.hpp"
#include "MBBSPTree.hpp"
+#include <algorithm>
void test_set_plane();
void test_iterator();
@@ -10,6 +11,7 @@
void test_leaf_containing_point_bounded_tree();
void test_leaf_containing_point_unbounded_tree();
void test_merge_leaf();
+void test_box_iter_neighbors();
int main()
{
@@ -23,6 +25,7 @@
failures += RUN_TEST( test_leaf_containing_point_bounded_tree );
failures += RUN_TEST( test_leaf_containing_point_unbounded_tree );
failures += RUN_TEST( test_merge_leaf );
+ failures += RUN_TEST( test_box_iter_neighbors );
return failures;
}
@@ -1113,3 +1116,347 @@
CHECK_EQUAL( MB_ENTITY_NOT_FOUND, rval );
}
+static std::vector<int>
+neighbors( const MBBSPTreeBoxIter& iter,
+ const MBEntityHandle leaves[8],
+ MBBSPTreeBoxIter::SideBits side,
+ double epsilon )
+{
+ std::vector<MBBSPTreeBoxIter> list;
+ MBErrorCode rval = iter.get_neighbors( side, list, epsilon );
+ CHECK_ERR(rval);
+
+ std::vector<int> results;
+ for (size_t i = 0; i < list.size(); ++i)
+ results.push_back( std::find( leaves, leaves+8, list[i].handle() ) - leaves );
+ std::sort( results.begin(), results.end() );
+ return results;
+}
+
+void test_box_iter_neighbors()
+{
+ MBCore moab;
+ MBBSPTree tool( &moab );
+ MBErrorCode rval;
+ MBEntityHandle root;
+ MBBSPTreeBoxIter iter;
+ MBBSPTree::Plane p;
+
+
+/* Build Tree */
+
+
+ const double corners[8][3] = { { 0, 0, 0 },
+ { 8, 0, 0 },
+ { 8, 2, 0 },
+ { 0, 2, 0 },
+ { 0, 0, 1 },
+ { 8, 0, 1 },
+ { 8, 2, 1 },
+ { 0, 2, 1 } };
+ rval = tool.create_tree( corners, root );
+ CHECK_ERR(rval);
+ rval = tool.get_tree_iterator( root, iter );
+ CHECK_ERR(rval);
+ MBEntityHandle leaves[8];
+
+ /* +----------------------------------------+
+ | |
+ | 0* |
+ | |
+ +----------------------------------------+ */
+
+ p = MBBSPTree::Plane( 1, 0, 0, -4 );
+ rval = tool.split_leaf( iter, p );
+ CHECK_ERR(rval);
+
+ /* +-------------------+--------------------+
+ | | |
+ | 0* | 1 |
+ | | |
+ +----------------------------------------+ */
+
+ p = MBBSPTree::Plane( -1, 0, 0, 2 );
+ rval = tool.split_leaf( iter, p );
+ CHECK_ERR(rval);
+
+ /* +---------+---------+--------------------+
+ | | | |
+ | 1 | 0* | 2 |
+ | | | |
+ +----------------------------------------+ */
+
+ p = MBBSPTree::Plane( 0, 1, 0, -1 );
+ rval = tool.split_leaf( iter, p );
+ CHECK_ERR(rval);
+
+ /* +---------+---------+--------------------+
+ | | 1 | |
+ | 2 +---------+ 3 |
+ | | 0* | |
+ +----------------------------------------+ */
+
+ leaves[0] = iter.handle();
+ rval = iter.step(); CHECK_ERR(rval);
+ leaves[1] = iter.handle();
+ rval = iter.step(); CHECK_ERR(rval);
+
+ /* +---------+---------+--------------------+
+ | | 1 | |
+ | 2* +---------+ 3 |
+ | | 0 | |
+ +----------------------------------------+ */
+
+ p = MBBSPTree::Plane( 0, -1, 0, 1 );
+ rval = tool.split_leaf( iter, p );
+ CHECK_ERR(rval);
+
+ /* +---------+---------+--------------------+
+ | 2* | 1 | |
+ +---------+---------+ 4 |
+ | 3 | 0 | |
+ +----------------------------------------+ */
+
+ leaves[2] = iter.handle();
+ rval = iter.step(); CHECK_ERR(rval);
+ leaves[3] = iter.handle();
+ rval = iter.step(); CHECK_ERR(rval);
+
+ /* +---------+---------+--------------------+
+ | 2 | 1 | |
+ +---------+---------+ 4* |
+ | 3 | 0 | |
+ +----------------------------------------+ */
+
+ p = MBBSPTree::Plane( 0, 1, 0, -1 );
+ rval = tool.split_leaf( iter, p );
+ CHECK_ERR(rval);
+
+ /* +---------+---------+--------------------+
+ | 2 | 1 | 5 |
+ +---------+---------+--------------------+
+ | 3 | 0 | 4* |
+ +----------------------------------------+ */
+
+ p = MBBSPTree::Plane( 1, 0, 0, -6 );
+ rval = tool.split_leaf( iter, p );
+ CHECK_ERR(rval);
+
+ /* +---------+---------+--------------------+
+ | 2 | 1 | 6 |
+ +---------+---------+----------+---------+
+ | 3 | 0 | 4* | 5 |
+ +------------------------------+---------+ */
+
+ leaves[4] = iter.handle();
+ rval = iter.step(); CHECK_ERR(rval);
+ leaves[5] = iter.handle();
+ rval = iter.step(); CHECK_ERR(rval);
+
+ /* +---------+---------+--------------------+
+ | 2 | 1 | 6* |
+ +---------+---------+----------+---------+
+ | 3 | 0 | 4 | 5 |
+ +------------------------------+---------+ */
+
+ p = MBBSPTree::Plane( -1, 0, 0, 6 );
+ rval = tool.split_leaf( iter, p );
+ CHECK_ERR(rval);
+
+ /* +---------+---------+--------------------+
+ | 2 | 1 | 7 | 6 |
+ +---------+---------+----------+---------+
+ | 3 | 0 | 4 | 5 |
+ +------------------------------+---------+ */
+
+ leaves[6] = iter.handle();
+ rval = iter.step(); CHECK_ERR(rval);
+ leaves[7] = iter.handle();
+
+
+ /* check all neighbors of each leaf */
+
+ rval = tool.get_tree_iterator( root, iter );
+ CHECK_ERR(rval);
+
+ // NOTE: Several values in the expected result list are
+ // commented out in the tests below. When the tolerance
+ // is greater than zero, the search algorithm may or may
+ // not return leaves that are not face-adjacent (e.g. adjacent
+ // only along edges or at corners.) The determining factor
+ // for whether or not such a neighbor is returned is which
+ // sub-tree from the split that defined the source leaf side
+ // the neighbor is on. The algorithm will not search the subtree
+ // of the split that created the side and that contains the
+ // source leaf.
+
+
+ // check neighbors of leaf 0
+ std::vector<int> expected;
+ CHECK_EQUAL( leaves[0], iter.handle() );
+ expected.clear();
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B0154, 1e-6 ) );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B3210, 1e-6 ) );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B4567, 1e-6 ) );
+ expected.push_back( 3 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B3047, -1e-6 ) );
+ expected.insert( expected.begin(), 2 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B3047, 1e-6 ) );
+ expected.clear(); expected.push_back( 1 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B2376, -1e-6 ) );
+ // See NOTE // expected.push_back( 2 ); expected.push_back( 7 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B2376, 1e-6 ) );
+ expected.clear(); expected.push_back( 4 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B1265, -1e-6 ) );
+ expected.push_back( 7 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B1265, 1e-6 ) );
+
+ // check neighbors of leaf 1
+ CHECK_ERR( iter.step() );
+ CHECK_EQUAL( leaves[1], iter.handle() );
+ expected.clear();
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B2376, 1e-6 ) );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B3210, 1e-6 ) );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B4567, 1e-6 ) );
+ expected.push_back( 2 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B3047, -1e-6 ) );
+ expected.push_back( 3 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B3047, 1e-6 ) );
+ expected.clear(); expected.push_back( 0 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B0154, -1e-6 ) );
+ // See NOTE // expected.push_back( 3 ); expected.push_back( 4 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B0154, 1e-6 ) );
+ expected.clear(); expected.push_back( 7 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B1265, -1e-6 ) );
+ expected.insert( expected.begin(), 4 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B1265, 1e-6 ) );
+
+ /* +---------+---------+--------------------+
+ | 2 | 1 | 7 | 6 |
+ +---------+---------+----------+---------+
+ | 3 | 0 | 4 | 5 |
+ +------------------------------+---------+ */
+
+ // check neighbors of leaf 2
+ CHECK_ERR( iter.step() );
+ CHECK_EQUAL( leaves[2], iter.handle() );
+ expected.clear();
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B2376, 1e-6 ) );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B3047, 1e-6 ) );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B3210, 1e-6 ) );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B4567, 1e-6 ) );
+ expected.push_back( 3 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B0154, -1e-6 ) );
+ // See NOTE // expected.insert( expected.begin(), 0 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B0154, 1e-6 ) );
+ expected.clear(); expected.push_back( 1 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B1265, -1e-6 ) );
+ expected.insert( expected.begin(), 0 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B1265, 1e-6 ) );
+
+ // check neighbors of leaf 3
+ CHECK_ERR( iter.step() );
+ CHECK_EQUAL( leaves[3], iter.handle() );
+ expected.clear();
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B0154, 1e-6 ) );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B3047, 1e-6 ) );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B3210, 1e-6 ) );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B4567, 1e-6 ) );
+ expected.push_back( 2 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B2376, -1e-6 ) );
+ // See NOTE // expected.insert( expected.begin(), 1 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B2376, 1e-6 ) );
+ expected.clear(); expected.push_back( 0 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B1265, -1e-6 ) );
+ expected.push_back( 1 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B1265, 1e-6 ) );
+
+ /* +---------+---------+--------------------+
+ | 2 | 1 | 7 | 6 |
+ +---------+---------+----------+---------+
+ | 3 | 0 | 4 | 5 |
+ +------------------------------+---------+ */
+
+ // check neighbors of leaf 4
+ CHECK_ERR( iter.step() );
+ CHECK_EQUAL( leaves[4], iter.handle() );
+ expected.clear();
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B0154, 1e-6 ) );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B3210, 1e-6 ) );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B4567, 1e-6 ) );
+ expected.push_back( 0 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B3047, -1e-6 ) );
+ expected.push_back( 1 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B3047, 1e-6 ) );
+ expected.clear(); expected.push_back( 7 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B2376, -1e-6 ) );
+ expected.insert( expected.begin(), 6 );
+ // See NOTE // expected.insert( expected.begin(), 1 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B2376, 1e-6 ) );
+ expected.clear(); expected.push_back( 5 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B1265, -1e-6 ) );
+ // See NOTE // expected.push_back( 6 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B1265, 1e-6 ) );
+
+ // check neighbors of leaf 5
+ CHECK_ERR( iter.step() );
+ CHECK_EQUAL( leaves[5], iter.handle() );
+ expected.clear();
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B0154, 1e-6 ) );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B1265, 1e-6 ) );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B3210, 1e-6 ) );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B4567, 1e-6 ) );
+ expected.push_back( 4 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B3047, -1e-6 ) );
+ // See NOTE // expected.push_back( 7 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B3047, 1e-6 ) );
+ expected.clear(); expected.push_back( 6 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B2376, -1e-6 ) );
+ expected.push_back( 7 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B2376, 1e-6 ) );
+
+ /* +---------+---------+--------------------+
+ | 2 | 1 | 7 | 6 |
+ +---------+---------+----------+---------+
+ | 3 | 0 | 4 | 5 |
+ +------------------------------+---------+ */
+
+ // check neighbors of leaf 6
+ CHECK_ERR( iter.step() );
+ CHECK_EQUAL( leaves[6], iter.handle() );
+ expected.clear();
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B2376, 1e-6 ) );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B1265, 1e-6 ) );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B3210, 1e-6 ) );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B4567, 1e-6 ) );
+ expected.push_back( 7 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B3047, -1e-6 ) );
+ // See NOTE // expected.insert( expected.begin(), 4 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B3047, 1e-6 ) );
+ expected.clear(); expected.push_back( 5 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B0154, -1e-6 ) );
+ expected.insert( expected.begin(), 4 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B0154, 1e-6 ) );
+
+ // check neighbors of leaf 7
+ CHECK_ERR( iter.step() );
+ CHECK_EQUAL( leaves[7], iter.handle() );
+ expected.clear();
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B2376, 1e-6 ) );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B3210, 1e-6 ) );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B4567, 1e-6 ) );
+ expected.push_back( 1 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B3047, -1e-6 ) );
+ expected.insert( expected.begin(), 0 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B3047, 1e-6 ) );
+ expected.clear(); expected.push_back( 4 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B0154, -1e-6 ) );
+ // See NOTE // expected.insert( expected.begin(), 0 );
+ expected.push_back( 5 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B0154, 1e-6 ) );
+ expected.clear(); expected.push_back( 6 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B1265, -1e-6 ) );
+ // See NOTE // expected.insert( expected.begin(), 5 );
+ CHECK_EQUAL( expected, neighbors( iter, leaves, MBBSPTreeBoxIter::B1265, 1e-6 ) );
+}
+
More information about the moab-dev
mailing list