[MOAB-dev] commit/MOAB: iulian07: Merged in iulian07/vtk_polydata (pull request #33)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Jul 14 09:15:47 CDT 2014


1 new commit in MOAB:

https://bitbucket.org/fathomteam/moab/commits/d5336a950414/
Changeset:   d5336a950414
Branch:      master
User:        iulian07
Date:        2014-07-14 16:15:43
Summary:     Merged in iulian07/vtk_polydata (pull request #33)

fix vtk polydata reader
Affected #:  5 files

diff --git a/MeshFiles/unittest/io/Makefile.am b/MeshFiles/unittest/io/Makefile.am
index f259b82..2fd6cb3 100644
--- a/MeshFiles/unittest/io/Makefile.am
+++ b/MeshFiles/unittest/io/Makefile.am
@@ -30,5 +30,6 @@ EXTRA_DIST = HommeMapping.nc \
              cube.stp \
              cylcube.sat \
              cylcube.stp \
+             poly8-10.vtk \
              gcrm_r3.nc
 

diff --git a/MeshFiles/unittest/io/poly8-10.vtk b/MeshFiles/unittest/io/poly8-10.vtk
new file mode 100644
index 0000000..3a4d242
--- /dev/null
+++ b/MeshFiles/unittest/io/poly8-10.vtk
@@ -0,0 +1,42 @@
+# vtk DataFile Version 3.0
+MOAB 4.7.0pre
+ASCII
+DATASET POLYDATA
+POINTS 26 double 
+3.073901530231682e-06 2.977455744718462e-01 0.000000000000000e+00 
+-7.071067811865476e-01 7.071067811865475e-01 0.000000000000000e+00 
+-1.715691137876366e-01 3.536798274750831e-01 0.000000000000000e+00 
+-4.719776146377113e-01 1.857355490854607e-01 0.000000000000000e+00 
+-8.508854127205038e-01 3.599944589578263e-01 0.000000000000000e+00 
+2.775557561562891e-16 1.000000000000000e+00 0.000000000000000e+00 
+-3.406715072241552e-01 8.588892413936710e-01 0.000000000000000e+00 
+1.715662369808998e-01 3.536768053562428e-01 0.000000000000000e+00 
+4.719754417201190e-01 1.857347459630188e-01 0.000000000000000e+00 
+-4.719756118732749e-01 -1.857348097293946e-01 0.000000000000000e+00 
+-1.000000000000000e+00 1.110223024625157e-16 0.000000000000000e+00 
+-8.508847507623047e-01 -3.599960570662885e-01 0.000000000000000e+00 
+7.071067811865476e-01 7.071067811865476e-01 0.000000000000000e+00 
+3.406701269292776e-01 8.588898131305294e-01 0.000000000000000e+00 
+8.508845922027242e-01 3.599964398629780e-01 0.000000000000000e+00 
+-7.071067811865476e-01 -7.071067811865476e-01 0.000000000000000e+00 
+4.719777412790575e-01 -1.857356073815120e-01 0.000000000000000e+00 
+7.071067811865472e-01 -7.071067811865477e-01 0.000000000000000e+00 
+-3.051853356210140e-16 -1.000000000000000e+00 0.000000000000000e+00 
+1.715687253344436e-01 -3.536802010232855e-01 0.000000000000000e+00 
+-3.319925237351595e-06 -2.977459818644166e-01 0.000000000000000e+00 
+-1.715662714497118e-01 -3.536770586038507e-01 0.000000000000000e+00 
+-3.406707216059742e-01 -8.588895668073767e-01 0.000000000000000e+00 
+3.406712167592965e-01 -8.588893617081550e-01 0.000000000000000e+00 
+1.000000000000000e+00 -2.775557561562891e-17 0.000000000000000e+00 
+8.508853951409249e-01 -3.599945013986841e-01 0.000000000000000e+00 
+POLYGONS 10 64
+6 21 22 18 23 19 20 
+6 20 0 7 8 16 19 
+5 10 4 3 9 11 
+5 12 13 7 8 14 
+5 24 14 8 16 25 
+5 21 9 11 15 22 
+6 7 0 2 6 5 13 
+5 19 23 17 25 16 
+5 3 4 1 6 2 
+6 21 9 3 2 0 20 

diff --git a/src/io/ReadVtk.cpp b/src/io/ReadVtk.cpp
index 2936a85..90b7a41 100644
--- a/src/io/ReadVtk.cpp
+++ b/src/io/ReadVtk.cpp
@@ -685,7 +685,7 @@ ErrorCode ReadVtk::vtk_read_polygons( FileTokenizer& tokens,
     
     if (prev +1 != handle) {
       if (first) { // true except for first iteration (first == 0)
-        if (first < elem_list.back().front()) // only need new range if order would get mixed up
+        if ( elem_list.empty() || first < elem_list.back().front()) // only need new range if order would get mixed up, or we just began inserting
           elem_list.push_back( empty );
         elem_list.back().insert( first, prev );
       }
@@ -694,7 +694,7 @@ ErrorCode ReadVtk::vtk_read_polygons( FileTokenizer& tokens,
     prev = handle;
   }
   if (first) { // true unless no elements (size[0] == 0)
-    if (first < elem_list.back().front()) // only need new range if order would get mixed up
+    if (elem_list.empty() || first < elem_list.back().front()) // only need new range if order would get mixed up, or we just began inserting
       elem_list.push_back( empty );
     elem_list.back().insert( first, prev );
   }

diff --git a/test/io/VtkTest.cpp b/test/io/VtkTest.cpp
index d6208a2..076c28b 100644
--- a/test/io/VtkTest.cpp
+++ b/test/io/VtkTest.cpp
@@ -12,6 +12,14 @@ using namespace moab;
 #include <algorithm>
 #include <sstream>
 
+#include "TestUtil.hpp"
+
+#ifdef MESHDIR
+static const char poly_example[] = STRINGIFY(MESHDIR) "/io/poly8-10.vtk";
+#else
+static const char poly_example[] = "poly8-10.vtk";
+#endif
+
 #define DECLARE_TEST(A) \
   bool test_ ## A(); \
   int A ## _reg_var = register_test( &test_ ## A, #A );
@@ -38,6 +46,7 @@ DECLARE_TEST(quad4)
 DECLARE_TEST(quad8)
 DECLARE_TEST(quad9)
 DECLARE_TEST(polygon)
+DECLARE_TEST(polygon_mix)
 DECLARE_TEST(tet4)
 DECLARE_TEST(tet10)
 DECLARE_TEST(hex8)
@@ -155,7 +164,8 @@ int main( int argc, char* argv[] )
 
   return fail_count;
 }
-
+// CHECK is defined in TestUtil now
+#undef CHECK
 #define CHECK(A) if (is_error((A))) return do_error( #A, __LINE__ )
 static bool do_error( const char* string, int line )
 {
@@ -383,6 +393,19 @@ bool test_polygon()
   return test_read_write_element( coords, 13, conn, conn, 16, 2, 7, MBPOLYGON );
 }
 
+bool test_polygon_mix()
+{
+  // just read the polygon file with mixed sequences
+  Core moab;
+  Interface& mb = moab;
+
+  ErrorCode rval = mb.load_file(poly_example);
+  if (MB_SUCCESS!=rval)
+    return false;
+
+  return true;
+
+}
 bool test_tet4()
 {
   const double coords[] = 

diff --git a/tools/size.cpp b/tools/size.cpp
index 7d4311d..737fb00 100644
--- a/tools/size.cpp
+++ b/tools/size.cpp
@@ -169,7 +169,7 @@ static ErrorCode gather_set_stats( EntityHandle set, set_stats& stats )
         {
           if (type == MBPOLYGON) {
             edge_vtx_idx[0] = e;
-            edge_vtx_idx[1] = e+1;
+            edge_vtx_idx[1] = (e+1)%num_edges;
           }
           else
             CN::SubEntityVertexIndices( type, 1, e, edge_vtx_idx );

Repository URL: https://bitbucket.org/fathomteam/moab/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.


More information about the moab-dev mailing list