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

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Tue Nov 17 11:07:43 CST 2009


Author: kraftche
Date: 2009-11-17 11:07:43 -0600 (Tue, 17 Nov 2009)
New Revision: 3359

Modified:
   MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp
Log:
fix bug: iMesh_getEntities does not preserve order for list-type entity sets

Modified: MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp
===================================================================
--- MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp	2009-11-17 16:47:01 UTC (rev 3358)
+++ MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp	2009-11-17 17:07:43 UTC (rev 3359)
@@ -2535,7 +2535,7 @@
     bool use_type = false;
       // initialize just to get rid of compiler warning
     MBEntityType type = mb_topology_table[iMesh_ALL_TOPOLOGIES];
-    MBRange out_entities;
+    std::vector<MBEntityHandle> out_entities;
  
     if (entity_topology >= iMesh_POINT
         && entity_topology < iMesh_ALL_TOPOLOGIES) {
@@ -2572,24 +2572,27 @@
       RETURN(iBase_ERROR_MAP[result]);
     }
 
-    int num_ents = out_entities.size() - out_entities.num_of_type(MBENTITYSET);
+      // remove entity sets from the result list
+    std::vector<MBEntityHandle>::iterator iter, end_iter;
+    if (iBase_ALL_TYPES == entity_type && iMesh_ALL_TOPOLOGIES == entity_topology) {
+      for (iter = out_entities.begin(); iter != out_entities.end() && 
+           TYPE_FROM_HANDLE(*iter) != MBENTITYSET; ++iter);
+      for (end_iter = iter; iter != out_entities.end(); ++iter)
+        if (TYPE_FROM_HANDLE(*iter) != MBENTITYSET)
+          *(end_iter++) = *iter;
+      out_entities.erase( end_iter, out_entities.end() );
+    }
+
+    int num_ents = out_entities.size();
     
     CHECK_SIZE(*entity_handles, *entity_handles_allocated, 
                num_ents, iBase_EntityHandle, iBase_MEMORY_ALLOCATION_FAILED);
   
-    MBRange::iterator iter = out_entities.begin();
-    MBRange::iterator end_iter = out_entities.end();
     int k = 0;
 
       // filter out entity sets here
-    if (iBase_ALL_TYPES == entity_type && iMesh_ALL_TOPOLOGIES == entity_topology) {
-      for (; iter != end_iter && MBI->type_from_handle(*iter) != MBENTITYSET; iter++)
-        (*entity_handles)[k++] = (iBase_EntityHandle)*iter;
-    }
-    else {
-      for (; iter != end_iter; iter++)
-        (*entity_handles)[k++] = (iBase_EntityHandle)*iter;
-    }
+    for (iter = out_entities.begin(); iter != out_entities.end(); iter++)
+      (*entity_handles)[k++] = (iBase_EntityHandle)*iter;
 
       // now it's safe to set the size; set it to k, not out_entities.size(), to
       // account for sets which might have been removed



More information about the moab-dev mailing list