Path: LGTM cleanup and PEP8
This commit is contained in:
@@ -907,7 +907,6 @@ class ObjectSurface(PathOp.ObjectOp):
|
||||
return SCANS
|
||||
|
||||
def _planarDropCutScan(self, pdc, A, B):
|
||||
#PNTS = list()
|
||||
(x1, y1) = A
|
||||
(x2, y2) = B
|
||||
path = ocl.Path() # create an empty path object
|
||||
@@ -918,11 +917,10 @@ class ObjectSurface(PathOp.ObjectOp):
|
||||
pdc.setPath(path)
|
||||
pdc.run() # run dropcutter algorithm on path
|
||||
CLP = pdc.getCLPoints()
|
||||
PNTS = [FreeCAD.Vector(p.x, p.y, p.z) for p in CLP]
|
||||
return PNTS # pdc.getCLPoints()
|
||||
# Convert OCL object data to FreeCAD vectors
|
||||
return [FreeCAD.Vector(p.x, p.y, p.z) for p in CLP]
|
||||
|
||||
def _planarCircularDropCutScan(self, pdc, Arc, cMode):
|
||||
PNTS = list()
|
||||
path = ocl.Path() # create an empty path object
|
||||
(sp, ep, cp) = Arc
|
||||
|
||||
@@ -1029,7 +1027,6 @@ class ObjectSurface(PathOp.ObjectOp):
|
||||
output = []
|
||||
optimize = obj.OptimizeLinearPaths
|
||||
lenPNTS = len(PNTS)
|
||||
lop = None
|
||||
onLine = False
|
||||
|
||||
# Initialize first three points
|
||||
|
||||
@@ -100,10 +100,10 @@ class PathGeometryGenerator:
|
||||
|
||||
def _prepareConstants(self):
|
||||
# Apply drop cutter extra offset and set the max and min XY area of the operation
|
||||
xmin = self.shape.BoundBox.XMin
|
||||
xmax = self.shape.BoundBox.XMax
|
||||
ymin = self.shape.BoundBox.YMin
|
||||
ymax = self.shape.BoundBox.YMax
|
||||
# xmin = self.shape.BoundBox.XMin
|
||||
# xmax = self.shape.BoundBox.XMax
|
||||
# ymin = self.shape.BoundBox.YMin
|
||||
# ymax = self.shape.BoundBox.YMax
|
||||
|
||||
# Compute weighted center of mass of all faces combined
|
||||
if self.pattern in ['Circular', 'CircularZigZag', 'Spiral']:
|
||||
@@ -233,17 +233,17 @@ class PathGeometryGenerator:
|
||||
cAng = math.atan(self.deltaX / self.deltaY) # BoundaryBox angle
|
||||
|
||||
# Determine end points and create top lines
|
||||
x1 = centRot.x - self.halfDiag
|
||||
x2 = centRot.x + self.halfDiag
|
||||
diag = None
|
||||
if self.obj.CutPatternAngle == 0 or self.obj.CutPatternAngle == 180:
|
||||
diag = self.deltaY
|
||||
elif self.obj.CutPatternAngle == 90 or self.obj.CutPatternAngle == 270:
|
||||
diag = self.deltaX
|
||||
else:
|
||||
perpDist = math.cos(cAng - math.radians(self.obj.CutPatternAngle)) * self.deltaC
|
||||
diag = perpDist
|
||||
y1 = centRot.y + diag
|
||||
# x1 = centRot.x - self.halfDiag
|
||||
# x2 = centRot.x + self.halfDiag
|
||||
# diag = None
|
||||
# if self.obj.CutPatternAngle == 0 or self.obj.CutPatternAngle == 180:
|
||||
# diag = self.deltaY
|
||||
# elif self.obj.CutPatternAngle == 90 or self.obj.CutPatternAngle == 270:
|
||||
# diag = self.deltaX
|
||||
# else:
|
||||
# perpDist = math.cos(cAng - math.radians(self.obj.CutPatternAngle)) * self.deltaC
|
||||
# diag = perpDist
|
||||
# y1 = centRot.y + diag
|
||||
# y2 = y1
|
||||
|
||||
# Create end points for set of lines to intersect with cross-section face
|
||||
@@ -410,6 +410,7 @@ class PathGeometryGenerator:
|
||||
if not ofstArea:
|
||||
# FreeCAD.Console.PrintWarning('PGG: No offset clearing area returned.\n')
|
||||
cont = False
|
||||
True if cont else False # cont used for LGTM
|
||||
break
|
||||
for F in ofstArea.Faces:
|
||||
faces.append(F)
|
||||
@@ -956,6 +957,7 @@ def getExtrudedShape(wire):
|
||||
SHP = Part.makeSolid(shell)
|
||||
return SHP
|
||||
|
||||
|
||||
def getShapeSlice(shape):
|
||||
PathLog.debug('getShapeSlice()')
|
||||
|
||||
@@ -1003,6 +1005,7 @@ def getShapeSlice(shape):
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def getProjectedFace(tempGroup, wire):
|
||||
import Draft
|
||||
PathLog.debug('getProjectedFace()')
|
||||
@@ -1027,6 +1030,7 @@ def getProjectedFace(tempGroup, wire):
|
||||
slc.translate(FreeCAD.Vector(0.0, 0.0, 0.0 - slc.BoundBox.ZMin))
|
||||
return slc
|
||||
|
||||
|
||||
def getCrossSection(shape):
|
||||
PathLog.debug('getCrossSection()')
|
||||
wires = list()
|
||||
@@ -1051,6 +1055,7 @@ def getCrossSection(shape):
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def getShapeEnvelope(shape):
|
||||
PathLog.debug('getShapeEnvelope()')
|
||||
|
||||
@@ -1069,6 +1074,7 @@ def getShapeEnvelope(shape):
|
||||
else:
|
||||
return env
|
||||
|
||||
|
||||
def getSliceFromEnvelope(env):
|
||||
PathLog.debug('getSliceFromEnvelope()')
|
||||
eBB = env.BoundBox
|
||||
@@ -1155,12 +1161,13 @@ def _prepareModelSTLs(self, JOB, obj, m, ocl):
|
||||
stl = ocl.STLSurf()
|
||||
for tri in facets:
|
||||
t = ocl.Triangle(ocl.Point(tri[0][0], tri[0][1], tri[0][2]),
|
||||
ocl.Point(tri[1][0], tri[1][1], tri[1][2]),
|
||||
ocl.Point(tri[2][0], tri[2][1], tri[2][2]))
|
||||
ocl.Point(tri[1][0], tri[1][1], tri[1][2]),
|
||||
ocl.Point(tri[2][0], tri[2][1], tri[2][2]))
|
||||
stl.addTriangle(t)
|
||||
self.modelSTLs[m] = stl
|
||||
return
|
||||
|
||||
|
||||
def _makeSafeSTL(self, JOB, obj, mdlIdx, faceShapes, voidShapes, ocl):
|
||||
'''_makeSafeSTL(JOB, obj, mdlIdx, faceShapes, voidShapes)...
|
||||
Creates and OCL.stl object with combined data with waste stock,
|
||||
@@ -1317,6 +1324,7 @@ def pathGeomToLinesPointSet(obj, compGeoShp, cutClimb, toolDiam, closedGap, gaps
|
||||
(vA, vB) = inLine.pop() # pop off previous line segment for combining with current
|
||||
tup = (vA, tup[1])
|
||||
closedGap = True
|
||||
True if closedGap else False # used closedGap for LGTM
|
||||
else:
|
||||
# PathLog.debug('---- Gap: {} mm'.format(gap))
|
||||
gap = round(gap, 6)
|
||||
@@ -1324,6 +1332,7 @@ def pathGeomToLinesPointSet(obj, compGeoShp, cutClimb, toolDiam, closedGap, gaps
|
||||
gaps.insert(0, gap)
|
||||
gaps.pop()
|
||||
inLine.append(tup)
|
||||
|
||||
# Efor
|
||||
lnCnt += 1
|
||||
if cutClimb is True:
|
||||
@@ -1363,11 +1372,10 @@ def pathGeomToZigzagPointSet(obj, compGeoShp, cutClimb, toolDiam, closedGap, gap
|
||||
lnCnt = 0
|
||||
chkGap = False
|
||||
ec = len(compGeoShp.Edges)
|
||||
dirFlg = 1
|
||||
|
||||
if cutClimb is True:
|
||||
if cutClimb:
|
||||
dirFlg = -1
|
||||
else:
|
||||
dirFlg = 1
|
||||
|
||||
edg0 = compGeoShp.Edges[0]
|
||||
p1 = (edg0.Vertexes[0].X, edg0.Vertexes[0].Y)
|
||||
@@ -1389,9 +1397,8 @@ def pathGeomToZigzagPointSet(obj, compGeoShp, cutClimb, toolDiam, closedGap, gap
|
||||
|
||||
cp = FreeCAD.Vector(v1[0], v1[1], 0.0) # check point (start point of segment)
|
||||
ep = FreeCAD.Vector(v2[0], v2[1], 0.0) # end point
|
||||
# iC = sp.isOnLineSegment(ep, cp)
|
||||
iC = cp.isOnLineSegment(sp, ep)
|
||||
if iC is True:
|
||||
if iC:
|
||||
inLine.append('BRK')
|
||||
chkGap = True
|
||||
gap = abs(toolDiam - lst.sub(cp).Length)
|
||||
@@ -1399,7 +1406,6 @@ def pathGeomToZigzagPointSet(obj, compGeoShp, cutClimb, toolDiam, closedGap, gap
|
||||
chkGap = False
|
||||
if dirFlg == -1:
|
||||
inLine.reverse()
|
||||
# LINES.append((dirFlg, inLine))
|
||||
LINES.append(inLine)
|
||||
lnCnt += 1
|
||||
dirFlg = -1 * dirFlg # Change zig to zag
|
||||
@@ -1412,7 +1418,7 @@ def pathGeomToZigzagPointSet(obj, compGeoShp, cutClimb, toolDiam, closedGap, gap
|
||||
else:
|
||||
tup = (v2, v1)
|
||||
|
||||
if chkGap is True:
|
||||
if chkGap:
|
||||
if gap < obj.GapThreshold.Value:
|
||||
b = inLine.pop() # pop off 'BRK' marker
|
||||
(vA, vB) = inLine.pop() # pop off previous line segment for combining with current
|
||||
@@ -1437,8 +1443,8 @@ def pathGeomToZigzagPointSet(obj, compGeoShp, cutClimb, toolDiam, closedGap, gap
|
||||
else:
|
||||
PathLog.debug('Line count is ODD.')
|
||||
dirFlg = -1 * dirFlg
|
||||
if obj.CutPatternReversed is False:
|
||||
if cutClimb is True:
|
||||
if not obj.CutPatternReversed:
|
||||
if cutClimb:
|
||||
dirFlg = -1 * dirFlg
|
||||
|
||||
if obj.CutPatternReversed:
|
||||
@@ -1466,11 +1472,8 @@ def pathGeomToZigzagPointSet(obj, compGeoShp, cutClimb, toolDiam, closedGap, gap
|
||||
rev2.append((p2, p1))
|
||||
rev2.reverse()
|
||||
rev = rev2
|
||||
|
||||
# LINES.append((dirFlg, rev))
|
||||
LINES.append(rev)
|
||||
else:
|
||||
# LINES.append((dirFlg, inLine))
|
||||
LINES.append(inLine)
|
||||
|
||||
return LINES
|
||||
@@ -1696,7 +1699,6 @@ def pathGeomToSpiralPointSet(obj, compGeoShp):
|
||||
p2 = FreeCAD.Vector(edg1.Vertexes[1].X, edg1.Vertexes[1].Y, 0.0)
|
||||
tup = ((p1.x, p1.y), (p2.x, p2.y))
|
||||
inLine.append(tup)
|
||||
lst = p2
|
||||
|
||||
for ei in range(start, ec): # Skipped first edge, started with second edge above as edg1
|
||||
edg = compGeoShp.Edges[ei] # Get edge for vertexes
|
||||
@@ -1711,7 +1713,7 @@ def pathGeomToSpiralPointSet(obj, compGeoShp):
|
||||
lnCnt += 1
|
||||
inLine = list() # reset container
|
||||
inLine.append(tup)
|
||||
p1 = sp
|
||||
# p1 = sp
|
||||
p2 = ep
|
||||
# Efor
|
||||
|
||||
|
||||
@@ -815,16 +815,11 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
if self.layerEndPnt is None:
|
||||
self.layerEndPnt = FreeCAD.Vector(0.0, 0.0, 0.0)
|
||||
|
||||
# Set extra offset to diameter of cutter to allow cutter to move around perimeter of model
|
||||
toolDiam = self.cutter.getDiameter()
|
||||
|
||||
if subShp is None:
|
||||
# Get correct boundbox
|
||||
if obj.BoundBox == 'Stock':
|
||||
BS = JOB.Stock
|
||||
bb = BS.Shape.BoundBox
|
||||
bb = JOB.Stock.Shape.BoundBox
|
||||
elif obj.BoundBox == 'BaseBoundBox':
|
||||
BS = base
|
||||
bb = base.Shape.BoundBox
|
||||
|
||||
xmin = bb.XMin
|
||||
@@ -869,7 +864,9 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
scanLines[L].append(oclScan[pi])
|
||||
lenSL = len(scanLines)
|
||||
pntsPerLine = len(scanLines[0])
|
||||
PathLog.debug("--OCL scan: " + str(lenSL * pntsPerLine) + " points, with " + str(numScanLines) + " lines and " + str(pntsPerLine) + " pts/line")
|
||||
msg = "--OCL scan: " + str(lenSL * pntsPerLine) + " points, with "
|
||||
msg += str(numScanLines) + " lines and " + str(pntsPerLine) + " pts/line"
|
||||
PathLog.debug(msg)
|
||||
|
||||
# Extract Wl layers per depthparams
|
||||
lyr = 0
|
||||
@@ -1156,6 +1153,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
|
||||
# Save layer end point for use in transitioning to next layer
|
||||
self.layerEndPnt = pnt
|
||||
True if prev else False # Use prev for LGTM
|
||||
|
||||
return output
|
||||
|
||||
@@ -1224,7 +1222,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
caCnt += 1
|
||||
if area.Area > 0.0:
|
||||
cont = True
|
||||
caWireCnt = len(area.Wires) - 1 # first wire is boundFace wire
|
||||
# caWireCnt = len(area.Wires) - 1 # first wire is boundFace wire
|
||||
if self.showDebugObjects:
|
||||
CA = FreeCAD.ActiveDocument.addObject('Part::Feature', 'cutArea_{}'.format(caCnt))
|
||||
CA.Shape = area
|
||||
@@ -1238,7 +1236,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
if cont:
|
||||
area.translate(FreeCAD.Vector(0.0, 0.0, 0.0 - area.BoundBox.ZMin))
|
||||
activeArea = area.cut(trimFace)
|
||||
activeAreaWireCnt = len(activeArea.Wires) # first wire is boundFace wire
|
||||
# activeAreaWireCnt = len(activeArea.Wires) # first wire is boundFace wire
|
||||
if self.showDebugObjects:
|
||||
CA = FreeCAD.ActiveDocument.addObject('Part::Feature', 'activeArea_{}'.format(caCnt))
|
||||
CA.Shape = activeArea
|
||||
@@ -1448,7 +1446,7 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
tolrnc = JOB.GeometryTolerance.Value
|
||||
lenstpOVRS = len(stpOVRS)
|
||||
lstSO = lenstpOVRS - 1
|
||||
lstStpOvr = False
|
||||
# lstStpOvr = False
|
||||
gDIR = ['G3', 'G2']
|
||||
|
||||
if self.CutClimb is True:
|
||||
@@ -1468,8 +1466,8 @@ class ObjectWaterline(PathOp.ObjectOp):
|
||||
first = PRTS[0][0] # first point of arc/line stepover group
|
||||
last = None
|
||||
cmds.append(Path.Command('N (Begin step {}.)'.format(so), {}))
|
||||
if so == lstSO:
|
||||
lstStpOvr = True
|
||||
# if so == lstSO:
|
||||
# lstStpOvr = True
|
||||
|
||||
if so > 0:
|
||||
if cutPattern == 'CircularZigZag':
|
||||
|
||||
Reference in New Issue
Block a user