Thanks Paul.
This seems to be the right equation.
I'm now have a case where there are faces to be added with the vertices added in reverse order. However, after creating the shape, when I try to iterate over the faces, I'm getting an exception when accessing these faces.
I created a method called IsReverse() which performs the calculation that you suggested.
Here's how I'm creating the face:
TopoDS_Vertex v1 = BRepBuilderAPI_MakeVertex(point1);
TopoDS_Vertex v2 = BRepBuilderAPI_MakeVertex(point2);
TopoDS_Vertex v3 = BRepBuilderAPI_MakeVertex(point3);
TopoDS_Wire wire;
if (IsReverse(mesh->GetFaceNormal(faceIndex), point1, point2, point3))
{
wire = BRepBuilderAPI_MakePolygon(v3, v2, v1, Standard_True);
}
else
{
wire = BRepBuilderAPI_MakePolygon(v1, v2, v3, Standard_True);
}
face = BRepBuilderAPI_MakeFace(wire, Standard_True);
~~~~~~~~~~~~~~
I'm also needing to use BRepOffsetAPI_Sewing and adding the faces to it in order to create either a shell or composite shape (since the faces I'm iterating over may not be added in the correct order).
I then triangulate the shape as:
BRepMesh::Mesh(shape, 1);
Then, I'm iterating over the faces as follows:
for (TopExp_Explorer ex(shape, TopAbs_FACE); ex.More(); ex.Next())
{
TopoDS_Shape currentShape = ex.Current();
TopoDS_Face face = TopoDS::Face(currentShape);
Handle (Poly_Triangulation) facing = BRep_Tool::Triangulation(face, location);
facing->NbTriangles();
}
~~~~~~~~~~~~
When it gets to the reversed face, the last line here throws an exception- presumably because the face is invalid. I.e. calling methods on facing throws an exception.
Do you know of another call that I may be missing when adding the face, or anything else you can tell that I'm doing wrong? I've tried calling the following just after creating the face (if it is reversed):
face.Orientation(TopAbs_REVERSED);
I'm still seeing the same behavior.