[MOAB-dev] r4230 - MOAB/trunk/test

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Wed Oct 20 18:04:37 CDT 2010


Author: kraftche
Date: 2010-10-20 18:04:37 -0500 (Wed, 20 Oct 2010)
New Revision: 4230

Modified:
   MOAB/trunk/test/MBTest.cpp
Log:
add test of face creation in get_adjacencies

Modified: MOAB/trunk/test/MBTest.cpp
===================================================================
--- MOAB/trunk/test/MBTest.cpp	2010-10-20 14:33:03 UTC (rev 4229)
+++ MOAB/trunk/test/MBTest.cpp	2010-10-20 23:04:37 UTC (rev 4230)
@@ -948,6 +948,86 @@
   return MB_SUCCESS;
 }
 
+ErrorCode mb_adjacent_create_test() 
+{
+  Core moab;
+  Interface& mb = moab;
+  ErrorCode rval;
+  
+    // create vertices
+  const double coords[][3] = 
+    { {-0.5, -0.5,  0.5 },
+      {-0.5, -0.5, -0.5 },
+      {-0.5,  0.5, -0.5 },
+      {-0.5,  0.5,  0.5 },
+      { 0.5, -0.5,  0.5 },
+      { 0.5, -0.5, -0.5 },
+      { 0.5,  0.5, -0.5 },
+      { 0.5,  0.5,  0.5 } };
+  EntityHandle verts[8] = {0};
+  for (int i = 0; i < 8; ++i) {
+    rval = mb.create_vertex( coords[i], verts[i] );
+    CHKERR(rval);
+  }
+    // create a single hex
+  const EntityHandle hconn[8] = { verts[0], verts[1], verts[2], verts[3], 
+                                  verts[4], verts[5], verts[6], verts[7] };
+  EntityHandle hex;
+  rval = mb.create_element( MBHEX, hconn, 8, hex );
+  CHKERR(rval);
+    // create hex faces
+  std::vector<EntityHandle> quads;
+  rval = mb.get_adjacencies( &hex, 1, 2, true, quads, Interface::UNION );
+  CHKERR(rval);
+  CHECK_EQUAL( (size_t)6, quads.size() );
+    // check that we got each of the 6 expected faces, with outwards
+    // normals assuming CCW order and correct connectivity
+  const EntityHandle faces[6][4] = {
+    { verts[0], verts[1], verts[5], verts[4] },
+    { verts[1], verts[2], verts[6], verts[5] },
+    { verts[2], verts[3], verts[7], verts[6] },
+    { verts[3], verts[0], verts[4], verts[7] },
+    { verts[3], verts[2], verts[1], verts[0] },
+    { verts[4], verts[5], verts[6], verts[7] } };
+  for (int i = 0; i < 6; ++i) { // for each expected face
+    // get sorted list of verts first for easy comparison


More information about the moab-dev mailing list