Get belonging face to an edge?

Hi,

i am new to opencascade, i try to import a step file and then i use TopExp_Explorer to get all TopoDS_Edge elements, then i use it again to get all TopoDS_Face elements.

What i want to do now is: when a user selects one of the Edges, i want to select all connected Edges.

So the fist question is: Is there already some functionality like 'get all connected edges(TopoDS_Edge)'?

If not, my idea was, to simply iterate over all Edges of a Face, get each edge's first and last point, and then match all edges that are connected to these points in a recursive manner so at the end i have all edges directly or indirectly connected to the selected one.

The Question on this approach would be: How can i get the TopoDS_Face an TopoDS_Edge belongs to?

Thank you,

 

Benjamin Bihler's picture

Hi,

you have to create an edge-face-map before to do that quickly. You might want to try the following code snippets.

Benjamin

---

    TopTools_IndexedDataMapOfShapeListOfShape edgeFaceMap;

---

    TopExp::MapShapesAndAncestors(shell, TopAbs_EDGE,
            TopAbs_FACE, edgeFaceMap);

---

        // Find adjacent face
        bool faceFound = TopOpeBRepBuild_Tools::GetAdjacentFace(face, boundaryEdge,
                edgeFaceMap, targetFace);

        if (!faceFound)
        {
            // This happens, if the part boundary was reached.
            return false;
        }

---

Heiko Irrgang's picture

Thank you very much, works.