Not able to create a face from nonPlanar wire

I am creating a single connected wire from multiple trimmed face and tried to create face out of that the code snippet is as belows. (Note:- works fine for planar surfaces)

BRepBuilderAPI_MakeWire wire;

//Iterates through each face and adds the outer wire to the BRepBuilderAPI_MakeWire
while (trimmedFaceArray->MoveNext())
{
ITrimmedFace^ trimmedFace= trimmedFaceArray->Current;
TopoDS_Face face;

trimmedFace->GetFace(face);

TopoDS_Wire outerWire = ShapeAnalysis::OuterWire(face);

wire.Add(outerWire);
}

//Created a single wire out of multiple outer wire
TopoDS_Wire aWire=wire.Wire();

//Creates the ordered and connected wire
TopoDS_Wire orderedWire= Ordered_ConnectedWire(aWire);

//Creates the face out of orderedWire
TopoDS_Face newFace= BRepBuilderAPI_MakeFace(orderedWire);

This works fine for the planar orderedWire,
but if its of nonPlanar orderedWire it is failing.
If someone worked on such scenario and has some solution, please help me out.

kishorm's picture

I am attaching .iges file for reference having two trimmed faces

kishorm's picture

Ignore first attachment i have created a single wire out of multiple trimmed face iges

kishorm's picture

Wire created from multiple trimmed face not able to create face out of that but the wire seems to be ok. Could any one check whats the problem in the created orderedWire.brep.

Forum supervisor's picture

Dear Kishor,
Indeed the mentioned wire is OK (in terms of OCCT validity), but it doesn't mean that
it is planar (even visually it looks like planar).
As result the used by you algorithm can't create a face from a non planar wire.
I suggest you to use alternative API of the same class with Geom_Surface additional parameter .
Geom_Surface you can build using for example GeomFill_BSplineCurves class, which builds surface from set of b-spline curves.
Regards

Mark Blome's picture

Dear Kishor,

you might also consider using the BRepFill_Filling class.
I had a similar issue and was able to create faces for not-exactly-planar
wires with it.

Regards,
Mark

kishorm's picture

Thanks!!!
This is working fine to create a face from the BSplineCurves, But the limitation is, it can take only two, three or at max four curves.

I have created surface from the four curves and Initialize BRepBuilderAPI_MakeFace with that surface and Added Wire for the bound and created a face. It has created the errored face as in the attachment. Which still doesn't solved my problem.

Forum supervisor's picture

Dear Kishor,
You may try to play with input parameter 'FillingStyle from GeomFill'or try to make healing of the resulting shape.
At the same time if the problem is critical for you, you may contact us via the Contact Form http://www.opencascade.org/about/contacts/ and ask our professional support. We will try to find a solution/workaround acceptable for you.
Regards.