Fix for bug 13476: Common of two compounds produce 10 compounds, 9 of which are empty.

This commit is contained in:
jfa 2006-09-26 11:35:38 +00:00
parent 1069f468cb
commit 6f6b0b4c18

View File

@ -127,8 +127,25 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(TFunction_Logbook& log) const
if (!BO.IsDone()) { if (!BO.IsDone()) {
StdFail_NotDone::Raise("Common operation can not be performed on the given shapes"); StdFail_NotDone::Raise("Common operation can not be performed on the given shapes");
} }
if (isCompound) if (isCompound) {
B.Add(C, BO.Shape()); 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 else
aShape = BO.Shape(); aShape = BO.Shape();
} }
@ -175,8 +192,23 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(TFunction_Logbook& log) const
} }
aCut = BO.Shape(); aCut = BO.Shape();
} }
if (isCompound) if (isCompound) {
B.Add(C, aCut); // 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 else
aShape = aCut; aShape = aCut;
} }
@ -229,8 +261,25 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(TFunction_Logbook& log) const
if (!BO.IsDone()) { if (!BO.IsDone()) {
StdFail_NotDone::Raise("Section operation can not be performed on the given shapes"); StdFail_NotDone::Raise("Section operation can not be performed on the given shapes");
} }
if (isCompound) if (isCompound) {
B.Add(C, BO.Shape()); 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 else
aShape = BO.Shape(); aShape = BO.Shape();
} }