Subdivide Spline/Bezier curves

Quaoar

Administrator
Staff member
How to split a Bezier curve into pieces?
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 the split-curve-bezier command:

split_bcurve_bezier.gif


Here is an illustration from the NURBS Book:

1623570708634.png

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:

1623572480434.png

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.

1623572503879.png

To insert a knot, use InsertKnot() method of Geom_BSplineCurve.
 

Attachments

  • 1623570104928.png
    1623570104928.png
    71.8 KB · Views: 4
  • 1623571360324.png
    1623571360324.png
    5.7 KB · Views: 2
  • 1623571899403.png
    1623571899403.png
    9.6 KB · Views: 2
  • 1623572310006.png
    1623572310006.png
    72.4 KB · Views: 4
Last edited:
Top