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;
        }

---

Thomas Hafemann's picture

Unfortunately this will not work for my case:

I saved the geometry created with OCCT in a Step file and read the file in a different session.
For some reason there are twice as much edges as there should be, ehre each face has its own edge and GetAdjacentFace only finds this face.

By reading the Step file functions such as IsSame will also not work, because they consider the entity and not the spacial/topological information. Since there are actually two edges they cannot be the same. They share same position in space (+- Tolerance). Is there another approach that might work here?

Heiko Irrgang's picture

Thank you very much, works.

vivek varkal's picture

Hi,
I'm new to occ. I read Benjamin's comment, but i still don't know how to do.
Can you tell me how to do it?It would be better if you could show some code.
Thanks!