From 8e58f10f7fd86fb3d9ee04e4b8fc7f15a796f43a Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Mon, 13 Apr 2020 14:55:24 -0500 Subject: [PATCH] Path: Fix weakness in face analysis for unique OuterWire cases --- src/Mod/Path/PathScripts/PathSurface.py | 30 ++++++++++++++----------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathSurface.py b/src/Mod/Path/PathScripts/PathSurface.py index 076b53a839..413058000a 100644 --- a/src/Mod/Path/PathScripts/PathSurface.py +++ b/src/Mod/Path/PathScripts/PathSurface.py @@ -384,7 +384,6 @@ class ObjectSurface(PathOp.ObjectOp): self.collectiveShapes = list() self.individualShapes = list() self.avoidShapes = list() - self.deflection = None self.tempGroup = None self.CutClimb = False self.closedGap = False @@ -408,6 +407,7 @@ class ObjectSurface(PathOp.ObjectOp): # Identify parent Job JOB = PathUtils.findParentJob(obj) + self.JOB = JOB if JOB is None: PathLog.error(translate('PathSurface', "No JOB")) return @@ -482,14 +482,6 @@ class ObjectSurface(PathOp.ObjectOp): # make circle for workplane self.wpc = Part.makeCircle(2.0) - # Set deflection values for mesh generation - try: # try/except is for Path Jobs created before GeometryTolerance - self.deflection = JOB.GeometryTolerance.Value - except AttributeError as ee: - PathLog.warning('Error setting Mesh deflection: {}. Using PathPreferences.defaultGeometryTolerance().'.format(ee)) - import PathScripts.PathPreferences as PathPreferences - self.deflection = PathPreferences.defaultGeometryTolerance() - # Save model visibilities for restoration if FreeCAD.GuiUp: for m in range(0, len(JOB.Model.Group)): @@ -596,7 +588,6 @@ class ObjectSurface(PathOp.ObjectOp): self.depthParams = None self.midDep = None self.wpc = None - self.deflection = None del self.modelSTLs del self.safeSTLs del self.modelTypes @@ -608,7 +599,6 @@ class ObjectSurface(PathOp.ObjectOp): del self.depthParams del self.midDep del self.wpc - del self.deflection execTime = time.time() - startTime PathLog.info('Operation time: {} sec.'.format(execTime)) @@ -1116,10 +1106,24 @@ class ObjectSurface(PathOp.ObjectOp): PathLog.debug(' -number of wires found is {}'.format(nf)) if nf == 1: (area, W, raised) = WIRES[0] - return [(W, raised)] + owLen = fc.OuterWire.Length + wLen = W.Length + if abs(owLen - wLen) > 0.0000001: + OW = Part.Wire(Part.__sortEdges__(fc.OuterWire.Edges)) + return [(OW, False), (W, raised)] + else: + return [(W, raised)] else: sortedWIRES = sorted(WIRES, key=index0, reverse=True) - return [(W, raised) for (area, W, raised) in sortedWIRES] # outer, then inner by area size + WRS = [(W, raised) for (area, W, raised) in sortedWIRES] # outer, then inner by area size + # Check if OuterWire is larger than largest in WRS list + (W, raised) = WRS[0] + owLen = fc.OuterWire.Length + wLen = W.Length + if abs(owLen - wLen) > 0.0000001: + OW = Part.Wire(Part.__sortEdges__(fc.OuterWire.Edges)) + WRS.insert(0, (OW, False)) + return WRS return False