Search code examples
c++opencascade

How to find out the coordinates of the two vertices of a TopoDS_Edge (Openscascade)?


I want to find out the coordinates of the two vertices of a TopoDS_Edge. I couldn't find any solution on the Public Member Functions list on https://dev.opencascade.org/doc/refman/html/class_topo_d_s___edge.html


Solution

  • With this you can get the vertices of any topological object in OpenCascade:

    TopoDS_Edge edge;
    for (TopExp_Explorer ex(edge, TopAbs_VERTEX); ex.More(); ex.Next())
    {
        gp_Pnt point = BRep_Tool::Pnt(TopoDS::Vertex(ex.Current()));
        double xCoord = point.X(); 
    }
    

    This is also capable of iterating over other types of topological entities like edges in a body when you replace TopAbs_VERTEX with TopAbs_EDGE.