Commit d10a0093 authored by lode_leroy's avatar lode_leroy

add direction switch

git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@15 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 46b75a3d
...@@ -189,7 +189,11 @@ class SimpleGui(Frame): ...@@ -189,7 +189,11 @@ class SimpleGui(Frame):
dy = (maxy-miny)/(lines-1) dy = (maxy-miny)/(lines-1)
else: else:
dy = INFINITE dy = INFINITE
self.toolpath = self.pathgenerator.GenerateToolPath(minx, maxx, miny, maxy, minz, maxz, dx, dy) if self.Dir.get() == "x":
self.toolpath = self.pathgenerator.GenerateToolPath(minx, maxx, miny, maxy, minz, maxz, dx, dy, 0)
else:
self.toolpath = self.pathgenerator.GenerateToolPath(minx, maxx, miny, maxy, minz, maxz, dy, dx, 1)
elif self.PathGeneratorName.get() == "PushCutter": elif self.PathGeneratorName.get() == "PushCutter":
if self.PathProcessorName.get() == "PathAccumulator": if self.PathProcessorName.get() == "PathAccumulator":
self.option = PathAccumulator() self.option = PathAccumulator()
...@@ -210,7 +214,10 @@ class SimpleGui(Frame): ...@@ -210,7 +214,10 @@ class SimpleGui(Frame):
dz = (maxz-minz)/(layers-1) dz = (maxz-minz)/(layers-1)
else: else:
dz = INFINITE dz = INFINITE
self.toolpath = self.pathgenerator.GenerateToolPath(minx, maxx, miny, maxy, minz, maxz, 0, dy, dz) if self.Dir.get() == "x":
self.toolpath = self.pathgenerator.GenerateToolPath(minx, maxx, miny, maxy, minz, maxz, 0, dy, dz)
else:
self.toolpath = self.pathgenerator.GenerateToolPath(minx, maxx, miny, maxy, minz, maxz, dy, 0, dz)
self.ogl.tkRedraw() self.ogl.tkRedraw()
def browseSaveAs(self): def browseSaveAs(self):
...@@ -285,6 +292,12 @@ class SimpleGui(Frame): ...@@ -285,6 +292,12 @@ class SimpleGui(Frame):
Radiobutton(self.ConfigurationFrame, text="mm", variable=self.Unit, value="mm", command=self.ogl.tkRedraw).pack(side=LEFT) Radiobutton(self.ConfigurationFrame, text="mm", variable=self.Unit, value="mm", command=self.ogl.tkRedraw).pack(side=LEFT)
Radiobutton(self.ConfigurationFrame, text="in", variable=self.Unit, value="in", command=self.ogl.tkRedraw).pack(side=LEFT) Radiobutton(self.ConfigurationFrame, text="in", variable=self.Unit, value="in", command=self.ogl.tkRedraw).pack(side=LEFT)
Label(self.ConfigurationFrame, text="Dir: ").pack(side=LEFT)
self.Dir = StringVar()
self.Dir.set("x")
Radiobutton(self.ConfigurationFrame, text="x", variable=self.Dir, value="x", command=self.ogl.tkRedraw).pack(side=LEFT)
Radiobutton(self.ConfigurationFrame, text="y", variable=self.Dir, value="y", command=self.ogl.tkRedraw).pack(side=LEFT)
self.MinX = StringVar() self.MinX = StringVar()
self.MinX.set("-7") self.MinX.set("-7")
self.MinY = StringVar() self.MinY = StringVar()
......
...@@ -9,37 +9,66 @@ class DropCutter: ...@@ -9,37 +9,66 @@ class DropCutter:
self.model = model self.model = model
self.processor = PathProcessor self.processor = PathProcessor
def GenerateToolPath(self, minx, maxx, miny, maxy, z0, z1, dx, dy, dz=0): def GenerateToolPath(self, minx, maxx, miny, maxy, z0, z1, dx, dy, direction):
if self.processor: if self.processor:
pa = self.processor pa = self.processor
else: else:
pa = PathAccumulator() pa = PathAccumulator()
pa.new_direction(0) if (direction==0):
y = miny pa.new_direction(0)
while y<=maxy: y = miny
while y<=maxy:
x = minx
pa.new_scanline()
while x<=maxx:
p = Point(x,y,z1)
z_max = -INFINITE
cl_max = None
self.cutter.moveto(p)
for t in self.model.triangles():
if t.normal().z < 0: continue;
cl = self.cutter.drop(t)
if cl and (cl.z > z_max or cl_max is None):
z_max = cl.z
cl_max = cl
if not cl_max or cl_max.z<z0:
cl_max = Point(x,y,z0)
pa.append(cl_max)
x += dx
pa.end_scanline()
y += dy
pa.end_direction()
if direction==1:
pa.new_direction(1)
x = minx x = minx
pa.new_scanline()
while x<=maxx: while x<=maxx:
p = Point(x,y,z1) y = miny
z_max = -INFINITE pa.new_scanline()
cl_max = None while y<=maxy:
self.cutter.moveto(p) p = Point(x,y,z1)
for t in self.model.triangles(): z_max = -INFINITE
if t.normal().z < 0: continue; cl_max = None
cl = self.cutter.drop(t) self.cutter.moveto(p)
if cl and (cl.z > z_max or cl_max is None): for t in self.model.triangles():
z_max = cl.z if t.normal().z < 0: continue;
cl_max = cl cl = self.cutter.drop(t)
if not cl_max or cl_max.z<z0: if cl and (cl.z > z_max or cl_max is None):
cl_max = Point(x,y,z0) z_max = cl.z
pa.append(cl_max) cl_max = cl
if not cl_max or cl_max.z<z0:
cl_max = Point(x,y,z0)
pa.append(cl_max)
y += dy
pa.end_scanline()
x += dx x += dx
pa.end_scanline() pa.end_direction()
y += dy
pa.end_direction()
pa.finish() pa.finish()
return pa.paths return pa.paths
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