Single-edge face triangulation fails

I have a TopoDS_Edge which is a circle, and has the same vertex on both ends.

I put this edge into a wire, using BRepBuilderAPI_MakeWire, and then create a face from the wire using BRepBuilderAPI_MakeFace. This succeeds (i.e. MakeFace.IsDone() is true).

When I try to use BRep_Tool::Triangulation however, it fails.

The funny thing is, when I read this same circular face from a STEP file, created externally, the triangulation is fine.

Any thoughts on what's going on? Should I be using a different mechanism to create the face such as GeomPlate_BuildPlateSurface?

Thorsten H's picture

This works for me (OCCT 6.5.1, VS2010, x86):

// face
gp_Pnt center(0,0,0);
gp_Circ circ(gp_Ax2(center, gp::DZ()), 100.0);
TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(circ);
BRepBuilderAPI_MakeWire mkWire;
TopoDS_Face face = BRepBuilderAPI_MakeFace(mkWire.Wire());

// triangulation
BRep_Builder builder;
TopoDS_Compound compound;
TopLoc_Location L; //= TopLoc_Location();
Handle(Poly_Triangulation) triangulation = BRep_Tool::Triangulation(face, L);

// check result
if (!triangulation.IsNull())
int nbTriangles = triangulation->NbTriangles();
const Poly_Array1OfTriangle & triangles = triangulation->Triangles();
const TColgp_Array1OfPnt & nodes = triangulation->Nodes();
for (int i = 1; i <= nbTriangles; i++)
Poly_Triangle triangle = triangles(i);

Standard_Integer node1,node2,node3;
triangle.Get(node1, node2, node3);

gp_Pnt v1 = nodes(node1);
gp_Pnt v2 = nodes(node2);
gp_Pnt v3 = nodes(node3);

TopoDS_Edge e1 = BRepBuilderAPI_MakeEdge(v1,v2);
TopoDS_Edge e2 = BRepBuilderAPI_MakeEdge(v2,v3);
TopoDS_Edge e3 = BRepBuilderAPI_MakeEdge(v3,v1);
TopoDS_Wire w = BRepBuilderAPI_MakeWire(e1, e2, e3);
TopoDS_Face fTriangle = BRepBuilderAPI_MakeFace(w);

builder.Add(compound, fTriangle);
if (nbTriangles > 0)
Handle_AIS_Shape aisShape = new AIS_Shape(compound);

nandy's picture

TopLoc_Location L1;