[Sketcher] Allow multiplicity change of B-Spline end knots

The first and last knots (which are often also poles) of a B-Spline are not
represented in sketcher as knots, but as end points of the curve. This creates a
problem when we want to change the multiplicities of those knots. As a
workaround, these points are treated differently.

NOTE: While it is technically possible to have end knots in a non-periodic
spline with degree <= degree of the curve, `Geom_BSplineCurve::RemoveKnot()`
fails for the first and last knots, so we are stuck with this. So, this commit
effectively only makes knot multiplicity change possible for periodic splines.
For non-periodic splines this commit just changes the confusing "no knot is
selected" message to an unhelpful "multiplicity modification failed".
This commit is contained in:
Ajinkya Dahale
2022-02-17 05:44:26 -05:00
committed by abdullahtahiriyo
parent 0a02853bb7
commit 61a7654094
3 changed files with 114 additions and 70 deletions

View File

@@ -221,6 +221,21 @@ bool SketcherGui::isBsplineKnot(const Sketcher::SketchObject* Obj, int GeoId)
return (gf && gf->getInternalType() == Sketcher::InternalType::BSplineKnotPoint);
}
bool SketcherGui::isBsplineKnotOrEndPoint(const Sketcher::SketchObject* Obj, int GeoId, Sketcher::PointPos PosId)
{
// check first using geometry facade
if (isBsplineKnot(Obj, GeoId))
return true;
const Part::Geometry *geo = Obj->getGeometry(GeoId);
// end points of B-Splines are also knots
if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId() &&
(PosId == Sketcher::PointPos::start || PosId == Sketcher::PointPos::end))
return true;
return false;
}
bool SketcherGui::IsPointAlreadyOnCurve(int GeoIdCurve, int GeoIdPoint, Sketcher::PointPos PosIdPoint, Sketcher::SketchObject* Obj)
{
//This func is a "smartness" behind three-element tangent-, perp.- and angle-via-point.