]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Fix for bug 13476: Common of two compounds produce 10 compounds, 9 of which are empty.
authorjfa <jfa@opencascade.com>
Tue, 26 Sep 2006 11:35:38 +0000 (11:35 +0000)
committerjfa <jfa@opencascade.com>
Tue, 26 Sep 2006 11:35:38 +0000 (11:35 +0000)
src/GEOMImpl/GEOMImpl_BooleanDriver.cxx

index 2f0c9e140e23aa1285f81c2149e22344d65812ae..045ca5adefe439103554e748404f79a9f5cfd99d 100644 (file)
@@ -127,8 +127,25 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(TFunction_Logbook& log) const
           if (!BO.IsDone()) {
             StdFail_NotDone::Raise("Common operation can not be performed on the given shapes");
           }
-          if (isCompound)
-            B.Add(C, BO.Shape());
+          if (isCompound) {
+            TopoDS_Shape aStepResult = BO.Shape();
+
+            // check result of this step: if it is a compound (boolean operations
+            // allways return a compound), we add all sub-shapes of it.
+            // This allows to avoid adding empty compounds,
+            // resulting from COMMON on two non-intersecting shapes.
+            if (aStepResult.ShapeType() == TopAbs_COMPOUND) {
+              TopoDS_Iterator aCompIter (aStepResult);
+              for (; aCompIter.More(); aCompIter.Next()) {
+                // add shape in a result
+                B.Add(C, aCompIter.Value());
+              }
+            }
+            else {
+              // add shape in a result
+              B.Add(C, aStepResult);
+            }
+          }
           else
             aShape = BO.Shape();
         }
@@ -175,8 +192,23 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(TFunction_Logbook& log) const
           }
           aCut = BO.Shape();
         }
-        if (isCompound)
-          B.Add(C, aCut);
+        if (isCompound) {
+          // check result of this step: if it is a compound (boolean operations
+          // allways return a compound), we add all sub-shapes of it.
+          // This allows to avoid adding empty compounds,
+          // resulting from CUT of parts
+          if (aCut.ShapeType() == TopAbs_COMPOUND) {
+            TopoDS_Iterator aCompIter (aCut);
+            for (; aCompIter.More(); aCompIter.Next()) {
+              // add shape in a result
+              B.Add(C, aCompIter.Value());
+            }
+          }
+          else {
+            // add shape in a result
+            B.Add(C, aCut);
+          }
+        }
         else
           aShape = aCut;
       }
@@ -229,8 +261,25 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(TFunction_Logbook& log) const
           if (!BO.IsDone()) {
             StdFail_NotDone::Raise("Section operation can not be performed on the given shapes");
           }
-          if (isCompound)
-            B.Add(C, BO.Shape());
+          if (isCompound) {
+            TopoDS_Shape aStepResult = BO.Shape();
+
+            // check result of this step: if it is a compound (boolean operations
+            // allways return a compound), we add all sub-shapes of it.
+            // This allows to avoid adding empty compounds,
+            // resulting from SECTION on two non-intersecting shapes.
+            if (aStepResult.ShapeType() == TopAbs_COMPOUND) {
+              TopoDS_Iterator aCompIter (aStepResult);
+              for (; aCompIter.More(); aCompIter.Next()) {
+                // add shape in a result
+                B.Add(C, aCompIter.Value());
+              }
+            }
+            else {
+              // add shape in a result
+              B.Add(C, aStepResult);
+            }
+          }
           else
             aShape = BO.Shape();
         }