# Order reduction Bezier Curve

Dear Sirs,

I am wondering: is there any method in OCC which allows the user to reduce the degree of a Bezier Curve? For instance from n to q with q

Thanks a lot for your help,
Kind regards,
P Dear Paolo,

degree reduction of a given Bezier curve is possible by approximation with the help of class GeomConvert_ApproxCurve, which allows to restrict the result degree by setting the needed value of MaxDegree input parameter (see documentation for this class).
Since the result of this algorithm is a BSpline curve, then it is possible to get a set of Bezier curves with the help of GeomConvert_BSplineCurveToBezierCurve class. This algorithm does not change the initial degree of the input BSpline curve.
For 2d Bezier curves it is necessary to use the corresponding algorithms from Geom2dConvert package.
Practically all OCCT methods for approximation of a set of points allow to restrict the result degree using input parameters.
If you need to get an approximation of a set of control points, you can use API level classes GeomAPI_PointsToBSpline for 3d points or Geom2dAPI_PointsToBSpline for 2d and then convert the results to a set of Bezier curves.
Low level approximation algorithm AppDef_Compute (instantiation of Approx_ComputeLine) allows to approximate a set of control points by sequence of Bezier curves with a required degree, which is defined by input parameters degreemin and degreemax.

Regards,
Forum Supervisor Dear Supervisor,

thanks for your clear response. I will test the GeomConvert_ApproxCurve class w.r.t to the least squares approximation I have manually implemented. I would prefer something more "stable" than my little implementation.

I still have got one question though. Would it be possible to merge Bezier curves? Let me explain it better: I have 2 Bezier of different degree (e.g. 4 and 5). Could I merge the two curves to a unique curve of degree 5? I have done some reading on the approximate merging of Bezier curve and it would be lovely if there is a tool for doing that in OCC.

Thanks a lot.
Kind regards,

Paolo Dear Paolo,

OCCT has a tool just for merging a sequence of Bezier curves into one BSpline curve, see class Convert_CompBezierCurveToBSplineCurve.
To get one Bezier curve from some Bezier curves it is possible:
1. To use class Convert_CompBezierCurveToBSplineCurve to get one BSpline curve from a sequence of Bezier ones.
2. To use class GeomConvert_ApproxCurve with the parameter MaxSegment = 1 for BSpline curve approximation in order to get a new BSpline curve with one knot span only.
In fact, this new BSpline curve is a Bezier curve and you can convert it into Bezier with the help of class GeomConvert_BSplineCurveToBezierCurve.

Best regards,
Forum Supervisor Thanks a lot!! I will check it against my least squares algorithm for merging curves!