[MOAB-dev] r4286 - MOAB/trunk/itaps/imesh

jvporter at wisc.edu jvporter at wisc.edu
Thu Nov 18 17:51:41 CST 2010


Author: jvporter
Date: 2010-11-18 17:51:41 -0600 (Thu, 18 Nov 2010)
New Revision: 4286

Modified:
   MOAB/trunk/itaps/imesh/iMesh_MOAB.cpp
Log:
Change behavior of get/set/create vertex functions (don't assume 3-dimensional
layout of coordinates) to pass iMesh_unitTest. Could maybe use some
optimizing...


Modified: MOAB/trunk/itaps/imesh/iMesh_MOAB.cpp
===================================================================
--- MOAB/trunk/itaps/imesh/iMesh_MOAB.cpp	2010-11-18 22:57:34 UTC (rev 4285)
+++ MOAB/trunk/itaps/imesh/iMesh_MOAB.cpp	2010-11-18 23:51:41 UTC (rev 4286)
@@ -462,18 +462,32 @@
                               /*inout*/ int* coords_allocated,
                               /*out*/ int* coords_size, int *err) 
   {
+    int geom_dim;
+    MBI->get_dimension(geom_dim);
 
       // make sure we can hold them all
-    ALLOC_CHECK_ARRAY(coords, 3*vertex_handles_size);
+    ALLOC_CHECK_ARRAY(coords, geom_dim*vertex_handles_size);
   
       // now get all the coordinates
       // coords will come back interleaved by default
     ErrorCode result;
     if (storage_order == iBase_INTERLEAVED) {
-      result = MBI->get_coords(CONST_HANDLE_ARRAY_PTR(vertex_handles), 
-                               vertex_handles_size, *coords);
+      if (3 == geom_dim) {
+        result = MBI->get_coords(CONST_HANDLE_ARRAY_PTR(vertex_handles), 
+                                 vertex_handles_size, *coords);
+      }
+      else {
+        std::vector<double> dum_coords(3*vertex_handles_size);
+        result = MBI->get_coords(CONST_HANDLE_ARRAY_PTR(vertex_handles), 
+                                 vertex_handles_size,
+                                 &dum_coords[0]);
+
+        for (int i = 0; i < vertex_handles_size; i++) {
+          for (int j = 0; j < geom_dim; j++)
+            (*coords)[geom_dim*i + j] = dum_coords[3*i + j];
+        }
+      }
     }
-  
     else {
       std::vector<double> dum_coords(3*vertex_handles_size);
       result = MBI->get_coords(CONST_HANDLE_ARRAY_PTR(vertex_handles), 
@@ -481,15 +495,9 @@
                                &dum_coords[0]);
       CHKERR(result,"iMesh_getVtxArrCoords: problem getting vertex coords");
 
-      int i;
-      double *x = *coords;
-      double *y = *coords+vertex_handles_size;
-      double *z = *coords+2*vertex_handles_size;
-      std::vector<double>::const_iterator c_iter = dum_coords.begin();
-      for (i = 0; i < vertex_handles_size; i++) {


More information about the moab-dev mailing list