I'm trying to use GeomConvert::CurveToBSplineCurve to convert a Handle(Geom_Curve) built from two points, and I have an exception "Standard_DomainError: No such curve"

gp_Pnt P1 ( 0.0, 0.0, 0.0 );
gp_Pnt P4 ( 0.0, 20.0, 0.0 );
const TopoDS_Edge& Line01 = BRepBuilderAPI_MakeEdge ( P1, P4 );
Standard_Real dFirst, dLast;
Handle(Geom_Curve) crv = BRep_Tool::Curve( Line01 , dFirst, dLast );
Handle(Geom_BSplineCurve) bspCrv = GeomConvert::CurveToBSplineCurve( crv );

Could somebody help me in this issue?
Thank You in Advance

Roman Lygin's picture

Hi Macedo,

If you need a B-Spline from 2 points why not to create it directly ? Create TColgp_Array1OfPnt, add your points, add 2 knots (e.g. 0 and 20. which would correspond to parameterization by length), multiplicities (2 in each knot) and degree of 1.

Handle(Geom_BSplineCurve) bspCrv = new Geom_BSplineCurve (...);

In general, to convert a Geom_Line into B-Spline you have to trim it first (Geom_TrimmedCurve (aLine, aFirst, aLast)) before feeding into GeomConvert::CurveToBSplne().

Hope this helps.
--- - the Open CASCADE blog - CAD Exchanger, your 3D data translator

tmacedo29's picture

Thank You Very Much Roman Lygin! It worked great!!