[Sketcher] Use tangent at B-spline knot constraint

Also squashes:

[Sketcher] Make tangent-at-knot with just knot and line

[Sketcher] Disallow tangent at C0 knot

If passed on to planegcs can cause segmentation fault.

[Sketcher] (Re-)Support tangent at B-spline end-knots

New code had introduced problems for non-periodic spline end-points, and
periodic spline "end-points" were not supported anyway.

(here end-points mean star/end points)
This commit is contained in:
Ajinkya Dahale
2022-09-21 20:26:56 +05:30
committed by Chris Hennes
parent 4c71957a97
commit 75f2a1d69a
4 changed files with 94 additions and 8 deletions

View File

@@ -226,8 +226,22 @@ bool SketcherGui::IsPointAlreadyOnCurve(int GeoIdCurve, int GeoIdPoint, Sketcher
//Simple geometric test seems to be the best, because a point can be
// constrained to a curve in a number of ways (e.g. it is an endpoint of an
// arc, or is coincident to endpoint of an arc, or it is an endpoint of an
// ellipse's majopr diameter line). Testing all those possibilities is way
// ellipse's major diameter line). Testing all those possibilities is way
// too much trouble, IMO(DeepSOIC).
// One exception: check for knots on their B-splines, at least until point on B-spline is implemented. (Ajinkya)
if (isBsplineKnot(Obj, GeoIdPoint)) {
const Part::Geometry *geoCurve = Obj->getGeometry(GeoIdCurve);
if (geoCurve->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) {
const std::vector<Constraint *> &constraints = Obj->Constraints.getValues();
for (const auto& constraint: constraints) {
if (constraint->Type == Sketcher::ConstraintType::InternalAlignment &&
constraint->First == GeoIdPoint &&
constraint->Second == GeoIdCurve)
return true;
}
}
}
Base::Vector3d p = Obj->getPoint(GeoIdPoint, PosIdPoint);
return Obj->isPointOnCurve(GeoIdCurve, p.x, p.y);
}