[MOAB-dev] r2222 - MOAB/trunk/tools/iMesh

kraftche at mcs.anl.gov kraftche at mcs.anl.gov
Fri Nov 7 12:42:28 CST 2008


Author: kraftche
Date: 2008-11-07 12:42:28 -0600 (Fri, 07 Nov 2008)
New Revision: 2222

Modified:
   MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp
Log:
Fix bugs in iMesh_getEntArrAdj:
 - Do not return faces when asked for vertices of polyhedron
 - Do not return only sets when asked for iBase_ALL_TYPES
 - Test for failed MBInterface::get_connectivity call
 
Fix bug in CHECK_SIZE:
 - Do not allocate and pass back a zero-length array
  


Modified: MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp
===================================================================
--- MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp	2008-11-07 15:26:18 UTC (rev 2221)
+++ MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp	2008-11-07 18:42:28 UTC (rev 2222)
@@ -5,6 +5,9 @@
 #include "MeshTopoUtil.hpp"
 #include "FileOptions.hpp"
 #include "iMesh_MOAB.hpp"
+#define IS_BUILDING_MB
+#include "MBInternals.hpp"
+#undef IS_BUILDING_MB
 
 #ifdef USE_MPI    
 #include "mpi.h"
@@ -53,7 +56,7 @@
           "Allocated array not large enough to hold returned contents.");\
     RETURN(iBase_MEMORY_ALLOCATION_FAILED);\
   }\
-  if (allocated == 0 || NULL == array) {\
+  if ((size) && ((allocated) == 0 || NULL == (array))) {\
     array = (type*)malloc((size)*sizeof(type));\
     allocated=(size);\
     if (NULL == array) {iMesh_processError(iBase_MEMORY_ALLOCATION_FAILED, \
@@ -67,7 +70,7 @@
           "Allocated array not large enough to hold returned contents.");\
     RETURN(iBase_MEMORY_ALLOCATION_FAILED);\
   }\
-  if (NULL == array || allocated == 0) {\
+  if ((size) && (NULL == (array) || (allocated) == 0)) {\
     allocated=(size); \
     if (allocated%sizeof(void*) != 0) allocated=((size)/sizeof(void*)+1)*sizeof(void*);\
     array = (char*)malloc(allocated); \
@@ -997,8 +1000,32 @@
     {
       *off_iter = prev_off;
       off_iter++;
-
-      if (iBase_VERTEX != entity_type_requested) {
+      
+      if (iBase_VERTEX == entity_type_requested &&
+          TYPE_FROM_HANDLE(*entity_iter) != MBPOLYHEDRON) {
+        result = MBI->get_connectivity(*entity_iter, connect, num_connect);
+        if (MB_SUCCESS != result) {
+          iMesh_processError(iBase_ERROR_MAP[result], "iMesh_getEntArrAdj: trouble getting adjacency list.");
+          RETURN(iBase_ERROR_MAP[result]);
+        }
+        std::copy(connect, connect+num_connect, std::back_inserter(all_adj_ents));
+        prev_off += num_connect;
+      }
+      else if (iBase_ALL_TYPES == entity_type_requested) {
+        for (int dim = 0; dim < 4; ++dim) {
+          if (MBCN::Dimension(TYPE_FROM_HANDLE(*entity_iter)) == dim)
+            continue;
+          adj_ents.clear();
+          result = MBI->get_adjacencies( entity_iter, 1, dim, false, adj_ents );
+          if (MB_SUCCESS != result) {
+            iMesh_processError(iBase_ERROR_MAP[result], "iMesh_getEntArrAdj: trouble getting adjacency list.");
+            RETURN(iBase_ERROR_MAP[result]);
+          }
+          std::copy(adj_ents.begin(), adj_ents.end(), std::back_inserter(all_adj_ents));
+          prev_off += adj_ents.size();
+        }
+      }
+      else {
         adj_ents.clear();
         result = MBI->get_adjacencies( entity_iter, 1, 
                                        entity_type_requested, false, adj_ents );
@@ -1009,11 +1036,6 @@
         std::copy(adj_ents.begin(), adj_ents.end(), std::back_inserter(all_adj_ents));
         prev_off += adj_ents.size();
       }
-      else {
-        result = MBI->get_connectivity(*entity_iter, connect, num_connect);
-        std::copy(connect, connect+num_connect, std::back_inserter(all_adj_ents));
-        prev_off += num_connect;
-      }
     }
     *off_iter = prev_off;
 




More information about the moab-dev mailing list