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();
}
}
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;
}
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();
}