Commit 8e361d19 authored by lode_leroy's avatar lode_leroy

fix verticals in DropCutter

git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@17 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 11850916
The DropCutter goes as folows:
1) make lines along the X-axis (Lines)
2) for each line, take a number of samples (Samples)
3) at each sample, drop the cutter until it hits the model, this is a cutter location point
4) connect the cutter location points along the line
The PushCutter goes as follows:
1) make slices along the Z-axis (Levels)
2) make lines along the X-axis (Lines)
3) push the cutter along the line until it hits the model, this is a cutter location
if we do not hit anything, we're finished
4) skip the parts where the model is above the current z-level
5) go back to 3
The PathAccumulator connects the cutter locations by cutting in between,
it's usefull mainly for debugging
The SimpleCutter connects the cutter locations in an on-off (cut/don't cut) pattern,
it's usefull only for debugging
The ZigZagCutter connects the cutter locations by cutting in between points,
then come back along the next line in reverse direction.
it's usefull mainly in combination with the DropCutter
The PolygonCutter extracts polygonial sections from the cutter scanlines,
then cuts those in a zig-zag pattern
it's usefull mainly in combination with the PushCutter
...@@ -3,7 +3,7 @@ from pycam.Geometry import * ...@@ -3,7 +3,7 @@ from pycam.Geometry import *
from pycam.Geometry.utils import * from pycam.Geometry.utils import *
class DropCutter: class DropCutter:
def __init__(self, cutter, model, PathProcessor=None): def __init__(self, cutter, model, PathProcessor=None):
self.cutter = cutter self.cutter = cutter
self.model = model self.model = model
...@@ -21,10 +21,12 @@ class DropCutter: ...@@ -21,10 +21,12 @@ class DropCutter:
while y<=maxy: while y<=maxy:
x = minx x = minx
pa.new_scanline() pa.new_scanline()
t_last = None
while x<=maxx: while x<=maxx:
p = Point(x,y,z1) p = Point(x,y,z1)
z_max = -INFINITE z_max = -INFINITE
cl_max = None cl_max = None
t_max = None
self.cutter.moveto(p) self.cutter.moveto(p)
for t in self.model.triangles(): for t in self.model.triangles():
if t.normal().z < 0: continue; if t.normal().z < 0: continue;
...@@ -32,10 +34,36 @@ class DropCutter: ...@@ -32,10 +34,36 @@ class DropCutter:
if cl and (cl.z > z_max or cl_max is None): if cl and (cl.z > z_max or cl_max is None):
z_max = cl.z z_max = cl.z
cl_max = cl cl_max = cl
t_max = t
if not cl_max or cl_max.z<z0: if not cl_max or cl_max.z<z0:
cl_max = Point(x,y,z0) cl_max = Point(x,y,z0)
if (t_max and not t_last) or (t_last and not t_max):
if cl_last.z < z_max:
pa.append(Point(cl_last.x,cl_last.y,cl_max.z))
else:
pa.append(Point(cl_max.x,cl_max.y,cl_last.z))
elif (t_max and t_last and cl_last and cl_max ) and (t_max != t_last):
nxl = t_last.normal().x
nzl = t_last.normal().z
nxm = t_max.normal().x
nzm = t_max.normal().z
xl = cl_last.x
zl = cl_last.z
xm = cl_max.x
zm = cl_max.z
try:
X = (zl-zm+(xm*nxm/nzm+xl*nxl/nzl))/(nxm/nzm+nxl/nzl)
Y = cl_last.y
Z = zl + (X-xl)*nxl/nzm
if xl > X and X < xm:
pa.append(Point(X,Y,Z))
except:
pass
pa.append(cl_max) pa.append(cl_max)
cl_last = cl_max
t_last = t_max
x += dx x += dx
pa.end_scanline() pa.end_scanline()
...@@ -48,10 +76,12 @@ class DropCutter: ...@@ -48,10 +76,12 @@ class DropCutter:
while x<=maxx: while x<=maxx:
y = miny y = miny
pa.new_scanline() pa.new_scanline()
t_last = None
while y<=maxy: while y<=maxy:
p = Point(x,y,z1) p = Point(x,y,z1)
z_max = -INFINITE z_max = -INFINITE
cl_max = None cl_max = None
t_max = None
self.cutter.moveto(p) self.cutter.moveto(p)
for t in self.model.triangles(): for t in self.model.triangles():
if t.normal().z < 0: continue; if t.normal().z < 0: continue;
...@@ -59,10 +89,38 @@ class DropCutter: ...@@ -59,10 +89,38 @@ class DropCutter:
if cl and (cl.z > z_max or cl_max is None): if cl and (cl.z > z_max or cl_max is None):
z_max = cl.z z_max = cl.z
cl_max = cl cl_max = cl
t_max = t
if not cl_max or cl_max.z<z0: if not cl_max or cl_max.z<z0:
cl_max = Point(x,y,z0) cl_max = Point(x,y,z0)
if (t_max and not t_last) or (t_last and not t_max):
if cl_last.z < z_max:
pa.append(Point(cl_last.x,cl_last.y,cl_max.z))
else:
pa.append(Point(cl_max.x,cl_max.y,cl_last.z))
elif (t_max and t_last and cl_last and cl_max ) and (t_max != t_last):
nyl = t_last.normal().y
nzl = t_last.normal().z
nym = t_max.normal().y
nzm = t_max.normal().z
yl = cl_last.y
zl = cl_last.z
ym = cl_max.y
zm = cl_max.z
try:
X = cl_last.x
Y = (zl-zm+(ym*nym/nzm+yl*nyl/nzl))/(nym/nzm+nyl/nzl)
Z = zl + (Y-yl)*nyl/nzm
if yl > Y and Y < ym:
pa.append(Point(X,Y,Z))
except:
pass
pa.append(cl_max) pa.append(cl_max)
cl_last = cl_max
t_last = t_max
y += dy y += dy
pa.end_scanline() pa.end_scanline()
......
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