How to transforme a TopoDS_Shape into a TopoDS_Edge

Hello,

I want to convert a TopoDS_Shape into a TopoDS_Edge. So I use the following instructions :

Handle (TopoDS_TEdge) newEdge= Handle (TopoDS_TEdge) :: DownCast (oldShape);
or
Handle (PTopoDS_TEdge) newEdge= Handle (PTopoDS_TEdge) :: DownCast (oldShape);
or
Handle (PTopoDS_TEdge1) newEdge= Handle (PTopoDS_TEdge1) :: DownCast (oldShape);

And I have include the following librairie :
#include "Handle_TopoDS_TEdge.hxx"
#include "Handle_PTopoDS_TEdge.hxx"
#include "Handle_PTopoDS_TEdge1.hxx"

But none of those commands work.

Do you have an Idea ?
Thanks for your attention

Jean-Sébastien Klein Meyer

Joe's picture

Hi
Try this.
TopoDS_Edge newEdge;
if (oldShape.ShapeType()==TopAbs_EDGE)
newEdge=TopoDS::Edge(oldShape);

Joe

JSKM's picture

hey,

thanks for your idea, unfortunately it doesn't work :
if (oldShape.ShapeType()==TopAbs_EDGE))
--> this expression is always "false
Jean-Sébastien Klein Meyer

Vivek Verma's picture

see if this works:

TopoDS_Shape myShape = ...;
.
.
.
for (TopExp_Explorer exp (myShape,TopAbs_Edge);exp.More();exp.Next())
{
TopoDS_Edge aCurrentEdge = TopoDS::Edge(exp.Current());
// do whatever with this edge
}

-vivek

Shizhou Luo's picture

Hi, JSKM! It's been a long time since you post your question.
Have you put the "#include <TopoDS.hxx>" header file at the beginning?
This is my code segment and it works:
TopExp_Explorer edgeExp1(topoNURBSSurface1, TopAbs_EDGE);
TopoDS_Edge surface1_edge1 = TopoDS::Edge(edgeExp1.Current());
Best Regards!