# Triangulation of simple face.

Hello,

I have a problem triangulating a simple quad polygon/face. The following code produces IMO false result:

//--------------------------------------------------

gp_Pnt p0(0.0, 0.0, 0.0);
gp_Pnt p1(1.0, 0.0, 0.0);
gp_Pnt p2(1.0, 1.0, 0.0);
gp_Pnt p3(0.0, 1.0, 0.0);

Handle(Geom_TrimmedCurve) seg0 = GC_MakeSegment(p0, p1);
Handle(Geom_TrimmedCurve) seg1 = GC_MakeSegment(p3, p2);
TopoDS_Edge edge0 = BRepBuilderAPI_MakeEdge(seg0);
TopoDS_Edge edge1 = BRepBuilderAPI_MakeEdge(seg1);
const TopoDS_Face face = BRepFill::Face(edge0, edge1);
TopLoc_Location loc;
double accuracy = 0.01;
BRepMesh::Mesh(face, accuracy);

TopExp_Explorer expl;
for (expl.Init(face, TopAbs_FACE); expl.More(); expl.Next())
{
TopoDS_Face f = TopoDS::Face(expl.Current());
Handle(Poly_Triangulation) triangulation = BRep_Tool::Triangulation(f, loc);
const Poly_Array1OfTriangle &triangles = triangulation->Triangles();
for (int i=1; i {
int n1,n2,n3;
if (f.Orientation() == TopAbs_REVERSED )
triangles(i).Get(n3,n2,n1);
else
triangles(i).Get(n1,n2,n3);

std::cout }

}

//--------------------------------------------------

I think triangulating polygon with four vertices should produce two triangles. Running the above program tells me:

triface 4 1 2

where as expected results would be:

triface 4 1 2
triface 4 2 3

There must be something simple I forgot to do, I really would appreciate if you could point the err of my ways.

Best regards,

Niko I forgot to mention that I am using the pre-built developer libraries on Ubuntu 12.10, could there be some clue why this do not work for me?

Best regards,

Niko