From e8c61bec158a0151e7fb2c01caac3134470048c9 Mon Sep 17 00:00:00 2001 From: Dimitris75 <30848292+Dimitris75@users.noreply.github.com> Date: Tue, 16 Dec 2025 22:55:22 +0200 Subject: [PATCH] Refactor bounding box and tool path limit calculations Refactor bounding box calculations for OCL Adaptive algorithm to improve clarity and maintainability. --- src/Mod/CAM/Path/Op/Waterline.py | 34 +++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/Mod/CAM/Path/Op/Waterline.py b/src/Mod/CAM/Path/Op/Waterline.py index 7734c32f01..bb1bd4cfc4 100644 --- a/src/Mod/CAM/Path/Op/Waterline.py +++ b/src/Mod/CAM/Path/Op/Waterline.py @@ -1247,25 +1247,35 @@ class ObjectWaterline(PathOp.ObjectOp): # Scan the piece to depth at smplInt if obj.Algorithm == "OCL Adaptive": - # Get Stock boundbox for OCL Adaptive + # Get Stock Bounding Box BS = JOB.Stock - bb = BS.Shape.BoundBox - xmin = round(abs(bb.XMin), 6) - xmax = round(abs(bb.XMax), 6) - ymin = round(abs(bb.YMin), 6) - ymax = round(abs(bb.YMax), 6) + stock_bb = BS.Shape.BoundBox + + # Stock Limits + s_xmin = stock_bb.XMin + s_xmax = stock_bb.XMax + s_ymin = stock_bb.YMin + s_ymax = stock_bb.YMax + + # Calculate Tool Path Limits based on OCL STL + path_min_x = stl.bb.minpt.x - self.radius + path_min_y = stl.bb.minpt.y - self.radius + path_max_x = stl.bb.maxpt.x + self.radius + path_max_y = stl.bb.maxpt.y + self.radius + + # Compare with a tiny tolerance + tol = 0.001 + if (path_min_x < s_xmin - tol) or \ + (path_min_y < s_ymin - tol) or \ + (path_max_x > s_xmax + tol) or \ + (path_max_y > s_ymax + tol): - # Check Stock's bounding box and Tool Path limits - MinX = round(abs(stl.bb.minpt.x) + self.toolDiam, 6) - MinY = round(abs(stl.bb.minpt.y) + self.toolDiam, 6) - MaxX = round(abs(stl.bb.maxpt.x) + self.toolDiam, 6) - MaxY = round(abs(stl.bb.maxpt.y) + self.toolDiam, 6) - if MinX < xmin or MinY < ymin or MaxX > xmax or MaxY > ymax: newPropMsg = translate( "PathWaterline", "The toolpath has exceeded the stock bounding box limits. Consider using a Boundary Dressup.", ) FreeCAD.Console.PrintWarning(newPropMsg + "\n") + # Run the Scan (Processing ALL depths at once) scanLines = self._waterlineAdaptiveScan(stl, smplInt, minSmplInt, depthparams, depOfst)