A possible bug in IntTools_FaceFace for a plane and a face with a circle surface

Hi,

I would like to find the intersection curves on a shape with a rectangular plane. There are several possible options. I used IntTools_FaceFace to generate the intersection curves on the shape. When faces of the shape are circular (rather than rectangular) faces, results are wrong, as shown in the attached figure. However, when faces of the shape are rectangular faces, results are ok. Any one has ideas how to avoid it?

Since I have to do a lot of such operations and the performance is quite important for my case, I prefer IntTools_FaceFace to bool type APIs, such as BRepAlgoAPI_Section.

Here are the code snippet I used to generate the attached figure. Any suggestion would be quite appreciated~~

TopExp_Explorer Extest;
for (Extest.Init(S1, TopAbs_FACE); Extest.More(); Extest.Next()) {
const TopoDS_Face& currentface = TopoDS::Face(Extest.Current());
double xloc;
xloc = x[k] + deltax[k] / 2.;
gp_Pnt p1(xloc, y[0], z[0]), p2(xloc, y[y.size()-1], z[0]);
gp_Pnt p4(xloc, y[0], z[z.size()-1]), p3(xloc, y[y.size() - 1], z[z.size()-1]);

TopoDS_Vertex v1 = BRepBuilderAPI_MakeVertex(p1);
TopoDS_Vertex v2 = BRepBuilderAPI_MakeVertex(p2);
TopoDS_Vertex v3 = BRepBuilderAPI_MakeVertex(p3);
TopoDS_Vertex v4 = BRepBuilderAPI_MakeVertex(p4);

TopoDS_Edge e1 = BRepBuilderAPI_MakeEdge(p1, p2);
TopoDS_Edge e2 = BRepBuilderAPI_MakeEdge(p2, p3);
TopoDS_Edge e3 = BRepBuilderAPI_MakeEdge(p3, p4);
TopoDS_Edge e4 = BRepBuilderAPI_MakeEdge(p4, p1);

TopoDS_Wire w1 = BRepBuilderAPI_MakeWire(e1, e2, e3, e4);
TopoDS_Face f = BRepBuilderAPI_MakeFace(w1);

Handle(AIS_Shape) ashape = new AIS_Shape(f);

ashape->SetColor(Quantity_NOC_AZURE);
myOccView->getContext()->Display(ashape, Standard_True);

IntTools_FaceFace aFF;
aFF.SetParameters(true, true, true, Precision::Confusion());
const Handle(Geom_Surface) S1 = BRep_Tool::Surface(currentface);
if (S1->DynamicType() == STANDARD_TYPE(Geom_Plane)) {
Handle(AIS_Shape) aFaceshape = new AIS_Shape(currentface);
aFaceshape->SetColor(Quantity_NOC_WHITE);
myOccView->getContext()->Display(aFaceshape, Standard_True);
aFF.Perform(currentface, f);
if (aFF.IsDone()) {
aFF.PrepareLines3D(false);
Standard_Integer aNbCurves;
const IntTools_SequenceOfCurves aCvs = aFF.Lines();
aNbCurves = aCvs.Length();
for (int kk = 1; kk <= aNbCurves; kk++) {
const IntTools_Curve& aIC = aCvs(kk);
Handle(Geom_Curve) mycrv = aIC.Curve();
TopoDS_Edge aEdgeInt = BRepBuilderAPI_MakeEdge(mycrv);
Handle(AIS_Shape) ashape = new AIS_Shape(aEdgeInt);
ashape->SetColor(Quantity_NOC_RED);
myOccView->getContext()->Display(ashape, Standard_True);
}
}
}
}

Attachments: