BRepBuilderAPI_MakeFace precision

Is there any way to set the planar tolerance for BRepBuilderAPI_MakeFace()?

I would like to be able to alter the tolerance for what is considered on and off the plane?

BRepBuilderAPI::Precision(Standard_Real xx) does not seem to do the trick.

Stephen

Pawel's picture

Hi Stephen,

maybe you could try ShapeFix_ShapeTolerance.

Pawel

Stephen Leary's picture

Thanks Pawel,

I will try this. Its my (limited) understanding that ShapeFix_ShapeTolerance alters shape? Is this true?

For various reasons I am not allwoed to alter the data i simply want to treat it as a plane with a given tolerance.

Stephen

Pawel's picture

Hi Stephen,

I guess changing the tolerance of a face might alter the whole shape.

Refer to Roman's blog here: http://opencascade.blogspot.com/2009/02/continued.html

It might help.

Pawel

Stephen Leary's picture

Thanks again,

That would be true only if you snapped vertices onto the face. Here i am refering to how cascade decides whether a shape is planar or not.

Provided all the vertices are within a tolerance distance of a plane i would not expect an error to be thrown. It may be true that as you add points the best fit plane is different.

Oracle 3D Validators manage to provide arbitrary tolerance for planes, I was looking for something similar.

Stephen

Stephen Leary's picture

double myTolerance = 0.00001; // vary this
TopoDS_Vertex v1 = newVertex(0,0,0);
TopoDS_Vertex v2 = newVertex(0,1,0);
TopoDS_Vertex v3 = newVertex(1,1,0);
TopoDS_Vertex v4 = newVertex(1,1,0.0001);

TopoDS_Edge e1 = newEdge(v1,v2);
TopoDS_Edge e2 = newEdge(v2,v3);
TopoDS_Edge e3 = newEdge(v3,v4);
TopoDS_Edge e4 = newEdge(v4,v1);

BRepBuilderAPI_MakeWire mWire(e1,e2,e3,e4);

// create a tolerance object
ShapeFix_ShapeTolerance FTol;
// get the wide
TopoDS_Wire wire = mWire.Wire();
// set the tolerance for this shape.
FTol.SetTolerance(wire, myTolerance ,TopAbs_WIRE);

// make the face with this tolerance
BRepBuilderAPI_MakeFace mFace(wire);

if (mFace.IsDone())
{
cout << "Done" << endl;
}
else
{
cout << BRepBuilderAPI_NotPlanar << endl;
cout << mFace.Error() << endl;
cout << "Failed" << endl;
}

Stephen Leary's picture

The example above (which i accidentally submitted) shows how to set the precision / tolerance for makeface or BRepBuilderAPI_MakeFace

Stephen

Sharad Verma's picture

Setting Tolerance really worked for my case.

Thanks Stephen

WenBo Zhang's picture

when I use BRepBuilderAPI_MakeFace to define face from wire, the face sides have some little segments.
And, the shape of face is mostly different from wire.

i changed the tolerance of wire and no affects.

how to do???

Attachments: 
Dmitrii Pasukhin's picture

Hello, can you share your wire as .brep file? Using "BRepTools::Write"

Can you make a look into: Wire to Face not working properly - Forum Open Cascade Technology

Best regards, Dmitrii.

WenBo Zhang's picture

I have fixed this mistake.

The wire order is wrong, which means edges of wire are not connected correctly.
using ShapeAnalysis_Wire::CheckOrder() to check order,
then ShapeFix_Wire::FixReorder() to repair it.