[MOAB-dev] r1376 - in MOAB/trunk/test: . h5file

kraftche at mcs.anl.gov kraftche at mcs.anl.gov
Fri Nov 9 17:22:18 CST 2007


Author: kraftche
Date: 2007-11-09 17:22:17 -0600 (Fri, 09 Nov 2007)
New Revision: 1376

Added:
   MOAB/trunk/test/h5file/h5legacy.cpp
   MOAB/trunk/test/v3_dodec.h5m
Modified:
   MOAB/trunk/test/h5file/Makefile.am
Log:
add test for ready MOAB v3.0 format .h5m poly data

Modified: MOAB/trunk/test/h5file/Makefile.am
===================================================================
--- MOAB/trunk/test/h5file/Makefile.am	2007-11-09 23:20:08 UTC (rev 1375)
+++ MOAB/trunk/test/h5file/Makefile.am	2007-11-09 23:22:17 UTC (rev 1376)
@@ -1,14 +1,13 @@
 DEFS = $(DEFINES)
 INCLUDES += -I$(top_srcdir) -I$(top_srcdir)/mhdf/include -I$(top_builddir)
-check_PROGRAMS = h5test
+check_PROGRAMS = h5test h5legacy
 if PARALLEL_HDF5
   check_PROGRAMS += parallel
   INCLUDES += -I$(top_srcdir)/parallel
 endif
+TESTS = $(check_PROGRAMS)
+
+LDADD = $(top_builddir)/libMOAB.la
 h5test_SOURCES = h5file_test.cpp
-h5test_LDADD = $(top_builddir)/libMOAB.la
-h5test_DEPENDENCIES = $(top_builddir)/libMOAB.la
+h5legacy_SOURCES = h5legacy.cpp
 parallel_SOURCES = parallel.cpp
-parallel_LDADD = $(top_builddir)/libMOAB.la
-parallel_DEPENDENCIES = $(top_builddir)/libMOAB.la
-TESTS = $(check_PROGRAMS)

Added: MOAB/trunk/test/h5file/h5legacy.cpp
===================================================================
--- MOAB/trunk/test/h5file/h5legacy.cpp	                        (rev 0)
+++ MOAB/trunk/test/h5file/h5legacy.cpp	2007-11-09 23:22:17 UTC (rev 1376)
@@ -0,0 +1,100 @@
+#include "MBCore.hpp"
+#include "testdir.h"
+
+#include <iostream>
+#include <stdlib.h>
+#include <math.h>
+
+// define our own assert so it doesn't get compiled out during release builds
+#define assert( A ) if (!(A)) { \
+  std::cerr << "Assertion failed at line " << __LINE__ << " : " << #A << std::endl; \
+  abort(); \
+}
+
+
+void calc_centroid( MBInterface* iface, MBEntityHandle pent, double result[3] )
+{
+  int len;
+  const MBEntityHandle* conn;
+  MBErrorCode rval;
+  rval = iface->get_connectivity( pent, conn, len );
+  assert(MB_SUCCESS == rval && 5 == len);
+  
+  double coords[15];
+  rval = iface->get_coords( conn, len, coords );
+  assert(MB_SUCCESS == rval);
+  
+  for (int d = 0; d < 3; ++d) {
+    result[d] = 0;
+    for (int i = 0; i < 5; ++i)
+      result[d] += coords[3*i+d];
+    result[d] /= 5;
+  }
+}
+
+void test_moab_v3_poly_format()
+{
+  MBCore moab;
+  MBInterface& mb = moab;
+  MBErrorCode rval;
+  
+    // load file containing a dodecahedron
+  rval = mb.load_mesh( "../../" TEST_DIR "/v3_dodec.h5m" );
+  assert( MB_SUCCESS == rval );
+  
+    // get entities from file
+  MBRange verts, faces, polyhedrons;
+  rval = mb.get_entities_by_type( 0, MBVERTEX, verts );
+  assert( MB_SUCCESS == rval );
+  rval = mb.get_entities_by_type( 0, MBPOLYGON, faces );
+  assert( MB_SUCCESS == rval );
+  rval = mb.get_entities_by_type( 0, MBPOLYHEDRON, polyhedrons );
+  assert( MB_SUCCESS == rval );
+  
+    // check expected number of entities
+  assert( 20 == verts.size() );
+  assert( 12 == faces.size() );
+  assert( 1 == polyhedrons.size() );
+  const MBEntityHandle polyhedron = polyhedrons.front();
+  
+    // check the polyhedron connectivity list
+  std::vector<MBEntityHandle> faces1, faces2;
+  std::copy( faces.begin(), faces.end(), std::back_inserter(faces1) );
+  rval = mb.get_connectivity( &polyhedron, 1, faces2 );
+  assert( MB_SUCCESS == rval );
+  std::sort( faces2.begin(), faces2.end() );
+  assert( faces1 == faces2 );
+  
+    // each polygonshould have a tag value storing its centroid.
+    // compare this value against the centroid calculated from
+    // the vertex coords.
+  
+    // get tag for saved values
+  MBTag centroid;
+  rval = mb.tag_get_handle( "CENTROID", centroid );
+  assert( MB_SUCCESS == rval );
+  
+    // for each face...
+  for (MBRange::iterator i = faces.begin(); i != faces.end(); ++i) {
+    double saved[3], calc[3];
+    rval = mb.tag_get_data( centroid, &*i, 1, saved );
+    assert( MB_SUCCESS == rval );
+    calc_centroid( &mb, *i, calc );
+    assert( fabs(saved[0] - calc[0]) < 1e-6 );
+    assert( fabs(saved[1] - calc[1]) < 1e-6 );
+    assert( fabs(saved[2] - calc[2]) < 1e-6 );
+  }
+}
+
+  
+
+
+int main()
+{
+  // only one test so far... should probably add second test
+  // for really-old-format  entityset parent/child links
+  test_moab_v3_poly_format();
+  return 0;
+}
+
+  

Added: MOAB/trunk/test/v3_dodec.h5m
===================================================================
(Binary files differ)


Property changes on: MOAB/trunk/test/v3_dodec.h5m
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream




More information about the moab-dev mailing list