Commit c28aa124 authored by sumpfralle's avatar sumpfralle

added an optional "reverse" parameter to all postprocessors


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@703 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent c1462ef4
...@@ -24,12 +24,13 @@ from pycam.Geometry.PolygonExtractor import PolygonExtractor ...@@ -24,12 +24,13 @@ from pycam.Geometry.PolygonExtractor import PolygonExtractor
from pycam.Toolpath import simplify_toolpath from pycam.Toolpath import simplify_toolpath
class ContourCutter: class ContourCutter:
def __init__(self): def __init__(self, reverse=False):
self.paths = [] self.paths = []
self.curr_path = None self.curr_path = None
self.scanline = None self.scanline = None
self.pe = None self.pe = None
self.points = [] self.points = []
self.reverse = reverse
def append(self, p): def append(self, p):
self.points.append(p) self.points.append(p)
...@@ -65,6 +66,8 @@ class ContourCutter: ...@@ -65,6 +66,8 @@ class ContourCutter:
p.append(p.points[0]) p.append(p.points[0])
simplify_toolpath(p) simplify_toolpath(p)
if paths: if paths:
if self.reverse:
paths.reverse()
self.paths.extend(paths) self.paths.extend(paths)
self.pe = None self.pe = None
...@@ -26,11 +26,12 @@ from pycam.Geometry.Path import Path ...@@ -26,11 +26,12 @@ from pycam.Geometry.Path import Path
class PathAccumulator: class PathAccumulator:
def __init__(self, zigzag=False): def __init__(self, zigzag=False, reverse=False):
self.paths = [] self.paths = []
self.curr_path = None self.curr_path = None
self.zigzag = zigzag self.zigzag = zigzag
self.scanline = None self.scanline = None
self.reverse = reverse
def append(self, p): def append(self, p):
if self.curr_path == None: if self.curr_path == None:
...@@ -53,6 +54,8 @@ class PathAccumulator: ...@@ -53,6 +54,8 @@ class PathAccumulator:
if self.curr_path: if self.curr_path:
if self.zigzag and (self.scanline % 2 == 0): if self.zigzag and (self.scanline % 2 == 0):
self.curr_path.reverse() self.curr_path.reverse()
if self.reverse:
self.curr_path.reverse()
simplify_toolpath(self.curr_path) simplify_toolpath(self.curr_path)
self.paths.append(self.curr_path) self.paths.append(self.curr_path)
self.curr_path = None self.curr_path = None
......
...@@ -27,11 +27,12 @@ from pycam.Toolpath import simplify_toolpath ...@@ -27,11 +27,12 @@ from pycam.Toolpath import simplify_toolpath
class PolygonCutter: class PolygonCutter:
def __init__(self): def __init__(self, reverse=False):
self.paths = [] self.paths = []
self.curr_path = None self.curr_path = None
self.scanline = None self.scanline = None
self.pe = PolygonExtractor(PolygonExtractor.MONOTONE) self.pe = PolygonExtractor(PolygonExtractor.MONOTONE)
self.reverse = reverse
def append(self, p): def append(self, p):
self.pe.append(p) self.pe.append(p)
...@@ -70,5 +71,7 @@ class PolygonCutter: ...@@ -70,5 +71,7 @@ class PolygonCutter:
if paths: if paths:
for p in paths: for p in paths:
simplify_toolpath(p) simplify_toolpath(p)
if self.reverse:
p.reverse()
self.paths.extend(paths) self.paths.extend(paths)
...@@ -24,9 +24,10 @@ from pycam.Geometry.Path import Path ...@@ -24,9 +24,10 @@ from pycam.Geometry.Path import Path
from pycam.Toolpath import simplify_toolpath from pycam.Toolpath import simplify_toolpath
class SimpleCutter: class SimpleCutter:
def __init__(self): def __init__(self, reverse=False):
self.paths = [] self.paths = []
self.curr_path = None self.curr_path = None
self.reverse = reverse
def append(self, p): def append(self, p):
curr_path = None curr_path = None
...@@ -39,7 +40,10 @@ class SimpleCutter: ...@@ -39,7 +40,10 @@ class SimpleCutter:
curr_path.append(p) curr_path.append(p)
if self.curr_path == None: if self.curr_path == None:
simplify_toolpath(curr_path) simplify_toolpath(curr_path)
self.paths.append(curr_path) if self.reverse:
self.paths.insert(0, curr_path)
else:
self.paths.append(curr_path)
def new_direction(self, direction): def new_direction(self, direction):
pass pass
......
...@@ -24,11 +24,12 @@ from pycam.Geometry.Path import Path ...@@ -24,11 +24,12 @@ from pycam.Geometry.Path import Path
from pycam.Toolpath import simplify_toolpath from pycam.Toolpath import simplify_toolpath
class ZigZagCutter: class ZigZagCutter:
def __init__(self): def __init__(self, reverse=False):
self.paths = [] self.paths = []
self.curr_path = None self.curr_path = None
self.scanline = None self.scanline = None
self.curr_scanline = None self.curr_scanline = None
self.reverse = reverse
def append(self, p): def append(self, p):
curr_path = None curr_path = None
...@@ -61,8 +62,11 @@ class ZigZagCutter: ...@@ -61,8 +62,11 @@ class ZigZagCutter:
def end_scanline(self): def end_scanline(self):
for path in self.curr_scanline: for path in self.curr_scanline:
simplify_toolpath(path) simplify_toolpath(path)
if self.reverse:
path.reverse()
self.paths.append(path) self.paths.append(path)
self.curr_scanline = None self.curr_scanline = None
def finish(self): def finish(self):
pass pass
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment