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