Path: Code cleanup

Fix `If ... is True:` clauses.
Remove unnecessary doc variables.
This commit is contained in:
Russell Johnson
2020-05-30 14:11:54 -05:00
parent 3b5d2d2e7f
commit 024d23bf31

View File

@@ -41,13 +41,10 @@ __author__ = "sliptonic (Brad Collette)"
__url__ = "http://www.freecadweb.org"
__doc__ = "Class and implementation of Mill Facing operation."
__contributors__ = "russ4262 (Russell Johnson)"
__created__ = "2014"
__scriptVersion__ = "1d usable"
__lastModified__ = "2019-07-22 23:49 CST"
PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule())
#PathLog.trackModule(PathLog.thisModule())
# PathLog.trackModule(PathLog.thisModule())
# Qt translation handling
@@ -61,7 +58,7 @@ class ObjectFace(PathPocketBase.ObjectPocket):
def initPocketOp(self, obj):
'''initPocketOp(obj) ... create facing specific properties'''
obj.addProperty("App::PropertyEnumeration", "BoundaryShape", "Face", QtCore.QT_TRANSLATE_NOOP("App::Property", "Shape to use for calculating Boundary"))
obj.BoundaryShape = ['Perimeter', 'Boundbox', 'Stock']
obj.BoundaryShape = ['Perimeter', 'Boundbox', 'Stock', 'Available']
obj.addProperty("App::PropertyBool", "ClearEdges", "Face", QtCore.QT_TRANSLATE_NOOP("App::Property", "Clear edges of surface (Only applicable to BoundBox)"))
if not hasattr(obj, 'ExcludeRaisedAreas'):
@@ -103,6 +100,8 @@ class ObjectFace(PathPocketBase.ObjectPocket):
# Facing is done either against base objects
holeShape = None
PathLog.debug('depthparams: {}'.format([i for i in self.depthparams]))
if obj.Base:
PathLog.debug("obj.Base: {}".format(obj.Base))
faces = []
@@ -119,20 +118,22 @@ class ObjectFace(PathPocketBase.ObjectPocket):
faces.append(shape)
if shape.BoundBox.ZMin < minHeight:
minHeight = shape.BoundBox.ZMin
# Limit to one model base per operation
if oneBase[0] is not b[0]:
oneBase[1] = False
if numpy.isclose(abs(shape.normalAt(0, 0).z), 1): # horizontal face
# Analyze internal closed wires to determine if raised or a recess
for wire in shape.Wires[1:]:
if obj.ExcludeRaisedAreas is True:
if obj.ExcludeRaisedAreas:
ip = self.isPocket(b[0], shape, wire)
if ip is False:
holes.append((b[0].Shape, wire))
else:
holes.append((b[0].Shape, wire))
else:
PathLog.error('The base subobject, "{0}," is not a face. Ignoring "{0}."'.format(sub))
PathLog.warning('The base subobject, "{0}," is not a face. Ignoring "{0}."'.format(sub))
if obj.ExcludeRaisedAreas is True and len(holes) > 0:
if obj.ExcludeRaisedAreas and len(holes) > 0:
for shape, wire in holes:
f = Part.makeFace(wire, 'Part::FaceMakerSimple')
env = PathUtils.getEnvelope(shape, subshape=f, depthparams=self.depthparams)
@@ -152,8 +153,8 @@ class ObjectFace(PathPocketBase.ObjectPocket):
bb = planeshape.BoundBox
# Apply offset for clearing edges
offset = 0;
if obj.ClearEdges == True:
offset = 0
if obj.ClearEdges:
offset = self.radius + 0.1
bb.XMin = bb.XMin - offset
@@ -164,7 +165,7 @@ class ObjectFace(PathPocketBase.ObjectPocket):
if obj.BoundaryShape == 'Boundbox':
bbperim = Part.makeBox(bb.XLength, bb.YLength, 1, FreeCAD.Vector(bb.XMin, bb.YMin, bb.ZMin), FreeCAD.Vector(0, 0, 1))
env = PathUtils.getEnvelope(partshape=bbperim, depthparams=self.depthparams)
if obj.ExcludeRaisedAreas is True and oneBase[1] is True:
if obj.ExcludeRaisedAreas and oneBase[1]:
includedFaces = self.getAllIncludedFaces(oneBase[0], env, faceZ=minHeight)
if len(includedFaces) > 0:
includedShape = Part.makeCompound(includedFaces)
@@ -174,7 +175,7 @@ class ObjectFace(PathPocketBase.ObjectPocket):
stock = PathUtils.findParentJob(obj).Stock.Shape
env = stock
if obj.ExcludeRaisedAreas is True and oneBase[1] is True:
if obj.ExcludeRaisedAreas and oneBase[1]:
includedFaces = self.getAllIncludedFaces(oneBase[0], stock, faceZ=minHeight)
if len(includedFaces) > 0:
stockEnv = PathUtils.getEnvelope(partshape=stock, depthparams=self.depthparams)
@@ -184,13 +185,14 @@ class ObjectFace(PathPocketBase.ObjectPocket):
else:
env = PathUtils.getEnvelope(partshape=planeshape, depthparams=self.depthparams)
if holeShape is not None:
if holeShape:
PathLog.info("Processing holes...")
holeEnv = PathUtils.getEnvelope(partshape=holeShape, depthparams=self.depthparams)
newEnv = env.cut(holeEnv)
return [(newEnv, False)]
tup = newEnv, False, 'pathMillFace', 0.0, 'X', obj.StartDepth.Value, obj.FinalDepth.Value
else:
return [(env, False)]
tup = env, False, 'pathMillFace', 0.0, 'X', obj.StartDepth.Value, obj.FinalDepth.Value
return [tup]
def areaOpSetDefaultValues(self, obj, job):
'''areaOpSetDefaultValues(obj, job) ... initialize mill facing properties'''
@@ -215,7 +217,7 @@ class ObjectFace(PathPocketBase.ObjectPocket):
face = b.Shape.Faces[fi]
for ei in range(0, len(face.Edges)):
edge = face.Edges[ei]
if e.isSame(edge) is True:
if e.isSame(edge):
if f is face:
# Alternative: run loop to see if all edges are same
pass # same source face, look for another
@@ -226,7 +228,7 @@ class ObjectFace(PathPocketBase.ObjectPocket):
def getAllIncludedFaces(self, base, env, faceZ):
included = []
eXMin = env.BoundBox.XMin
eXMax = env.BoundBox.XMax
eYMin = env.BoundBox.YMin
@@ -257,12 +259,12 @@ class ObjectFace(PathPocketBase.ObjectPocket):
fYMax = face.BoundBox.YMax
# fZMin = face.BoundBox.ZMin
fZMax = face.BoundBox.ZMax
if fZMax > eZMin:
if isOverlap(fXMin, fXMax, eXMin, eXMax) is True:
if isOverlap(fYMin, fYMax, eYMin, eYMax) is True:
if isOverlap(fXMin, fXMax, eXMin, eXMax):
if isOverlap(fYMin, fYMax, eYMin, eYMax):
incl = True
if incl is True:
if incl:
included.append(face)
return included