From 6f6b0b4c18597ee72a30494cd98bd10c1a5d40ad Mon Sep 17 00:00:00 2001 From: jfa Date: Tue, 26 Sep 2006 11:35:38 +0000 Subject: [PATCH] Fix for bug 13476: Common of two compounds produce 10 compounds, 9 of which are empty. --- src/GEOMImpl/GEOMImpl_BooleanDriver.cxx | 61 ++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 6 deletions(-) diff --git a/src/GEOMImpl/GEOMImpl_BooleanDriver.cxx b/src/GEOMImpl/GEOMImpl_BooleanDriver.cxx index 2f0c9e140..045ca5ade 100644 --- a/src/GEOMImpl/GEOMImpl_BooleanDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_BooleanDriver.cxx @@ -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(); } -- 2.39.2