Problem to get the curve from an edge in wire created by BRepBuilderAPI_MakeEdge2d

As write in the title i get some problem to work with edge in a wire created by the function BRepBuilderAPI_MakeEdge2d in spite of BRepBuilderAPI_MakeEdge.

First in function of differents case i create theses types of edge :

gp_Pnt2d point1,point2;
- 2 points : BRepBuilderAPI_MakeEdge2d edgeConstruct(point1,point2);
- a segment of line :
gp_Lin2d line;
Handle(Geom2d_Curve) line2d = new Geom2d_Line(line);
BRepBuilderAPI_MakeEdge2d edgeConstruct(line2d,point1,point2);
- an arc :
gp_Circ2d circle;
Handle(Geom2d_Curve) circle2d = new Geom2d_Circle(circle);
BRepBuilderAPI_MakeEdge2d edgeConstruct(circle2d ,point1,point2);

Next i add the differents edges in a wire :
if (edgeConstruct.IsDone())
{
makeWire.Add(edgeConstruct.Edge());
}

My problem start after the creation of the wire.
The wire is correct, it corresponds exactly at what i want (i check it by creating a brep file and loading it in the example of OpenCascade)

My aim is to recuperate the differents edge and to display them.

So i use a TopExp_Explorer like this :

TopExp_Explorer contourExp;
Standard_Real firstParam, lastParam;
TopoDS_Edge edge;

for (contourExp.Init(myWire,TopAbs_EDGE); contourExp.More() ; contourExp.Next())
{

edge = TopoDS::Edge(contourExp.Current());
//Until this point all is ok but i don't know how to recuperate geometry of arc type.

If it is only segment no hay problem i do that and i can display it without problem
TopoDS_Vertex vertex1 = TopExp::FirstVertex(edge);
TopoDS_Vertex vertex2 = TopExp::LastVertex(edge);
gp_Pnt pnt3D1 = BRep_Tool::Pnt( vertex1 );
gp_Pnt pnt3D2 = BRep_Tool::Pnt( vertex2 );
gp_Pnt2d pnt1(pnt3D1.X(),pnt3D1.Y());
gp_Pnt2d pnt2(pnt3D2.X(),pnt3D2.Y());
But with a wire more complex with an arc i need to recuperate the geometry 2D, know which type of curve it is (basically segment or arc) to know how to display it (i use my own display)

I've try that but it doesn't work the curve3D object is garbage.
Handle(Geom_Curve) curve3D = BRep_Tool::Curve(edge,firstParam,lastParam);
Handle(Geom2d_Curve) curve2D = GeomAPI::To2d(curve3D,gp_Pln(gp::XOY()));

So i would like to know how to recuperate from an edge created by a BRepBuilderAPI_MakeEdge2d the type of the edge (segment, arc, circle etc...) to call my function of drawing (for instance if it is an arc i need the extremities point and the center of the arc to display it)

Thanks in adavance

Steph's picture

I can interest someone i've found how to do :

TopoExp_Explorer contourExp;
//My wire
TopoDS_Wire wire....;
TopoDS_Edge edge;

for (contourExp.Init(wire,TopAbs_EDGE); contourExp.More() ; contourExp.Next())
{
edge = TopoDS::Edge(contourExp.Current());

Handle(Geom2d_Curve) curve2D;
Handle(Geom_Surface) surface;
TopLoc_Location location;
Standard_Real First;Standard_Real Last;

BRep_Tool::CurveOnSurface(edge,curve2D,surface,location,First,Last);

Geom2dAdaptor_Curve adaptedCurve(curve2D);
GeomAbs_CurveType curveType = adaptedCurve.GetType();

gp_Pnt2d pnt1,pnt2;

adaptedCurve.D0(First,pnt1);
adaptedCurve.D0(Last,pnt2);

switch (curveType)
{
case GeomAbs_Line:
{
DrawSegment(pnt1,pnt2);
}
break;

case GeomAbs_Circle:
{
gp_Circ2d circle = adaptedCurve.Circle();
gp_Pnt2d center = circle.Location();
DrawArc(pnt1,pnt2,center);
}
break;

default:
break;
}
}