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):
dy = (maxy-miny)/(lines-1)
else:
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":
if self.PathProcessorName.get() == "PathAccumulator":
self.option = PathAccumulator()
......@@ -210,7 +214,10 @@ class SimpleGui(Frame):
dz = (maxz-minz)/(layers-1)
else:
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()
def browseSaveAs(self):
......@@ -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="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.set("-7")
self.MinY = StringVar()
......
......@@ -9,37 +9,66 @@ class DropCutter:
self.model = model
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:
pa = self.processor
else:
pa = PathAccumulator()
pa.new_direction(0)
y = miny
while y<=maxy:
if (direction==0):
pa.new_direction(0)
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
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)
y = miny
pa.new_scanline()
while y<=maxy:
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)
y += dy
pa.end_scanline()
x += dx
pa.end_scanline()
y += dy
pa.end_direction()
pa.end_direction()
pa.finish()
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