Error creating face from polygon

For some reason, I'm having problems creating faces with particular sets of points.

Here's an example:
gp_Pnt point1 = gp_Pnt(0.95915532112121582, 0.39877992868423462, 0.020832687616348267);
gp_Pnt point2 = gp_Pnt(0.84645986557006836, 0.39877998828887939, 0.020832687616348267);
gp_Pnt point3 = gp_Pnt(0.82415747642517090, 0.39877998828887939, 0.020832687616348267);
TopoDS_Wire wire = BRepBuilderAPI_MakePolygon(point1, point2, point3, Standard_True);
TopoDS_Face face = BRepBuilderAPI_MakeFace(wire, Standard_True);
BRepCheck_Analyzer analyzer(face);

When the last line of code executes, it causes the following error:
008DB86C : Standard_NullObject

It seems that the face wasn't created correctly.
I can't even call face.Closed() without getting an exception.

Does anyone have any ideas why this is failing?
I have 2 other examples of points to add that cause this. If that would help, I'll post these as well.

Stephane Routelous's picture

did you check if the 3 pnts are colinear ?


Volker's picture

Z is constant, delta Y is about 6.0e-8. I assume that Precision::Confusion or a similar constant says, that the three points are collinear and thus the triangle is degenerated.
Either reduce the corresponding tolerance or filter your mesh data before creating TopoDS_Faces's. (Filter each triangle with a side shorter than Precision::Confusion, while collapsing triangles you ought to update neighbouhood informations.)

Roman Lygin's picture


One more hint. Before casting to a TopoDS_Shape you might want to check if the shape has really been created (see BRepBuilderAPI_Command::IsDone()).

BRepBuilderAPI_MakeFace aMF (wire, Standard_True);
TopoDS_Face face;
if (aMF.IsDone()) {
face = aMF; //or aFace = aMF.Shape() for better readability if you want
BRepCheck_Analyzer analyzer(face);


--- - blog on Open CASCADE

Jeff Moody's picture

That's a good tip, and has helped me in debugging.

I resolved this issue by lowering the overall precision by calling:


Jeff Moody's picture

Actually, I'm still having to call IsDone() and discard faces.
Setting the precision did help with other issues- e.g. performing boolean operations.