From e561950ff8ab5d2fbf1207d8b1f76b088887b352 Mon Sep 17 00:00:00 2001 From: tarman3 Date: Sat, 7 Mar 2026 17:44:04 +0200 Subject: [PATCH] CAM: Linking - Minor optimization for simple solid --- src/Mod/CAM/Path/Base/Generator/linking.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Mod/CAM/Path/Base/Generator/linking.py b/src/Mod/CAM/Path/Base/Generator/linking.py index d80b85cb1e..c5c8c3f548 100644 --- a/src/Mod/CAM/Path/Base/Generator/linking.py +++ b/src/Mod/CAM/Path/Base/Generator/linking.py @@ -61,6 +61,12 @@ def check_collision( # Create direct path wire wire = Part.Wire([Part.makeLine(start_position, target_position)]) + + bbDistance = wire.BoundBox.ZMin - collision_model.BoundBox.ZMax + if bbDistance >= tolerance or Path.Geom.isRoughly(bbDistance, tolerance): + # attempt to skip long time computation for simple model + return False + distance = wire.distToShape(collision_model)[0] return distance < tolerance and not Path.Geom.isRoughly(distance, tolerance) @@ -168,7 +174,17 @@ def make_linking_wire(start: Vector, target: Vector, z: float) -> Part.Wire: def is_wire_collision_free( wire: Part.Wire, solid: Optional[Part.Shape], tolerance: float = 0.001 ) -> bool: + """ + Check if a horizontal edge of wire would not collide with solids. + Returns True if path is clear, False if collision detected. + """ if not solid: return True + + bbDistance = wire.BoundBox.ZMax - solid.BoundBox.ZMax + if bbDistance >= tolerance or Path.Geom.isRoughly(bbDistance, tolerance): + # attempt to skip long time computation for simple model + return True + distance = wire.distToShape(solid)[0] return distance >= tolerance or Path.Geom.isRoughly(distance, tolerance)