From 183e82607a4332e2bcdb85fcf9de64513afe6574 Mon Sep 17 00:00:00 2001 From: David Kaufman Date: Thu, 18 Sep 2025 13:12:34 -0400 Subject: [PATCH] Fix units/extract RESOLUTION_FACTOR from area constants Most of the code treats RESOLUTION_FACTOR as "number of clipper units in a single step" -- a linear distance unit. However, there are a few locations in which it is treated as unitless, multiplied by area constants. This commit folds the current value of RESOLUTION_FACTOR into these other contents in preparation for declaring it to have distance units and increasing its value. --- src/Mod/CAM/libarea/Adaptive.cpp | 9 ++++----- src/Mod/CAM/libarea/Adaptive.hpp | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Mod/CAM/libarea/Adaptive.cpp b/src/Mod/CAM/libarea/Adaptive.cpp index ad999004ae..2f34baa884 100644 --- a/src/Mod/CAM/libarea/Adaptive.cpp +++ b/src/Mod/CAM/libarea/Adaptive.cpp @@ -3153,8 +3153,7 @@ void Adaptive2d::ProcessPolyNode(Paths boundPaths, Paths toolBoundPaths) prevDistTrend = distanceTrend; prevDistFromStart = distFromStart; - if (area > 0.5 * MIN_CUT_AREA_FACTOR * optimalCutAreaPD - * RESOLUTION_FACTOR) { // cut is ok - record it + if (area > 0.5 * MIN_CUT_AREA_FACTOR * optimalCutAreaPD) { // cut is ok - record it fout << "\tFinal cut acceptance" << endl; noCutDistance = 0; if (toClearPath.empty()) { @@ -3220,7 +3219,7 @@ void Adaptive2d::ProcessPolyNode(Paths boundPaths, Paths toolBoundPaths) cleared.ExpandCleared(toClearPath); toClearPath.clear(); } - if (cumulativeCutArea > MIN_CUT_AREA_FACTOR * optimalCutAreaPD * RESOLUTION_FACTOR) { + if (cumulativeCutArea > MIN_CUT_AREA_FACTOR * optimalCutAreaPD) { Path cleaned; CleanPath(passToolPath, cleaned, CLEAN_PATH_TOLERANCE); total_output_points += long(cleaned.size()); @@ -3250,7 +3249,7 @@ void Adaptive2d::ProcessPolyNode(Paths boundPaths, Paths toolBoundPaths) this, cleared, moveDistance, - ENGAGE_AREA_THR_FACTOR * optimalCutAreaPD * RESOLUTION_FACTOR, + ENGAGE_AREA_THR_FACTOR * optimalCutAreaPD, 4 * referenceCutArea * stepOverFactor )) { // check if there are any uncleared area left @@ -3288,7 +3287,7 @@ void Adaptive2d::ProcessPolyNode(Paths boundPaths, Paths toolBoundPaths) this, cleared, moveDistance, - ENGAGE_AREA_THR_FACTOR * optimalCutAreaPD * RESOLUTION_FACTOR, + ENGAGE_AREA_THR_FACTOR * optimalCutAreaPD, 4 * referenceCutArea * stepOverFactor )) { break; diff --git a/src/Mod/CAM/libarea/Adaptive.hpp b/src/Mod/CAM/libarea/Adaptive.hpp index 6dc9ff9788..550dce3f07 100644 --- a/src/Mod/CAM/libarea/Adaptive.hpp +++ b/src/Mod/CAM/libarea/Adaptive.hpp @@ -208,9 +208,9 @@ private: // constants for fine tuning const int DIRECTION_SMOOTHING_BUFLEN = 3; // gyro points - used for angle smoothing - const double MIN_CUT_AREA_FACTOR = 0.1; // used for filtering out of insignificant cuts (should - // be < ENGAGE_AREA_THR_FACTOR) - const double ENGAGE_AREA_THR_FACTOR = 0.5; // influences minimal engage area + const double MIN_CUT_AREA_FACTOR = 0.1 + * 16; // used for filtering out of insignificant cuts (should be < ENGAGE_AREA_THR_FACTOR) + const double ENGAGE_AREA_THR_FACTOR = 0.5 * 16; // influences minimal engage area const double ENGAGE_SCAN_DISTANCE_FACTOR = 0.2; // influences the engage scan/stepping distance const double CLEAN_PATH_TOLERANCE = 1.41; // should be >1