### [Sketcher] Constraints on b-spline knots with max multiplicity

Posted:

**Sat Feb 26, 2022 1:34 pm**When a knot in a b-spline is repeated "m" times where "m = degree of the spline", something interesting happens: the knot point is now coincident with a control point (a.k.a. pole). This can be useful if we want the b-spline to pass through a certain point, or to apply any other constraint we want by applying that on the control point(NOTE: remember we still lose the C1 continuity at the knot).

In Sketcher's implementation of b-splines, however, we encounter an issue. Only one of the coincident points can be selected and currently that is the knot, so only operations that can act on them (viz. multiplicity change) can be performed. Realthunder does have some fixes to select other points (and entities in general) when possible, but he will not be doing that for 0.20 [1]. So right now I am trying to make a workaround that will be usable with what we have right now.

The first option is to bring the control points to the "front" so they are what are selected instead of the knots. However, doing this will cause a problem when trying to change the knot's multiplicity, so we have just "inverted" the problem. So instead what I am trying to do is to implement a getConstrainableVertex() method so that if Sketcher notices the user is trying to constrain a knot, it tries to look for alternatives before cancelling the operation. This involves the following steps:

In Sketcher's implementation of b-splines, however, we encounter an issue. Only one of the coincident points can be selected and currently that is the knot, so only operations that can act on them (viz. multiplicity change) can be performed. Realthunder does have some fixes to select other points (and entities in general) when possible, but he will not be doing that for 0.20 [1]. So right now I am trying to make a workaround that will be usable with what we have right now.

The first option is to bring the control points to the "front" so they are what are selected instead of the knots. However, doing this will cause a problem when trying to change the knot's multiplicity, so we have just "inverted" the problem. So instead what I am trying to do is to implement a getConstrainableVertex() method so that if Sketcher notices the user is trying to constrain a knot, it tries to look for alternatives before cancelling the operation. This involves the following steps:

- Find the index of the knot in the b-spline and check it's multiplicity. Proceed only if it's high enough.
- Find the index of the control point that controls this knot point in the b-spline .
- Apply the constraint on the point.

- How to find the index of the knot without going through all the constraints? There is a relatively quick way to see a given sketcher vertex is a knot using GeometryFacade::getInternalType() but no way to find the internal position itself there.
- How to find the corresponding index of the pole? This is just math though so it can be done quickly.
- How to find the sketcher vertex for the pole? This is the reverse of 1. and can be done by a search but there might be a faster way.
- Do we really change from knots to poles all the time? Certain constraints can still be applied to knots if they are "non-driving". If the constraints are being created in "driving" mode, the user's intention is clear. However if the constraints are being created in "non-driving" mode, then the user may want to just get the coordinates of the knot or such. For the case of coordinates, even if there is a pole on the knot, one can decrease it's multiplicity and still want the new coordinates of the knot point.