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

jvporter at wisc.edu jvporter at wisc.edu
Thu Dec 2 20:11:41 CST 2010


Author: jvporter
Date: 2010-12-02 20:11:41 -0600 (Thu, 02 Dec 2010)
New Revision: 4315

Modified:
   MOAB/trunk/itaps/imesh/iMesh_MOAB.cpp
Log:
Allow boolean set ops with the root set


Modified: MOAB/trunk/itaps/imesh/iMesh_MOAB.cpp
===================================================================
--- MOAB/trunk/itaps/imesh/iMesh_MOAB.cpp	2010-12-03 00:40:29 UTC (rev 4314)
+++ MOAB/trunk/itaps/imesh/iMesh_MOAB.cpp	2010-12-03 02:11:41 UTC (rev 4315)
@@ -2371,12 +2371,30 @@
       result = MBI->create_meshset(MESHSET_ORDERED, temp_set);
     else
       result = MBI->create_meshset(MESHSET_SET, temp_set);
-    
-    if (MB_SUCCESS == result) result = MBI->unite_meshset(temp_set, set1);
-    if (MB_SUCCESS == result) result = MBI->subtract_meshset(temp_set, set2);
 
-    CHKERR(result,"iMesh_subtract: ERROR subtract failed.");
+    if (MB_SUCCESS != result)
+      ERROR(result, "iMesh_subtract: couldn't create result set.");
 
+      // if the second set is the root set, the result is always the empty set
+    if (entity_set_2) {
+      if (!entity_set_1) {
+          // subtracting from the root set, so get everything first...
+        Range entities;
+        result = MBI->get_entities_by_handle(0,entities);
+        if (MB_SUCCESS == result)
+          result = MBI->add_entities(temp_set, entities);
+          // ...but not the newly-created set!
+        if (MB_SUCCESS == result)
+          result = MBI->remove_entities(temp_set, &temp_set, 1);
+      }
+      else
+        result = MBI->unite_meshset(temp_set, set1);
+
+      if (MB_SUCCESS == result)
+        result = MBI->subtract_meshset(temp_set, set2);
+    }
+    
+    CHKERR(result, "iMesh_subtract: ERROR subtract failed.");
     *result_entity_set = (iBase_EntitySetHandle)temp_set;
 
     RETURN(iBase_SUCCESS);
@@ -2403,11 +2421,32 @@
     else
       result = MBI->create_meshset(MESHSET_SET, temp_set);
 
-    if (MB_SUCCESS == result) result = MBI->unite_meshset(temp_set, set1);
-    if (MB_SUCCESS == result) result = MBI->intersect_meshset(temp_set, set2);
+    if (MB_SUCCESS != result)
+      ERROR(result, "iMesh_intersect: couldn't create result set.");
 
+    if (!entity_set_1 && !entity_set_2) {
+        // intersecting the root set with itself, so get everything...
+      Range entities;


More information about the moab-dev mailing list