[MOAB-dev] r1856 - MOAB/trunk
kraftche at mcs.anl.gov
kraftche at mcs.anl.gov
Wed May 28 18:56:57 CDT 2008
Author: kraftche
Date: 2008-05-28 18:56:57 -0500 (Wed, 28 May 2008)
New Revision: 1856
Modified:
MOAB/trunk/GeomUtilTests.cpp
Log:
add tests for MBGeomUtil::box_hex_overlap
Modified: MOAB/trunk/GeomUtilTests.cpp
===================================================================
--- MOAB/trunk/GeomUtilTests.cpp 2008-05-28 23:56:31 UTC (rev 1855)
+++ MOAB/trunk/GeomUtilTests.cpp 2008-05-28 23:56:57 UTC (rev 1856)
@@ -706,7 +706,117 @@
ASSERT( box_linear_elem_overlap( coords, MBHEX, MBCartVect( 1,-1, 0 ), MBCartVect(0.75,0.75,0.5) ) );
}
+void test_box_hex_overlap()
+{
+ MBCartVect coords[8];
+ // test against axis-aligned rectilinear hex
+ coords[0] = MBCartVect(-0.5,-0.5,-0.5);
+ coords[1] = MBCartVect( 0.5,-0.5,-0.5);
+ coords[2] = MBCartVect( 0.5, 0.5,-0.5);
+ coords[3] = MBCartVect(-0.5, 0.5,-0.5);
+ coords[4] = MBCartVect(-0.5,-0.5, 0.5);
+ coords[5] = MBCartVect( 0.5,-0.5, 0.5);
+ coords[6] = MBCartVect( 0.5, 0.5, 0.5);
+ coords[7] = MBCartVect(-0.5, 0.5, 0.5);
+
+ ASSERT( box_hex_overlap( coords, MBCartVect( 0, 0, 0), MBCartVect(1,1,1) ) );
+
+ ASSERT( box_hex_overlap( coords, MBCartVect( 1, 0, 0), MBCartVect(1,1,1) ) );
+ ASSERT( box_hex_overlap( coords, MBCartVect( 0, 1, 0), MBCartVect(1,1,1) ) );
+ ASSERT( box_hex_overlap( coords, MBCartVect( 0, 0, 1), MBCartVect(1,1,1) ) );
+ ASSERT( box_hex_overlap( coords, MBCartVect(-1, 0, 0), MBCartVect(1,1,1) ) );
+ ASSERT( box_hex_overlap( coords, MBCartVect( 0,-1, 0), MBCartVect(1,1,1) ) );
+ ASSERT( box_hex_overlap( coords, MBCartVect( 0, 0,-1), MBCartVect(1,1,1) ) );
+
+ ASSERT( box_hex_overlap( coords, MBCartVect( 1, 1, 0), MBCartVect(1,1,1) ) );
+ ASSERT( box_hex_overlap( coords, MBCartVect(-1, 1, 0), MBCartVect(1,1,1) ) );
+ ASSERT( box_hex_overlap( coords, MBCartVect(-1,-1, 0), MBCartVect(1,1,1) ) );
+ ASSERT( box_hex_overlap( coords, MBCartVect( 1,-1, 0), MBCartVect(1,1,1) ) );
+ ASSERT( box_hex_overlap( coords, MBCartVect( 1, 0, 1), MBCartVect(1,1,1) ) );
+ ASSERT( box_hex_overlap( coords, MBCartVect(-1, 0, 1), MBCartVect(1,1,1) ) );
+ ASSERT( box_hex_overlap( coords, MBCartVect(-1, 0,-1), MBCartVect(1,1,1) ) );
+ ASSERT( box_hex_overlap( coords, MBCartVect( 1, 0,-1), MBCartVect(1,1,1) ) );
+ ASSERT( box_hex_overlap( coords, MBCartVect( 0, 1, 1), MBCartVect(1,1,1) ) );
+ ASSERT( box_hex_overlap( coords, MBCartVect( 0,-1, 1), MBCartVect(1,1,1) ) );
+ ASSERT( box_hex_overlap( coords, MBCartVect( 0,-1,-1), MBCartVect(1,1,1) ) );
+ ASSERT( box_hex_overlap( coords, MBCartVect( 0, 1,-1), MBCartVect(1,1,1) ) );
+
+ ASSERT( box_hex_overlap( coords, MBCartVect( 1, 1, 1), MBCartVect(1,1,1) ) );
+ ASSERT( box_hex_overlap( coords, MBCartVect(-1, 1, 1), MBCartVect(1,1,1) ) );
+ ASSERT( box_hex_overlap( coords, MBCartVect(-1,-1, 1), MBCartVect(1,1,1) ) );
+ ASSERT( box_hex_overlap( coords, MBCartVect( 1,-1, 1), MBCartVect(1,1,1) ) );
+ ASSERT( box_hex_overlap( coords, MBCartVect( 1, 1,-1), MBCartVect(1,1,1) ) );
+ ASSERT( box_hex_overlap( coords, MBCartVect(-1, 1,-1), MBCartVect(1,1,1) ) );
+ ASSERT( box_hex_overlap( coords, MBCartVect(-1,-1,-1), MBCartVect(1,1,1) ) );
+ ASSERT( box_hex_overlap( coords, MBCartVect( 1,-1,-1), MBCartVect(1,1,1) ) );
+
+ ASSERT(!box_hex_overlap( coords, MBCartVect( 3, 0, 0), MBCartVect(1,1,1) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect( 0, 3, 0), MBCartVect(1,1,1) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect( 0, 0, 3), MBCartVect(1,1,1) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect(-3, 0, 0), MBCartVect(1,1,1) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect( 0,-3, 0), MBCartVect(1,1,1) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect( 0, 0,-3), MBCartVect(1,1,1) ) );
+
+ ASSERT(!box_hex_overlap( coords, MBCartVect( 3, 3, 0), MBCartVect(1,1,1) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect(-3, 3, 0), MBCartVect(1,1,1) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect(-3,-3, 0), MBCartVect(1,1,1) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect( 3,-3, 0), MBCartVect(1,1,1) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect( 3, 0, 3), MBCartVect(1,1,1) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect(-3, 0, 3), MBCartVect(1,1,1) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect(-3, 0,-3), MBCartVect(1,1,1) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect( 3, 0,-3), MBCartVect(1,1,1) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect( 0, 3, 3), MBCartVect(1,1,1) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect( 0,-3, 3), MBCartVect(1,1,1) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect( 0,-3,-3), MBCartVect(1,1,1) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect( 0, 3,-3), MBCartVect(1,1,1) ) );
+
+ ASSERT(!box_hex_overlap( coords, MBCartVect( 3, 3, 3), MBCartVect(1,1,1) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect(-3, 3, 3), MBCartVect(1,1,1) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect(-3,-3, 3), MBCartVect(1,1,1) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect( 3,-3, 3), MBCartVect(1,1,1) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect( 3, 3,-3), MBCartVect(1,1,1) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect(-3, 3,-3), MBCartVect(1,1,1) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect(-3,-3,-3), MBCartVect(1,1,1) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect( 3,-3,-3), MBCartVect(1,1,1) ) );
+
+ // test against rectilinear hex rotated 45 degrees about z axis
+ const double r = sqrt(2.0)/2.0;
+ coords[0] = MBCartVect( r, 0,-0.5);
+ coords[1] = MBCartVect( 0, r,-0.5);
+ coords[2] = MBCartVect(-r, 0,-0.5);
+ coords[3] = MBCartVect( 0,-r,-0.5);
+ coords[4] = MBCartVect( r, 0, 0.5);
+ coords[5] = MBCartVect( 0, r, 0.5);
+ coords[6] = MBCartVect(-r, 0, 0.5);
+ coords[7] = MBCartVect( 0,-r, 0.5);
+
+ ASSERT( box_hex_overlap( coords, MBCartVect( 1, 0, 0 ), MBCartVect(0.5,0.5,0.5) ) );
+ ASSERT( box_hex_overlap( coords, MBCartVect(-1, 0, 0 ), MBCartVect(0.5,0.5,0.5) ) );
+ ASSERT( box_hex_overlap( coords, MBCartVect( 0, 1, 0 ), MBCartVect(0.5,0.5,0.5) ) );
+ ASSERT( box_hex_overlap( coords, MBCartVect( 0,-1, 0 ), MBCartVect(0.5,0.5,0.5) ) );
+
+ ASSERT(!box_hex_overlap( coords, MBCartVect( 1, 0, 2 ), MBCartVect(0.5,0.5,0.5) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect(-1, 0, 2 ), MBCartVect(0.5,0.5,0.5) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect( 0, 1, 2 ), MBCartVect(0.5,0.5,0.5) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect( 0,-1, 2 ), MBCartVect(0.5,0.5,0.5) ) );
+
+ ASSERT(!box_hex_overlap( coords, MBCartVect( 2, 0, 0 ), MBCartVect(0.5,0.5,0.5) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect(-2, 0, 0 ), MBCartVect(0.5,0.5,0.5) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect( 0, 2, 0 ), MBCartVect(0.5,0.5,0.5) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect( 0,-2, 0 ), MBCartVect(0.5,0.5,0.5) ) );
+
+ ASSERT(!box_hex_overlap( coords, MBCartVect( 1, 1, 0 ), MBCartVect(0.5,0.5,0.5) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect(-1, 1, 0 ), MBCartVect(0.5,0.5,0.5) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect(-1,-1, 0 ), MBCartVect(0.5,0.5,0.5) ) );
+ ASSERT(!box_hex_overlap( coords, MBCartVect( 1,-1, 0 ), MBCartVect(0.5,0.5,0.5) ) );
+
+ ASSERT( box_hex_overlap( coords, MBCartVect( 1, 1, 0 ), MBCartVect(0.75,0.75,0.5) ) );
+ ASSERT( box_hex_overlap( coords, MBCartVect(-1, 1, 0 ), MBCartVect(0.75,0.75,0.5) ) );
+ ASSERT( box_hex_overlap( coords, MBCartVect(-1,-1, 0 ), MBCartVect(0.75,0.75,0.5) ) );
+ ASSERT( box_hex_overlap( coords, MBCartVect( 1,-1, 0 ), MBCartVect(0.75,0.75,0.5) ) );
+}
+
void test_ray_tri_intersect()
{
bool xsect;
@@ -1133,6 +1243,7 @@
int error_count = 0;
error_count += RUN_TEST(test_box_plane_overlap);
error_count += RUN_TEST(test_box_tri_overlap);
+ error_count += RUN_TEST(test_box_hex_overlap);
error_count += RUN_TEST(test_box_linear_elem_overlap_tri);
error_count += RUN_TEST(test_box_linear_elem_overlap_hex);
error_count += RUN_TEST(test_ray_tri_intersect);
More information about the moab-dev
mailing list