From 48d10b25b262c32022cc54fafbd7e47c810074c3 Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Tue, 17 Aug 2021 21:21:58 -0500 Subject: [PATCH 1/4] Path: LGTM fix Prompted by LuzPaz in Gitter.im/FreeCAD/Path chatroom --- src/Mod/Path/PathScripts/PathMillFace.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathMillFace.py b/src/Mod/Path/PathScripts/PathMillFace.py index f3c1d93511..2f1928b553 100644 --- a/src/Mod/Path/PathScripts/PathMillFace.py +++ b/src/Mod/Path/PathScripts/PathMillFace.py @@ -265,16 +265,9 @@ class ObjectFace(PathPocketBase.ObjectPocket): eYMax = env.BoundBox.YMax eZMin = faceZ - def isOverlap(fMn, fMx, eMn, eMx): - if fMx > eMn: - if fMx <= eMx: - return True - elif fMx >= eMx and fMn <= eMx: - return True - if fMn < eMx: - if fMn >= eMn: - return True - elif fMn <= eMn and fMx >= eMn: + def isOverlap(faceMin, faceMax, envMin, envMax): + if faceMax > envMin: + if faceMin <= envMax or faceMin == envMin: return True return False From 1fbb7412b77791a55f3d07921fe88ffa900f0bdd Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Tue, 17 Aug 2021 21:22:52 -0500 Subject: [PATCH 2/4] Path: Add docString and comments for `getAllIncludedFaces()` method --- src/Mod/Path/PathScripts/PathMillFace.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathMillFace.py b/src/Mod/Path/PathScripts/PathMillFace.py index 2f1928b553..2fd245b768 100644 --- a/src/Mod/Path/PathScripts/PathMillFace.py +++ b/src/Mod/Path/PathScripts/PathMillFace.py @@ -257,6 +257,8 @@ class ObjectFace(PathPocketBase.ObjectPocket): return False def getAllIncludedFaces(self, base, env, faceZ): + '''getAllIncludedFaces(base, env, faceZ)... + Return all `base` faces extending above `faceZ` whose boundboxes overlap with the `env` boundbox.''' included = [] eXMin = env.BoundBox.XMin @@ -272,6 +274,7 @@ class ObjectFace(PathPocketBase.ObjectPocket): return False for fi in range(0, len(base.Shape.Faces)): + # Check all faces of `base` shape incl = False face = base.Shape.Faces[fi] fXMin = face.BoundBox.XMin @@ -281,8 +284,9 @@ class ObjectFace(PathPocketBase.ObjectPocket): fZMax = face.BoundBox.ZMax if fZMax > eZMin: - if isOverlap(fXMin, fXMax, eXMin, eXMax): - if isOverlap(fYMin, fYMax, eYMin, eYMax): + # Include face if its boundbox overlaps envelope boundbox + if isOverlap(fXMin, fXMax, eXMin, eXMax): # check X values + if isOverlap(fYMin, fYMax, eYMin, eYMax): # check Y values incl = True if incl: included.append(face) From 7ec38a5c3bcb63b83ccc7d0085f74f1446f167b9 Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Tue, 17 Aug 2021 21:23:35 -0500 Subject: [PATCH 3/4] Path: Remove unused import --- src/Mod/Path/PathScripts/PathMillFace.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Mod/Path/PathScripts/PathMillFace.py b/src/Mod/Path/PathScripts/PathMillFace.py index 2fd245b768..7159040698 100644 --- a/src/Mod/Path/PathScripts/PathMillFace.py +++ b/src/Mod/Path/PathScripts/PathMillFace.py @@ -192,7 +192,6 @@ class ObjectFace(PathPocketBase.ObjectPocket): else: env = PathUtils.getEnvelope(partshape=planeshape, depthparams=self.depthparams) elif obj.BoundaryShape == 'Face Region': - import PathScripts.PathSurfaceSupport as PathSurfaceSupport baseShape = oneBase[0].Shape psZMin = planeshape.BoundBox.ZMin ofstShape = PathUtils.getOffsetArea(planeshape, From fcd8b8558e269bb01346820d31308b61a86c671e Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Tue, 17 Aug 2021 21:29:17 -0500 Subject: [PATCH 4/4] Path: Fix `Face Region` boundary shape usage This commit removes automatic edge extension for `Face Region` boundary shape. It applies the `Clear Edges` toggle for `Face Region`. It applies `Exclude Raised Areas` correctly. The problem of collision paths for `Clear Edges` with `Exclude Raised Areas` for certain use cases remains and is not fixed with this commit. --- src/Mod/Path/PathScripts/PathMillFace.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathMillFace.py b/src/Mod/Path/PathScripts/PathMillFace.py index 7159040698..ec9a528880 100644 --- a/src/Mod/Path/PathScripts/PathMillFace.py +++ b/src/Mod/Path/PathScripts/PathMillFace.py @@ -194,16 +194,20 @@ class ObjectFace(PathPocketBase.ObjectPocket): elif obj.BoundaryShape == 'Face Region': baseShape = oneBase[0].Shape psZMin = planeshape.BoundBox.ZMin - ofstShape = PathUtils.getOffsetArea(planeshape, - self.tool.Diameter * 1.1, - plane=planeshape) + ofst = 0.0 + if obj.ClearEdges: + ofst = self.tool.Diameter * 0.51 + ofstShape = PathUtils.getOffsetArea(planeshape, ofst, plane=planeshape) ofstShape.translate(FreeCAD.Vector(0.0, 0.0, psZMin - ofstShape.BoundBox.ZMin)) # Calculate custom depth params for removal shape envelope, with start and final depth buffers custDepthparams = self._customDepthParams(obj, obj.StartDepth.Value + 0.2, obj.FinalDepth.Value - 0.1) # only an envelope ofstShapeEnv = PathUtils.getEnvelope(partshape=ofstShape, depthparams=custDepthparams) - env = ofstShapeEnv.cut(baseShape) - env.translate(FreeCAD.Vector(0.0, 0.0, -0.000001)) # lower removal shape into buffer zone + if obj.ExcludeRaisedAreas: + env = ofstShapeEnv.cut(baseShape) + env.translate(FreeCAD.Vector(0.0, 0.0, -0.00001)) # lower removal shape into buffer zone + else: + env = ofstShapeEnv if holeShape: PathLog.debug("Processing holes and face ...")