Commit 2ece945d authored by sumpfralle's avatar sumpfralle

r641@erker: lars | 2010-02-10 03:54:10 +0100

 replace the complex triangle testing with ODE's collision check


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@106 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 45f65926
......@@ -5,10 +5,11 @@ from pycam.Geometry.intersection import intersect_lines
class DropCutter:
def __init__(self, cutter, model, PathProcessor=None):
def __init__(self, cutter, model, PathProcessor=None, physics=None):
self.cutter = cutter
self.model = model
self.processor = PathProcessor
self.physics = physics
def GenerateToolPath(self, minx, maxx, miny, maxy, z0, z1, dx, dy, direction):
if self.processor:
......@@ -30,42 +31,21 @@ class DropCutter:
cl_max = None
t_max = None
self.cutter.moveto(p)
triangles = self.model.triangles(p.x-self.cutter.radius,p.y-self.cutter.radius,z0,p.x+self.cutter.radius,p.y+self.cutter.radius,+INFINITE)
for t in 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
t_max = t
if not cl_max or cl_max.z<z0:
cl_max = Point(x,y,z0)
if cl_last and ((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))
z = z1
dz = (z1-z0)/100
collision = False
while (z >= z0) and not collision:
self.physics.set_drill_position((x, y, z))
if self.physics.check_collision():
z_max = z + dz
collision = True
z -= dz
if collision:
pa.append(Point(x, y, z_max))
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
(X,Z) = intersect_lines(xl, zl, nxl, nzl, xm, zm, nxm, nzm)
if X and xl < X and X < xm and (Z > zl or Z > zm):
Y = cl_last.y
if Z<z0-10 or Z>z1+10:
print "^", "xl=",xl,", zl=",zl,"nxl=",nxl,", nzl=",nzl,", X=", X, ", Z=",Z,", xm=",xm,",zm=",zm, ", nxm=",nxm,",nzm=",nzm
else:
pa.append(Point(X,Y,Z))
pa.append(cl_max)
pa.append(Point(x, y, z0))
cl_last = cl_max
t_last = t_max
x += dx
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