A question was asked how to split a single Bezier curve into two segments. To start off, a Bezier curve is nothing but a special case of a spline curve, so if we know how to split a spline curve, we're done. From the theory (The NURBS Book, sec. 5.2.), it's known that to split a spline curve we need to insert knots, decreasing the smoothness of a curve until it falls apart. In Analysis Situs, it is done with theHow to split a Bezier curve into pieces?
split-curve-bezier
command:Here is an illustration from the NURBS Book:
Let's create a B-spline curve for testing:
C++:
// Control points.
TColgp_Array1OfPnt poles(1, 5);
poles(1) = gp_Pnt(0., 0., 0.);
poles(2) = gp_Pnt(1., 0.5, 0.);
poles(3) = gp_Pnt(2., 1.5, 1.);
poles(4) = gp_Pnt(2.5, 2.5, 1.5);
poles(5) = gp_Pnt(3.5, 1., 0.5);
//
const int n = poles.Upper() - 1;
// Basis spline degree.
const int p = 3;
// Knots.
TColStd_Array1OfReal knots(1, 3);
knots(1) = 0.;
knots(2) = 0.5;
knots(3) = 1.;
// Multiplicities.
TColStd_Array1OfInteger mults(1, 3);
mults(1) = 4;
mults(2) = 1;
mults(3) = 4;
// Create B-spline curve
Handle(Geom_BSplineCurve)
bcurve = new Geom_BSplineCurve(poles, knots, mults, p);
Here's is how it looks like:
Inserting a knot `degree + 1` times between the existing knots will lead to subdividing. Actually, it's just necessary to obtain `degree + 1` multiplicity at the division knot. Then, you could construct two new curves to represent the subdivision result.
To insert a knot, use
InsertKnot()
method of Geom_BSplineCurve
.Attachments
Last edited: