I'm using OpenCascade to get edge vertices in a triangulation. For this I use the help of an edge-to-face map with edges as keys to the matching faces. However, I would also like to get the numeric index of the face in the parent shape (the face number if I for example use TopoDS::Face(face_map(int face_number))
).
TopTools_IndexedMapOfShape edges;
TopExp::MapShapes (parent_shape, TopAbs_EDGE, edges);
TopTools_IndexedDataMapOfShapeListOfShape edge2FaceMap;
TopExp::MapShapesAndAncestors(shape, TopAbs_EDGE, TopAbs_FACE, edge2FaceMap);
for (int iedge = 1; iedge <= edges.Extent(); iedge++) {
const TopoDS_Edge& edge = TopoDS::Edge(edges(iedge));
const TopoDS_Face& face = TopoDS::Face(edge2FaceMap.FindFromKey(edge).First());
// Get vertices...
}
I can loop over all faces and match the mapped face, but this seems quite inefficient.
TopTools_IndexedMapOfShape face_map;
TopExp::MapShapes(shape, TopAbs_FACE, face_map);
for (v = 1; face_number <= face_map.Extent(); face_number++) {
if( face.IsSame(face_map(face_number)) ) {
// Found face index.
}
}
Is there a better or alternative approach to achieve this?