From c29c18e0e1e226001cff7aef56b83b760bc4693f Mon Sep 17 00:00:00 2001 From: David Kaufman Date: Tue, 23 Dec 2025 16:54:29 -0500 Subject: [PATCH] Remove debug code --- src/Mod/CAM/Path/Op/Adaptive.py | 3 - src/Mod/CAM/libarea/Adaptive.cpp | 120 ------------------------------- src/Mod/CAM/libarea/Adaptive.hpp | 3 - 3 files changed, 126 deletions(-) diff --git a/src/Mod/CAM/Path/Op/Adaptive.py b/src/Mod/CAM/Path/Op/Adaptive.py index 0b1a104cc6..4d8fb39dce 100644 --- a/src/Mod/CAM/Path/Op/Adaptive.py +++ b/src/Mod/CAM/Path/Op/Adaptive.py @@ -784,10 +784,7 @@ def ExecuteModelAware(op, obj): "orderCutsByRegion": obj.OrderCutsByRegion, } - import random - insideInputStateObject = { - "TODO TESTING": random.random(), "tool": op.tool.Diameter.Value, "tolerance": obj.Tolerance, "geometry": [ diff --git a/src/Mod/CAM/libarea/Adaptive.cpp b/src/Mod/CAM/libarea/Adaptive.cpp index b344c813f1..409c6ba241 100644 --- a/src/Mod/CAM/libarea/Adaptive.cpp +++ b/src/Mod/CAM/libarea/Adaptive.cpp @@ -24,7 +24,6 @@ #include "Adaptive.hpp" #include -#include #include #include #include @@ -916,7 +915,6 @@ public: } inline void Start() { -#define DEV_MODE #ifdef DEV_MODE start_ticks = clock(); if (running) { @@ -1273,9 +1271,6 @@ public: int maxPases = 2 ) { - (*parent->fout) << "Finding Next Engage Point! " - << "step=" << step << " minCutArea=" << minCutArea - << " maxCutArea=" << maxCutArea << "\n"; Perf_NextEngagePoint.Start(); double prevArea = 0; // we want to make sure that we catch the point where the area is on // raising slope @@ -1286,7 +1281,6 @@ public: state.passes++; if (state.passes >= maxPases) { Perf_NextEngagePoint.Stop(); - (*parent->fout) << "Done, none found.\n"; return false; // nothing more to cut } prevArea = 0; @@ -1294,12 +1288,8 @@ public: } IntPoint cpt = getCurrentPoint(); double area = parent->CalcCutArea(clip, dummyInitialPoint, cpt, clearedArea); - (*parent->fout) << "Testint point:" - << " cpt=(" << cpt.X << "," << cpt.Y << ")" - << " area=" << area << "\n"; if (area > minCutArea && area < maxCutArea && area > prevArea) { Perf_NextEngagePoint.Stop(); - (*parent->fout) << "Done, accepted point.\n"; return true; } prevArea = area; @@ -1482,18 +1472,6 @@ double Adaptive2d::CalcCutArea( polygons.push_back(polygon); } - // (*fout) << "AREA[" - // << " c1=(" << c1.X << "," << c1.Y << ")" - // << " c2=(" << c2.X << "," << c2.Y << ")"; - // for (const auto poly : polygons) { - // (*fout) << "POLY["; - // for (const auto p : poly) { - // (*fout) << "(" << p.X << "," << p.Y << ")"; - // } - // (*fout) << "] "; - // } - // (*fout) << "] "; - // 1) Find all x-coordinates of interest: vector xs; for (const auto polygon : polygons) { @@ -1638,12 +1616,6 @@ double Adaptive2d::CalcCutArea( const auto y1 = interpX(p0, p1, x1); const double newArea = (y0 + y1) / 2 * (x1 - x0); area += entranceExitSign * newArea; - //(*fout) << "Pgon[eeSign=" << entranceExitSign - // << " x0=(" << x0 << " x1=" << x1 << ")" - // << " p0=(" << p0.X << "," << p0.Y << ")" - // << " p1=(" << p1.X << "," << p1.Y << ")" - // << " newArea(w/o sign)=" << newArea - // << " totalArea=" << area << "] "; } else { // crossed a circle @@ -1681,24 +1653,12 @@ double Adaptive2d::CalcCutArea( const double areaTrapezoid = (x1 - x0) * (y0 + y1) / 2; const double newArea = circleSign * areaSegment + areaTrapezoid; area += entranceExitSign * newArea; - //(*fout) << "Circle[eeSign=" << entranceExitSign - // << " x0=(" << x0 << " x1=" << x1 << ")" - // << " c=(" << c.X << "," << c.Y << ")" - // << " circleSign=" << circleSign - // << " areaSector=" << areaSector - // << " areaTriangle=" << areaTriangle - // << " areaSegment=" << areaSegment - // << " areaTrapezoid=" << areaTrapezoid - // << " newArea(w/o sign)=" << newArea - // << " totalArea=" << area << "] "; } } } } Perf_CalcCutAreaCirc.Stop(); - (*fout) << "Area=" << area << endl; - return area; } @@ -2757,31 +2717,8 @@ void Adaptive2d::AddPathToProgress(TPaths& progressPaths, const Path pth, Motion } } -struct nostream -{ - nostream(string a) - {} - nostream operator<<(string a) - { - return *this; - } - nostream operator<<(double a) - { - return *this; - } - nostream operator<<(IntPoint a) - { - return *this; - } -}; - void Adaptive2d::ProcessPolyNode(Paths boundPaths, Paths toolBoundPaths) { - ofstream fout("adaptive_debug.txt"); - this->fout = &fout; - // nostream fout("adaptive_debug.txt"); - fout << "\n" << "\n" << "----------------------" << "\n"; - fout << "Start ProcessPolyNode" << "\n"; Perf_ProcessPolyNode.Start(); current_region++; cout << "** Processing region: " << current_region << endl; @@ -2834,14 +2771,12 @@ void Adaptive2d::ProcessPolyNode(Paths boundPaths, Paths toolBoundPaths) engageBounds.push_back(p); } outsideEntry = true; - fout << "Outside entry " << entryPoint << "\n"; } else { if (!FindEntryPoint(progressPaths, toolBoundPaths, boundPaths, cleared, entryPoint, toolPos, toolDir)) { Perf_ProcessPolyNode.Stop(); return; } - fout << "Helix entry " << entryPoint << "\n"; } EngagePoint engage(engageBounds); // engage point stepping instance @@ -2898,22 +2833,11 @@ void Adaptive2d::ProcessPolyNode(Paths boundPaths, Paths toolBoundPaths) #endif ClearedArea clearedBeforePass(toolRadiusScaled); clearedBeforePass.SetClearedPaths(cleared.GetCleared()); - fout << "Tool radius scaled: " << toolRadiusScaled << "\n"; - fout << "toolBoundPaths:"; - for (auto path : toolBoundPaths) { - fout << " ["; - for (auto p : path) { - fout << "(" << p.X << "," << p.Y << ")_"; - } - fout << "]"; - } - fout << "\n"; //******************************* // LOOP - PASSES //******************************* for (long pass = 0; pass < PASSES_LIMIT; pass++) { - fout << "New pass! " << pass << "\n"; if (stopProcessing) { break; } @@ -2952,7 +2876,6 @@ void Adaptive2d::ProcessPolyNode(Paths boundPaths, Paths toolBoundPaths) // LOOP - POINTS //******************************* for (long point_index = 0; point_index < POINTS_PER_PASS_LIMIT; point_index++) { - fout << "\n" << "Point " << point_index << "\n"; if (stopProcessing) { break; } @@ -2991,14 +2914,12 @@ void Adaptive2d::ProcessPolyNode(Paths boundPaths, Paths toolBoundPaths) if (stepScaled < MIN_STEP_CLIPPER) { stepScaled = long(MIN_STEP_CLIPPER); } - fout << "\tstepScaled " << stepScaled << "\n"; //***************************** // ANGLE vs AREA ITERATIONS //***************************** double predictedAngle = averageDV(angleHistory); double maxError = AREA_ERROR_FACTOR * optimalCutAreaPD; - fout << "optimal area " << optimalCutAreaPD << " maxError " << maxError << "\n"; double area = 0; double areaPD = 0; interp.clear(); @@ -3009,50 +2930,35 @@ void Adaptive2d::ProcessPolyNode(Paths boundPaths, Paths toolBoundPaths) bool pointNotInterp; for (iteration = 0; iteration < MAX_ITERATIONS; iteration++) { total_iterations++; - fout << "It " << iteration << " "; if (iteration == 0) { angle = predictedAngle; pointNotInterp = true; - fout << "case predicted "; } else if (iteration == 1) { angle = interp.MIN_ANGLE; // max engage pointNotInterp = true; - fout << "case minimum "; } else if (iteration == 2) { if (interp.bothSides()) { angle = interp.interpolateAngle(); - fout << "(" << interp.m_min->first.first << ", " << interp.m_min->second - << ") ~ (" << interp.m_max->first.first << ", " << interp.m_max->second - << ") "; pointNotInterp = false; - fout << "case interp "; } else { angle = interp.MAX_ANGLE; // min engage - fout << "case maximum "; pointNotInterp = true; } } else { angle = interp.interpolateAngle(); - fout << "(" << interp.m_min->first.first << ", " << interp.m_min->second - << ") ~ (" << interp.m_max->first.first << ", " << interp.m_max->second - << ") "; pointNotInterp = false; - fout << "case interp "; } - fout << "raw " << angle << " "; angle = interp.clampAngle(angle); - fout << "clamped " << angle << " "; newToolDir = rotate(toolDir, angle); newToolPos = IntPoint( long(toolPos.X + newToolDir.X * stepScaled), long(toolPos.Y + newToolDir.Y * stepScaled) ); - fout << "int pos " << newToolPos << " "; // Skip iteration if this IntPoint has already been processed bool intRepeat = false; @@ -3075,7 +2981,6 @@ void Adaptive2d::ProcessPolyNode(Paths boundPaths, Paths toolBoundPaths) // integers continue; } - fout << "hit integer floor" << "\n"; // exit early, selecting the better of the two adjacent integers double error; if (abs(interp.m_min->second) < abs(interp.m_max->second)) { @@ -3092,17 +2997,14 @@ void Adaptive2d::ProcessPolyNode(Paths boundPaths, Paths toolBoundPaths) area = areaPD * double(stepScaled); break; } - fout << "skip area calc " << "\n"; continue; } area = CalcCutArea(clip, toolPos, newToolPos, cleared); areaPD = area / double(stepScaled); // area per distance - fout << "addPoint " << areaPD << " " << angle << " "; double error = areaPD - targetAreaPD; interp.addPoint(error, {angle, newToolPos}, pointNotInterp); - fout << "areaPD " << areaPD << " error " << error << " "; // cout << " iter:" << iteration << " angle:" << angle << " area:" << areaPD // << " target:" << targetAreaPD << " error:" << error << " max:" << maxError // << endl; @@ -3111,22 +3013,17 @@ void Adaptive2d::ProcessPolyNode(Paths boundPaths, Paths toolBoundPaths) if (angleHistory.size() > ANGLE_HISTORY_POINTS) { angleHistory.erase(angleHistory.begin()); } - fout << "small enough" << "\n"; break; } if (iteration > 5 && fabs(error - prev_error) < 0.001) { - fout << "no change" << "\n"; break; } if (iteration == MAX_ITERATIONS - 1) { - fout << "too many iterations!" << "\n"; total_exceeded++; } - fout << "\n"; prev_error = error; } Perf_PointIterations.Stop(); - fout << "Iterations: " << iteration << "\n"; recalcArea = false; // approach end boundary tangentially @@ -3158,12 +3055,6 @@ void Adaptive2d::ProcessPolyNode(Paths boundPaths, Paths toolBoundPaths) long(toolPos.Y + newToolDir.Y * stepScaled) ); recalcArea = true; - fout << "\tRewrote tooldir/toolpos for boundary approach" - << " a=" << angle << " maxA=" << maxAngleToBoundary << " (" << newToolPos.X - << ", " << newToolPos.Y << ")" << "\n"; - } - else { - fout << "\tRewrote tooldir/toolpos for boundary approach BUT NOT ACTUALLY \n"; } } @@ -3180,8 +3071,6 @@ void Adaptive2d::ProcessPolyNode(Paths boundPaths, Paths toolBoundPaths) long(toolPos.X + newToolDir.X * stepScaled), long(toolPos.Y + newToolDir.Y * stepScaled) ); - fout << "\tMoving tool back within boundary..." - << "(" << newToolPos.X << ", " << newToolPos.Y << ")" << "\n"; } if (rotateStep >= 180) { #ifdef DEV_MODE @@ -3192,13 +3081,11 @@ void Adaptive2d::ProcessPolyNode(Paths boundPaths, Paths toolBoundPaths) if (recalcArea) { area = CalcCutArea(clip, toolPos, newToolPos, cleared); - fout << "\tRecalc area: " << area << "\n"; } // safety condition if (area > stepScaled * optimalCutAreaPD && areaPD > 2 * optimalCutAreaPD) { over_cut_count++; - fout << "\tCut area too big!!!" << "\n"; break; } @@ -3215,7 +3102,6 @@ void Adaptive2d::ProcessPolyNode(Paths boundPaths, Paths toolBoundPaths) prevDistFromStart = distFromStart; if (area > 0) { // cut is ok - record it - fout << "\tFinal cut acceptance (" << newToolPos.X << "," << newToolPos.Y << ")\n"; noCutDistance = 0; if (toClearPath.empty()) { toClearPath.push_back(toolPos); @@ -3261,11 +3147,9 @@ void Adaptive2d::ProcessPolyNode(Paths boundPaths, Paths toolBoundPaths) else { // cout<<"Break: no cut @" << point_index << endl; if (noCutDistance > stepOverScaled) { - fout << "Points: " << point_index << "\n"; break; } noCutDistance += stepScaled; - fout << "\tFailed to accept point??" << "\n"; } } /* end of points loop*/ @@ -3282,12 +3166,8 @@ void Adaptive2d::ProcessPolyNode(Paths boundPaths, Paths toolBoundPaths) CheckReportProgress(progressPaths); bad_engage_count = 0; engage.ResetPasses(); - fout << "Accepted pass, area " << cumulativeCutArea << " more than minimum " << minArea - << "\n\n"; } else { - fout << "Rejected pass, too little area " << cumulativeCutArea << " < " << minArea - << "\n\n"; bad_engage_count++; } diff --git a/src/Mod/CAM/libarea/Adaptive.hpp b/src/Mod/CAM/libarea/Adaptive.hpp index 6ae5d967c9..2e906f6561 100644 --- a/src/Mod/CAM/libarea/Adaptive.hpp +++ b/src/Mod/CAM/libarea/Adaptive.hpp @@ -26,7 +26,6 @@ #include #include #include -#include #ifndef ADAPTIVE_HPP # define ADAPTIVE_HPP @@ -200,8 +199,6 @@ private: void AddPathToProgress(TPaths& progressPaths, const Path pth, MotionType mt = MotionType::mtCutting); void ApplyStockToLeave(Paths& inputPaths); - std::ofstream* fout; - private: // constants for fine tuning const double MIN_STEP_CLIPPER = 16.0 * 3; const int MAX_ITERATIONS = 10;