From 3bccd6686a72d1c5c19beaf65ec67a8766064340 Mon Sep 17 00:00:00 2001 From: Ajinkya Dahale Date: Thu, 22 Dec 2022 01:08:49 +0530 Subject: [PATCH] [Sketcher] Do not use `TangentViaPoint` for tangent-at-knot --- src/Mod/Sketcher/App/Sketch.cpp | 27 ++++++++++---------- src/Mod/Sketcher/Gui/CommandConstraints.cpp | 28 +-------------------- 2 files changed, 14 insertions(+), 41 deletions(-) diff --git a/src/Mod/Sketcher/App/Sketch.cpp b/src/Mod/Sketcher/App/Sketch.cpp index 8ac5eeb150..06547a6e2a 100644 --- a/src/Mod/Sketcher/App/Sketch.cpp +++ b/src/Mod/Sketcher/App/Sketch.cpp @@ -1722,27 +1722,26 @@ int Sketch::addConstraint(const Constraint *constraint) //simple tangency rtn = addTangentConstraint(constraint->First,constraint->Second); } - else { + else if (constraint->FirstPos == PointPos::start && + constraint->SecondPos == PointPos::none && + constraint->Third == GeoEnum::GeoUndef) { // check for B-Spline Knot to curve tangency - if (constraint->FirstPos == PointPos::none && - constraint->SecondPos == PointPos::none && - constraint->ThirdPos == PointPos::start) { - auto knotgeoId = checkGeoId(constraint->Third); - if (Geoms[knotgeoId].type == Point) { - auto *point = static_cast(Geoms[knotgeoId].geo); + auto knotgeoId = checkGeoId(constraint->First); + if (Geoms[knotgeoId].type == Point) { + auto *point = static_cast(Geoms[knotgeoId].geo); - if (GeometryFacade::isInternalType(point,InternalType::BSplineKnotPoint)) { - auto bsplinegeoid = internalAlignmentGeometryMap.at(constraint->Third); + if (GeometryFacade::isInternalType(point,InternalType::BSplineKnotPoint)) { + auto bsplinegeoid = internalAlignmentGeometryMap.at(constraint->First); - bsplinegeoid = checkGeoId(bsplinegeoid); + bsplinegeoid = checkGeoId(bsplinegeoid); - auto linegeoid = checkGeoId(constraint->Second); + auto linegeoid = checkGeoId(constraint->Second); - return addTangentLineAtBSplineKnotConstraint(linegeoid, bsplinegeoid, knotgeoId); - } + rtn = addTangentLineAtBSplineKnotConstraint(linegeoid, bsplinegeoid, knotgeoId); } } - + } + else { //any other point-wise tangency (endpoint-to-curve, endpoint-to-endpoint, tangent-via-point) c.value = new double(constraint->getValue()); if(c.driving) diff --git a/src/Mod/Sketcher/Gui/CommandConstraints.cpp b/src/Mod/Sketcher/Gui/CommandConstraints.cpp index ec3e50a336..4e5e680b18 100644 --- a/src/Mod/Sketcher/Gui/CommandConstraints.cpp +++ b/src/Mod/Sketcher/Gui/CommandConstraints.cpp @@ -4226,33 +4226,7 @@ void CmdSketcherConstrainTangent::activated(int iMsg) } if (isSimpleVertex(Obj, GeoId1, PosId1)) { - if (isBsplineKnot(Obj, GeoId1)) { - // find the B-spline and treat as TangentViaPoint - openCommand(QT_TRANSLATE_NOOP("Command", "Add tangent constraint")); - const std::vector &constraints = Obj->Constraints.getValues(); - for (const auto& constraint: constraints) { - // TODO: wrap around with try-catch - if (constraint->Type == Sketcher::ConstraintType::InternalAlignment && - constraint->First == GeoId1 && - constraint->AlignmentType == Sketcher::InternalAlignmentType::BSplineKnotPoint) { - int GeoId3 = constraint->Second; - // TODO: ensure C1 continuity at point - if(! IsPointAlreadyOnCurve(GeoId2, GeoId1, PosId1, Obj)){ - Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - GeoId1,static_cast(PosId1),GeoId2); - } - - Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('TangentViaPoint',%d,%d,%d,%d)) ", - GeoId3,GeoId2,GeoId1,static_cast(PosId1)); - commitCommand(); - tryAutoRecompute(Obj); - - getSelection().clearSelection(); - return; - } - } - } - else { + if (!isBsplineKnot(Obj, GeoId1)) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Cannot add a tangency constraint at an unconnected point!")); return;