TopoDS_Wire can not make face when it is self-intersected

This is what I have so far:

BRepBuilderAPI_MakePolygon builder;
builder.Add(...);
builder.Build();

TopoDS_Wire W = builder.Wire();
if ( W.Closed() )
{
TopoDS_Face F = BRepBuilderAPI_MakeFace(W);
}

I find F is invalid when W have self-intersection. How to fix it?
Thx!

P G's picture

Use CheckSelfIntersection() function in ShapeAnalysis_Wire class.

Thomas Rabenbauer's picture

Thx to rely.
Yes, I found ShapeAnalysis_Wire class and I detect the intersection, but it can not be fixed:

BRepBuilderAPI_MakePolygon ply;
ply.Add();

TopoDS_Wire wire = ply.Wire();
TopoDS_Face face = BRepBuilderAPI_MakeFace(wire);

Standard_Real precision = 1e-04;
ShapeAnalysis_Wire saw (wire, face, precision);
ShapeFix_Wire sfw (wire, face, precision);
if (saw.CheckOrder())
{
sfw.FixReorder();
}

if (saw.CheckSelfIntersection())
{
if (sfw.FixSelfIntersection()) // This function always return false
{
face = sfw.Face();
}
}

So, How can I get the right face?

Alexander Luger's picture

Did you try to use sfw.Perform()? Maybe FixSelfIntersection requires other fixes first to succeed.

Regards,
Alex