I have encountered similar behavior after upgrading to the 6.7.1.
Suppose following code using a unit box and a cylinder and building boolean cut = box-cylinder:
#include
#include
#include
#include
int getItemCount(const TopoDS_Shape & shape, const TopAbs_ShapeEnum itemType) {
int count = 0;
for(TopExp_Explorer explorer(shape, itemType); explorer.More(); explorer.Next()) {
count++;
}
return count;
}
void traceSourceShape(
BRepAlgoAPI_BooleanOperation & operation,
const TopoDS_Shape & shape
) {
int i = 0;
for(TopExp_Explorer explorer(shape, TopAbs_FACE); explorer.More(); explorer.Next()) {
TopoDS_Shape face = explorer.Current();
TopTools_ListOfShape generated;
generated = operation.Generated(face);
TopTools_ListOfShape modified;
modified = operation.Modified(face);
cout << "face #" << i++
<< "(generated: " << generated.Extent()
<< ", modified: " << modified.Extent()
<< ", deleted: " << operation.IsDeleted(face)
<< ")" << endl;
}
}
int main(int argc, char** argv) {
TopoDS_Solid box = BRepPrimAPI_MakeBox(1.0,1.0,1.0);
gp_Ax2 axes = gp::XOY();
axes.Translate(gp_Vec(0.5,0.5,-0.5));
TopoDS_Solid cylinder = BRepPrimAPI_MakeCylinder(axes, 0.2, 2.0);
BRepAlgoAPI_Cut cut(box, cylinder);
cut.Build();
TopoDS_Shape cutShape = cut.Shape();
cout << "Result face count: " << getItemCount(cutShape, TopAbs_FACE) << endl;
cout << "Box" << endl;
traceSourceShape(cut, cut.Shape1());
cout << "Cylinder" << endl;
traceSourceShape(cut, cut.Shape2());
return 0;
}
The output is following:
Result face count: 7
Box
face #0(generated: 0, modified: 0, deleted: 1)
face #1(generated: 0, modified: 0, deleted: 1)
face #2(generated: 0, modified: 0, deleted: 1)
face #3(generated: 0, modified: 0, deleted: 1)
face #4(generated: 0, modified: 1, deleted: 0)
face #5(generated: 0, modified: 1, deleted: 0)
Cylinder
face #0(generated: 0, modified: 1, deleted: 0)
face #1(generated: 0, modified: 0, deleted: 1)
face #2(generated: 0, modified: 0, deleted: 1)
I see that resulting shape has 7 faces (6 from original box + 1 for the hole) - that is fine.
But tracing original faces of the box one can see just 2 modified faces and 4 deleted. For the cylinder 1 modified original face and 2 deleted.
Here I am confused - I have just 2+1=3 modified original faces and none new generated. What about the rest 7-3=4 faces of the resulting shape? How can I resolve their source face?
Can someone eplain this behavior? Or is it a bug?