[MOAB-dev] r4056 - MOAB/trunk/src

hongjun at mcs.anl.gov hongjun at mcs.anl.gov
Wed Jul 14 14:57:28 CDT 2010


Author: hongjun
Date: 2010-07-14 14:57:28 -0500 (Wed, 14 Jul 2010)
New Revision: 4056

Modified:
   MOAB/trunk/src/WriteUtil.cpp
Log:
o For stuructured mesh element, get_connectivity function is called element by element
o For unstructured case, it still get connectivities at once by copying buffer
o Bug fixed, end handle is fixed for element getting loop


Modified: MOAB/trunk/src/WriteUtil.cpp
===================================================================
--- MOAB/trunk/src/WriteUtil.cpp	2010-07-14 19:50:44 UTC (rev 4055)
+++ MOAB/trunk/src/WriteUtil.cpp	2010-07-14 19:57:28 UTC (rev 4056)
@@ -492,11 +492,28 @@
     if (output_iter + (count * conn_size) > output_end)
       return MB_FAILURE;
 
+    if (conn_array == NULL) { // if it is structured mesh
+      ErrorCode rval;
+      int temp_buff_size = conn_size* sizeof(EntityHandle);
+      for (int i = 0; i < count; i++) { // copy connectivity element by element
+	std::vector<EntityHandle> connect;
+	rval = static_cast<ElementSequence*>(*seq_iter)->get_connectivity(*iter,
+									  connect);
+	if (MB_SUCCESS != rval) {
+          return rval;
+	}
+	memcpy(output_iter, &connect[0], temp_buff_size);
+	output_iter += conn_size;
+	iter++;
+      }
+    }
+    else {
       // Copy connectivity into output array
-    conn_array += (conn_size * offset);
-    memcpy( output_iter, conn_array, count * conn_size * sizeof(EntityHandle));
-    output_iter += count * conn_size;
-    iter += count;
+      conn_array += (conn_size * offset);
+      memcpy( output_iter, conn_array, count * conn_size * sizeof(EntityHandle));
+      output_iter += count * conn_size;
+      iter += count;
+    }
   }
 
   return MB_SUCCESS;
@@ -631,8 +648,9 @@
     }
       // structured mesh
     else {
+      EntityHandle end_h = iter.get_end_handle() + 1;
       for (EntityHandle h = iter.get_start_handle();
-           h < iter.get_end_handle(); ++h) {
+           h < end_h; ++h) {
         tmp_conn.clear();
         rval = seq->get_connectivity( h, tmp_conn, false );
         if (MB_SUCCESS != rval) {





More information about the moab-dev mailing list