Skip to content

Commit

Permalink
Path: Remove Expand Profile feature from Profile op
Browse files Browse the repository at this point in the history
  • Loading branch information
Russ4262 committed Jan 30, 2021
1 parent 4db83a4 commit df76384
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 139 deletions.
2 changes: 0 additions & 2 deletions src/Mod/Path/PathScripts/PathAreaOp.py
Expand Up @@ -231,8 +231,6 @@ def _buildPathArea(self, obj, baseobject, isHole, start, getsim):
area.add(baseobject)

areaParams = self.areaOpAreaParams(obj, isHole) # pylint: disable=assignment-from-no-return
if hasattr(obj, 'ExpandProfile') and obj.ExpandProfile != 0:
areaParams = self.areaOpAreaParamsExpandProfile(obj, isHole) # pylint: disable=assignment-from-no-return

heights = [i for i in self.depthparams]
PathLog.debug('depths: {}'.format(heights))
Expand Down
145 changes: 8 additions & 137 deletions src/Mod/Path/PathScripts/PathProfile.py
Expand Up @@ -99,10 +99,6 @@ def areaOpProperties(self):
return [
("App::PropertyEnumeration", "Direction", "Profile",
QtCore.QT_TRANSLATE_NOOP("App::Property", "The direction that the toolpath should go around the part ClockWise (CW) or CounterClockWise (CCW)")),
("App::PropertyLength", "ExpandProfile", "Profile",
QtCore.QT_TRANSLATE_NOOP("App::Property", "Extend the profile clearing beyond the Extra Offset.")),
("App::PropertyPercent", "ExpandProfileStepOver", "Profile",
QtCore.QT_TRANSLATE_NOOP("App::Property", "Set the stepover percentage, based on the tool's diameter.")),
("App::PropertyEnumeration", "HandleMultipleFeatures", "Profile",
QtCore.QT_TRANSLATE_NOOP("PathPocket", "Choose how to process multiple Base Geometry features.")),
("App::PropertyEnumeration", "JoinType", "Profile",
Expand Down Expand Up @@ -149,8 +145,6 @@ def areaOpPropertyDefaults(self, obj, job):
return {
'AttemptInverseAngle': True,
'Direction': 'CW',
'ExpandProfile': 0.0,
'ExpandProfileStepOver': 100,
'HandleMultipleFeatures': 'Individually',
'InverseAngle': False,
'JoinType': 'Round',
Expand Down Expand Up @@ -261,29 +255,6 @@ def areaOpAreaParams(self, obj, isHole):

return params

def areaOpAreaParamsExpandProfile(self, obj, isHole):
'''areaOpPathParamsExpandProfile(obj, isHole) ... return dictionary with area parameters for expanded profile'''
params = {}

params['Fill'] = 1
params['Coplanar'] = 0
params['PocketMode'] = 1
params['SectionCount'] = -1
# params['Angle'] = obj.ZigZagAngle
# params['FromCenter'] = (obj.StartAt == "Center")
params['PocketStepover'] = self.tool.Diameter * (float(obj.ExpandProfileStepOver) / 100.0)
extraOffset = obj.OffsetExtra.Value
if False: # self.pocketInvertExtraOffset(): # Method simply returns False
extraOffset = 0.0 - extraOffset
params['PocketExtraOffset'] = extraOffset
params['ToolRadius'] = self.radius

# Pattern = ['ZigZag', 'Offset', 'Spiral', 'ZigZagOffset', 'Line', 'Grid', 'Triangle']
params['PocketMode'] = 2 # Pattern.index(obj.OffsetPattern) + 1
params['JoinType'] = 0 # jointype = ['Round', 'Square', 'Miter']

return params

def areaOpPathParams(self, obj, isHole):
'''areaOpPathParams(obj, isHole) ... returns dictionary with path parameters.
Do not overwrite.'''
Expand All @@ -310,9 +281,7 @@ def areaOpPathParams(self, obj, isHole):

def areaOpUseProjection(self, obj):
'''areaOpUseProjection(obj) ... returns True'''
if obj.ExpandProfile.Value == 0.0:
return True
return False
return True

def opUpdateDepths(self, obj):
if hasattr(obj, 'Base') and obj.Base.__len__() == 0:
Expand All @@ -331,7 +300,6 @@ def areaOpShapes(self, obj):
self.isDebug = True if PathLog.getLevel(PathLog.thisModule()) == 4 else False
self.inaccessibleMsg = translate('PathProfile', 'The selected edge(s) are inaccessible. If multiple, re-ordering selection might work.')
self.offsetExtra = obj.OffsetExtra.Value
self.expandProfile = None

if self.isDebug:
for grpNm in ['tmpDebugGrp', 'tmpDebugGrp001']:
Expand All @@ -343,11 +311,6 @@ def areaOpShapes(self, obj):
tmpGrpNm = self.tmpGrp.Name
self.JOB = PathUtils.findParentJob(obj)

if obj.ExpandProfile.Value != 0.0:
import PathScripts.PathSurfaceSupport as PathSurfaceSupport
self.PathSurfaceSupport = PathSurfaceSupport
self.expandProfile = True

if obj.UseComp:
self.useComp = True
self.ofstRadius = self.radius + self.offsetExtra
Expand Down Expand Up @@ -435,10 +398,7 @@ def areaOpShapes(self, obj):
if ot < 1:
cont = True
if cont:
if self.expandProfile:
shapeEnv = self._getExpandedProfileEnvelope(obj, f, True, obj.StartDepth.Value, finDep)
else:
shapeEnv = PathUtils.getEnvelope(baseShape, subshape=f, depthparams=self.depthparams)
shapeEnv = PathUtils.getEnvelope(baseShape, subshape=f, depthparams=self.depthparams)

if shapeEnv:
self._addDebugObject('HoleShapeEnvelope', shapeEnv)
Expand All @@ -460,11 +420,7 @@ def areaOpShapes(self, obj):
custDepthparams = self._customDepthParams(obj, strDep + 0.5, finDep) # only an envelope

try:
# env = PathUtils.getEnvelope(profileshape, depthparams=custDepthparams)
if self.expandProfile:
shapeEnv = self._getExpandedProfileEnvelope(obj, shape, False, obj.StartDepth.Value, finDep)
else:
shapeEnv = PathUtils.getEnvelope(profileshape, depthparams=custDepthparams)
shapeEnv = PathUtils.getEnvelope(profileshape, depthparams=custDepthparams)
except Exception as ee: # pylint: disable=broad-except
# PathUtils.getEnvelope() failed to return an object.
msg = translate('Path', 'Unable to create path for face(s).')
Expand All @@ -481,12 +437,7 @@ def areaOpShapes(self, obj):
finalDep = obj.FinalDepth.Value
custDepthparams = self.depthparams
self._addDebugObject('Rotation_Indiv_Shp', shape)

if self.expandProfile:
shapeEnv = self._getExpandedProfileEnvelope(obj, shape, False, obj.StartDepth.Value, finalDep)
else:
shapeEnv = PathUtils.getEnvelope(shape, depthparams=custDepthparams)

shapeEnv = PathUtils.getEnvelope(shape, depthparams=custDepthparams)
if shapeEnv:
self._addDebugObject('IndivCutShapeEnv', shapeEnv)
tup = shapeEnv, False, 'pathProfile', angle, axis, strDep, finalDep
Expand All @@ -499,11 +450,6 @@ def areaOpShapes(self, obj):

if 1 == len(self.model) and hasattr(self.model[0], "Proxy"):
if isinstance(self.model[0].Proxy, ArchPanel.PanelSheet): # process the sheet
# Cancel ExpandProfile feature. Unavailable for ArchPanels.
if obj.ExpandProfile.Value != 0.0:
obj.ExpandProfile.Value == 0.0
msg = translate('PathProfile', 'No ExpandProfile support for ArchPanel models.')
FreeCAD.Console.PrintWarning(msg + '\n')
modelProxy = self.model[0].Proxy
# Process circles and holes if requested by user
if obj.processCircles or obj.processHoles:
Expand Down Expand Up @@ -631,77 +577,14 @@ def _openingType(self, obj, baseShape, face, strDep, finDep):
PathLog.debug('_openingType() ' + msg)
return -2

# Method for expanded profile
def _getExpandedProfileEnvelope(self, obj, faceShape, isHole, strDep, finalDep):
shapeZ = faceShape.BoundBox.ZMin

def calculateOffsetValue(obj, isHole):
offset = obj.ExpandProfile.Value + obj.OffsetExtra.Value # 0.0
if obj.UseComp:
offset = obj.OffsetExtra.Value + self.tool.Diameter
offset += obj.ExpandProfile.Value
if isHole:
if obj.Side == 'Outside':
offset = 0 - offset
else:
if obj.Side == 'Inside':
offset = 0 - offset
return offset

faceEnv = self.PathSurfaceSupport.getShapeEnvelope(faceShape)
# newFace = self.PathSurfaceSupport.getSliceFromEnvelope(faceEnv)
newFace = self.PathSurfaceSupport.getShapeSlice(faceEnv)
# Compute necessary offset
offsetVal = calculateOffsetValue(obj, isHole)
expandedFace = self.PathSurfaceSupport.extractFaceOffset(newFace, offsetVal, newFace)
if expandedFace:
if shapeZ != 0.0:
expandedFace.translate(FreeCAD.Vector(0.0, 0.0, shapeZ))
newFace.translate(FreeCAD.Vector(0.0, 0.0, shapeZ))

if isHole:
if obj.Side == 'Outside':
newFace = newFace.cut(expandedFace)
else:
newFace = expandedFace.cut(newFace)
else:
if obj.Side == 'Inside':
newFace = newFace.cut(expandedFace)
else:
newFace = expandedFace.cut(newFace)

if finalDep - shapeZ != 0:
newFace.translate(FreeCAD.Vector(0.0, 0.0, finalDep - shapeZ))

if strDep - finalDep != 0:
if newFace.Area > 0:
return newFace.extrude(FreeCAD.Vector(0.0, 0.0, strDep - finalDep))
else:
PathLog.debug('No expanded profile face shape.\n')
return False
else:
PathLog.debug(translate('PathProfile', 'Failed to extract offset(s) for expanded profile.') + '\n')

PathLog.debug(translate('PathProfile', 'Failed to expand profile.') + '\n')
return False

# Method to handle each model as a whole, when no faces are selected
# It includes ExpandProfile implementation
def _processEachModel(self, obj):
shapeTups = list()
for base in self.model:
if hasattr(base, 'Shape'):
env = PathUtils.getEnvelope(partshape=base.Shape, subshape=None, depthparams=self.depthparams)
if self.expandProfile:
eSlice = self.PathSurfaceSupport.getCrossSection(env) # getSliceFromEnvelope(env)
eSlice.translate(FreeCAD.Vector(0.0, 0.0, base.Shape.BoundBox.ZMin - env.BoundBox.ZMin))
self._addDebugObject('ModelSlice', eSlice)
shapeEnv = self._getExpandedProfileEnvelope(obj, eSlice, False, obj.StartDepth.Value, obj.FinalDepth.Value)
else:
shapeEnv = env

if shapeEnv:
shapeTups.append((shapeEnv, False))
if env:
shapeTups.append((env, False))
return shapeTups

# Edges pre-processing
Expand All @@ -711,7 +594,7 @@ def _processEdges(self, obj):
basewires = list()
delPairs = list()
ezMin = None
self.cutOut = self.tool.Diameter * (float(obj.ExpandProfileStepOver) / 100.0)
self.cutOut = self.tool.Diameter

for p in range(0, len(obj.Base)):
(base, subsList) = obj.Base[p]
Expand Down Expand Up @@ -745,11 +628,7 @@ def _processEdges(self, obj):
(origWire, flatWire) = self._flattenWire(obj, wire, obj.FinalDepth.Value)
f = flatWire.Wires[0]
if f:
if self.expandProfile:
shapeEnv = self._getExpandedProfileEnvelope(obj, Part.Face(f), False, obj.StartDepth.Value, ezMin)
else:
shapeEnv = PathUtils.getEnvelope(Part.Face(f), depthparams=self.depthparams)

shapeEnv = PathUtils.getEnvelope(Part.Face(f), depthparams=self.depthparams)
if shapeEnv:
tup = shapeEnv, False, 'Profile', 0.0, 'X', obj.StartDepth.Value, obj.FinalDepth.Value
shapes.append(tup)
Expand All @@ -771,14 +650,6 @@ def _processEdges(self, obj):

self._addDebugObject('FlatWire', flatWire)

if self.expandProfile:
# Identify list of pass offset values for expanded profile paths
regularOfst = self.ofstRadius
targetOfst = regularOfst + obj.ExpandProfile.Value
while regularOfst < targetOfst:
regularOfst += self.cutOut
passOffsets.insert(0, regularOfst)

for po in passOffsets:
self.ofstRadius = po
cutShp = self._getCutAreaCrossSection(obj, base, origWire, flatWire)
Expand Down

0 comments on commit df76384

Please sign in to comment.