Get the Vector of Edge On Face

Hi. I make a face object made of lots of edge. I want to calculate normal vector to each edge. In my opinion, To caclulate it, maybe need the information about the each edge direction or vector. so I use the TopExp_Explorer class.

TopExp_Explorer a;
for(a.Init(TopoDSShape, TopAbs_Vertex); a.More(); a.Next())
{

TopoDS_Shape CurrentShape = a.Current();

..
..
..
}

so. I Get the CurrentShape. But I don't know how to convert TopoDS_Vertex to gp_Pnt.

If there is no way to convert, would you suggest a idea ?

have a nice day

jelle's picture

def vertex2pnt(vertex):
'''returns a gp_Pnt from a TopoDS_Vertex
'''
from OCC.BRep import BRep_Tool
return BRep_Tool.Pnt(vertex)

shudolf's picture

Thanks alot.

using this method, i can make a gp_Vec or gp_Dir.

Yeon cheol

Heinz R.'s picture

Hi,

if you have already the faces belonging to the the edges, you can also try the static methods of  TopOpeBRepBuild_Tools class:

  • TopOpeBRepBuild_Tools::GetNormalToFaceOnEdge(const TopoDS_Face& aFObj,const TopoDS_Edge& anEdgeObj,gp_Vec& aDirNormal) ;

 or:

  • TopOpeBRepBuild_Tools::GetNormalInNearestPoint(const TopoDS_Face& aFace,const TopoDS_Edge& anEdge,gp_Vec& aNormal) ;

look also in the docs.

nice day

H1