MakeFace from gp_Circ

Hello, I'm building a TopoDS_Face from a TopoDS_Wire builded from a gp_Circ, but the result face is not a valid profile to BrepPrimAPI_MakePrism because the algorithm BrepPrimAPI_MakePrism fail. I added to the code ShapeFix_Face but the perform method return false. All is OK with wires builded from two or more edges. Here is a piece of code. The raised error is: "Can not build the face"
I thanks any help.

BRepBuilderAPI_MakeFace builder(wire);

ShapeFix_Face fixFace(builder.Face());
fixFace.FixOrientation();
fixFace.FixMissingSeam();
fixFace.FixSmallAreaWire();
fixFace.FixIntersectingWires();
fixFace.FixWiresTwoCoincEdges();

if(!fixFace.Perform())
{
if(fixFace.Status(ShapeExtend_OK))
{
Standard_Failure::Raise("ShapeExtend_OK");
}

if(fixFace.Status(ShapeExtend_DONE1))
{
Standard_Failure::Raise("ShapeExtend_DONE1");
}

if(fixFace.Status(ShapeExtend_DONE2))
{
Standard_Failure::Raise("ShapeExtend_DONE2");
}

if(fixFace.Status(ShapeExtend_DONE3))
{
Standard_Failure::Raise("ShapeExtend_DONE3");
}

if(fixFace.Status(ShapeExtend_DONE4))
{
Standard_Failure::Raise("ShapeExtend_DONE4");
}

if(fixFace.Status(ShapeExtend_DONE5))
{
Standard_Failure::Raise("ShapeExtend_DONE5");
}

if(fixFace.Status(ShapeExtend_FAIL1))
{
Standard_Failure::Raise("ShapeExtend_FAIL1");
}

if(fixFace.Status(ShapeExtend_FAIL2))
{
Standard_Failure::Raise("ShapeExtend_FAIL2");
}

if(fixFace.Status(ShapeExtend_FAIL3))
{
Standard_Failure::Raise("ShapeExtend_FAIL3");
}

if(fixFace.Status(ShapeExtend_FAIL4))
{
Standard_Failure::Raise("ShapeExtend_FAIL4");
}

Standard_Failure::Raise("Can not build the face");
}

Forum supervisor's picture

Dear Gustavo,
I suggest you to check 'wire' for validity before calling MakeFace.
Regards

toranzolorca's picture

Thanks for your answer. This is my code to create the wire:

gp_Ax2 ax2(gp_Pnt(0, 0, 0), gp_Vec(0, 0, 1));
gp_Circ circ(ax2, 200);
TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(circ);
TopoDS_Wire wire = BRepBuilderAPI_MakeWire(edge);

I take into account your answer and change the above code by the below code but I get the error "Perform return false":

gp_Ax2 ax2(gp_Pnt(0, 0, 0), gp_Vec(0, 0, 1));
gp_Circ circ(ax2, 200);
TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(circ);

wireData = new ShapeExtend_WireData();
wireData->Add(edge);

ShapeFix_Wire fixWire;
fixWire.Load(wireData);

fixWire.FixReorder();
fixWire.FixConnected();
fixWire.FixEdgeCurves();
fixWire.FixDegenerated();
fixWire.FixSelfIntersection();
fixWire.FixClosed();

if(!fixWire.Perform())
{
Standard_Failure::Raise("Perform return false");
}

TopoDS_Wire wire = fixWire.WireAPIMake();

Any idea?
Thanks.

JuryS's picture

If you are need rebuild any wire you may use something like this:

if(!myWire.Closed())
{
Standard_Real tol = 0.01;
BRepBuilderAPI_MakeWire brepMake;
ShapeFix_ShapeTolerance FTol;
TopExp_Explorer ExpEdges;

TopoDS_Shape section = myShape->Get();

Handle(ShapeExtend_WireData) sbwd1 = new ShapeExtend_WireData();
for (ExpEdges.Init(section, TopAbs_EDGE); ExpEdges.More(); ExpEdges.Next())
{
const TopoDS_Edge& Edge = TopoDS::Edge(ExpEdges.Current());
sbwd1->Add(Edge);
}

Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
sfw->Load(sbwd1);
sfw->Perform();
//Reorder edges is very important
sfw->FixReorder();
sfw->SetMaxTolerance(tol);

for (int i = 1; i <= sfw->NbEdges(); i ++)
{
TopoDS_Edge Edge = sfw->WireData()->Edge(i);
FTol.SetTolerance(Edge, tol, TopAbs_VERTEX);
brepMake.Add(Edge);
}

myWire = brepMake.Wire();
}

and then build face with BRepBuilderAPI_MakeFace(myWire);

but really you don't need this, in my case I'm use this method only with OCC ver 6.3.0 because I can't make some faces with arc wires, but now (ver 6.5.0 or higher) you may check only closed wire and planar for building correct faces and you don't need any checks if you build face from Splines or Bezier curves

PG's picture

....
....
gp_Circ circ(ax2, 200);
TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(circ);
...

Looks like u may have to 'trim/bound' it between 'parameters'
the gp_circ instance before u use it to make an 'edge'.

Please look at the documentation of BRepBuilderAPI_MakeEdge constructor's.
- PG

Forum supervisor's picture

Dear Gustavo,
You should more carefully check your idea and modeling steps.
It is not clear why do you want to fix just created edge?
It should be valid by definition. You may check it using BRepCheck_Analyzer.
See below Draw reproducer allowing to build the expected face from the initial circle:

pload ALL
circle c1 0 0 0 0 0 1 200
mkedge e1 c1
wire w1 e1
don w1
mkplane face1 w1
don face1
checkshape face1
## => This shape seems to be valid

You may easy check it.
Regards

PG's picture

Dear supervisor,
'circle' command uses another constructor 'Geom_Cicle'
but Gustavo's concern is with 'gp_Circ' circle.
- pg

Forum supervisor's picture

Dear PG,
It's nothing change.
Geom_Circle has constructor accepting gp_Circ
as input parameter. So, you can easy check it
if you want.
Regards