Skip to content

Commit

Permalink
Path: Apply missing CutMode setting when CutPattern = Offset
Browse files Browse the repository at this point in the history
The `CutMode` toggle had no effect. This fix applies the `CutMode` toggle when the `CutPattern = Offset`.  The indicated `CutMode` may not be accurate depending on the situation, but the toggle will change the cut direction as intended.
  • Loading branch information
Russ4262 committed Nov 9, 2020
1 parent 9b5eb77 commit 604cfaf
Showing 1 changed file with 51 additions and 1 deletion.
52 changes: 51 additions & 1 deletion src/Mod/Path/PathScripts/PathSurfaceSupport.py
Expand Up @@ -33,6 +33,7 @@
import Path
import PathScripts.PathLog as PathLog
import PathScripts.PathUtils as PathUtils
import PathScripts.PathOpTools as PathOpTools
import math

# lazily loaded modules
Expand Down Expand Up @@ -383,15 +384,64 @@ def _extractOffsetFaces(self):
wires = list()
shape = self.shape
offset = 0.0 # Start right at the edge of cut area
direction = 0
loop_cnt = 0

def _get_direction(w):
if PathOpTools._isWireClockwise(w):
return 1
return -1

def _reverse_wire(w):
rev_list = list()
for e in w.Edges:
rev_list.append(PathUtils.reverseEdge(e))
rev_list.reverse()
# return Part.Wire(Part.__sortEdges__(rev_list))
return Part.Wire(rev_list)

while True:
offsetArea = PathUtils.getOffsetArea(shape, offset, plane=self.wpc)
if not offsetArea:
# Area fully consumed
break

# set initial cut direction
if direction == 0:
first_face_wire = offsetArea.Faces[0].Wires[0]
direction = _get_direction(first_face_wire)
if self.obj.CutMode == 'Climb':
if direction == 1:
direction = -1
else:
if direction == -1:
direction = 1

# Correct cut direction for `Conventional` cuts
if self.obj.CutMode == 'Conventional':
if loop_cnt == 1:
direction = direction * -1

# process each wire within face
for f in offsetArea.Faces:
wire_cnt = 0
for w in f.Wires:
wires.append(w)
use_direction = direction
if wire_cnt > 0:
# swap direction for internal features
use_direction = direction * -1
wire_direction = _get_direction(w)
# Process wire
if wire_direction == use_direction:
# direction is correct
wires.append(w)
else:
# incorrect direction, so reverse wire
rw = _reverse_wire(w)
wires.append(rw)

offset -= self.cutOut
loop_cnt += 1
return wires
# Eclass

Expand Down

0 comments on commit 604cfaf

Please sign in to comment.