diff --git a/src/Mod/Sketcher/App/Sketch.cpp b/src/Mod/Sketcher/App/Sketch.cpp index 7e548ec499..4bbeb41f7d 100644 --- a/src/Mod/Sketcher/App/Sketch.cpp +++ b/src/Mod/Sketcher/App/Sketch.cpp @@ -4021,6 +4021,66 @@ void Sketch::resetInitMove() isInitMove = false; } +int Sketch::initBSplinePieceMove(int geoId, PointPos pos, const Base::Vector3d& firstPoint, bool fine) +{ + isFine = fine; + + geoId = checkGeoId(geoId); + + clearTemporaryConstraints(); + + // don't try to move sketches that contain conflicting constraints + if (hasConflicts()) { + isInitMove = false; + return -1; + } + + // this is only meant for B-Splines + if (Geoms[geoId].type != BSpline || pos == PointPos::start || pos == PointPos::end) { + return -1; + } + + // Find the closest knot + auto partBsp = static_cast(Geoms[geoId].geo); + double uNear; + partBsp->closestParameter(firstPoint, uNear); + GCS::BSpline &bsp = BSplines[Geoms[geoId].index]; + auto& knots = bsp.knots; + auto upperknot = std::upper_bound( + knots.begin(), knots.end(), uNear, + [](double u, double* element) { + return u < *element; + }); + + size_t idx = 0; + // skipping the first knot for adjustment + // TODO: ensure this works for periodic as well + for (size_t i=1; iinitTemporaryMove(drag.DragCurve, Sketcher::PointPos::none, false); - + if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + getSketchObject()->initTemporaryBSplinePieceMove( + drag.DragCurve, Sketcher::PointPos::none, + Base::Vector3d(drag.xInit, drag.yInit, 0.0), false); + } else { + getSketchObject()->initTemporaryMove(drag.DragCurve, Sketcher::PointPos::none, false); + } } else { Mode = STATUS_NONE; }