# How to convert a trimmedCurve on an arc of circle

Hi,

I've selected an edge (TopoDS_Edge) on the screen witch is in reality an arc of a circle.

How can I convert this edge to obtain the circle arc informations (gp_Pnt, Radius...).

GeomAbs_CurveType theCurveType = bac.GetType();
if ( theCurveType == GeomAbs_Circle )
{
gp_Circ theCircle = bac.Circle();
}

should work

HTH,

Stephane

Thank you very much Stephane it works,

Kreshnik HASANI

Hi,

This method works on imported step files witch contents a CIRCLE element. I'm importing a step file which has no CIRCLE element in its step description. However in the screen I can see circles. When I try to get these circles with this method it doesn't work. The edge is not a GeomAbs_Circle.

How can I get these circles ?

Kreshnik HASANI

I finally found the solution.

The arc is if fact in this case a BSpline curve. So I have to convert it in a circle to get its radius.

I use tis code :

// Conversion du format de l'arrete
GeomAbs_CurveType theCurveType = bac.GetType();

if (theCurveType == GeomAbs_Circle)
{
// Obtention du rayon de l'arc de cercle
gp_Circ theCircle = bac.Circle();
Message = str_col;
}else if((theCurveType != GeomAbs_Line) && (theCurveType != GeomAbs_Ellipse) && (theCurveType != GeomAbs_Hyperbola) && (theCurveType != GeomAbs_Parabola) && (theCurveType != GeomAbs_BezierCurve) && (theCurveType != GeomAbs_OtherCurve))
{

// Obtention des deux extremités
Standard_Real First,Last;
Handle(Geom_Curve) myCurve = BRep_Tool::Curve(myEdge, First, Last);
Handle(Geom_TrimmedCurve) myTrimmed = new Geom_TrimmedCurve(myCurve, First, Last);
gp_Pnt pt_start = myTrimmed->StartPoint();
gp_Pnt pt_end = myTrimmed->EndPoint();

// Conversion en BSplineCurve
Handle(Geom_BSplineCurve) myBSplCurve = GeomConvert::CurveToBSplineCurve(myTrimmed);

// Récuperation de deux pôles
Standard_Integer nb_poles = myBSplCurve->NbPoles();
gp_Pnt pt_pole1 = myBSplCurve->Pole(2);
gp_Pnt pt_pole2 = myBSplCurve->Pole(nb_poles-1);

// On projette les pôles sur la courbe
GeomAPI_ProjectPointOnCurve proj1;
GeomAPI_ProjectPointOnCurve proj2;
proj1.Init(pt_pole1, myCurve, First, Last);
proj2.Init(pt_pole2, myCurve, First, Last);

// On recupere les points de projection
gp_Pnt pt_curve1 = proj1.NearestPoint();
gp_Pnt pt_curve2 = proj2.NearestPoint();

// On crée deux cercles et on recupere les rayons respectifs
gce_MakeCirc gce_circ1 = gce_MakeCirc(pt_start,pt_end,pt_curve1);
gp_Circ circle1 = gce_circ1.Value();
gce_MakeCirc gce_circ2 = gce_MakeCirc(pt_start,pt_end,pt_curve2);
gp_Circ circle2 = gce_circ2.Value();

// On teste que les cercles soient bien crées et egaux
if ((gce_circ1.Status() == gce_Done) && (gce_circ2.Status() == gce_Done) && (fabs(radius2-radius1) < 0.01))
{
// On recupere et returne le rayon