From 3c74c995f03634d2e01434626a189fd4b7a1cb7f Mon Sep 17 00:00:00 2001 From: David Kaufman Date: Fri, 19 Dec 2025 20:28:20 -0500 Subject: [PATCH] WIP - starts finishing pass farther down, to avoid looping back for it This now has all the features to address #19768, but I think I want to pick out just what is required for that PR --- src/Mod/CAM/libarea/Adaptive.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Mod/CAM/libarea/Adaptive.cpp b/src/Mod/CAM/libarea/Adaptive.cpp index 5894b0c07d..dfd8a70837 100644 --- a/src/Mod/CAM/libarea/Adaptive.cpp +++ b/src/Mod/CAM/libarea/Adaptive.cpp @@ -762,7 +762,8 @@ bool PopPathWithClosestPoint( start with closest point */ , IntPoint p1, - Path& result + Path& result, + double extraDistanceAround = 0 ) { @@ -785,14 +786,18 @@ bool PopPathWithClosestPoint( } } + Path& closestPath = paths.at(closestPathIndex); + while (extraDistanceAround > 0) { + long nexti = (closestPointIndex + 1) % closestPath.size(); + extraDistanceAround -= sqrt(DistanceSqrd(closestPath[closestPointIndex], closestPath[nexti])); + closestPointIndex = nexti; + } + result.clear(); // make new path starting with that point - Path& closestPath = paths.at(closestPathIndex); for (size_t i = 0; i < closestPath.size(); i++) { long index = closestPointIndex + long(i); - if (index >= long(closestPath.size())) { - index -= long(closestPath.size()); - } + index = index % closestPath.size(); result.push_back(closestPath.at(index)); } // remove the closest path @@ -3438,7 +3443,8 @@ void Adaptive2d::ProcessPolyNode(Paths boundPaths, Paths toolBoundPaths) Path finShiftedPath; bool allCutsAllowed = true; - while (!stopProcessing && PopPathWithClosestPoint(finishingPaths, lastPoint, finShiftedPath)) { + while (!stopProcessing + && PopPathWithClosestPoint(finishingPaths, lastPoint, finShiftedPath, stepOverScaled)) { if (finShiftedPath.empty()) { continue; }