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 ...@@ -5,10 +5,11 @@ from pycam.Geometry.intersection import intersect_lines
class DropCutter: class DropCutter:
def __init__(self, cutter, model, PathProcessor=None): def __init__(self, cutter, model, PathProcessor=None, physics=None):
self.cutter = cutter self.cutter = cutter
self.model = model self.model = model
self.processor = PathProcessor self.processor = PathProcessor
self.physics = physics
def GenerateToolPath(self, minx, maxx, miny, maxy, z0, z1, dx, dy, direction): def GenerateToolPath(self, minx, maxx, miny, maxy, z0, z1, dx, dy, direction):
if self.processor: if self.processor:
...@@ -30,42 +31,21 @@ class DropCutter: ...@@ -30,42 +31,21 @@ class DropCutter:
cl_max = None cl_max = None
t_max = None t_max = None
self.cutter.moveto(p) 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)): z = z1
if cl_last.z < z_max: dz = (z1-z0)/100
pa.append(Point(cl_last.x,cl_last.y,cl_max.z)) collision = False
else: while (z >= z0) and not collision:
pa.append(Point(cl_max.x,cl_max.y,cl_last.z)) self.physics.set_drill_position((x, y, z))
elif (t_max and t_last and cl_last and cl_max ) and (t_max != t_last): if self.physics.check_collision():
nxl = -t_last.normal().x z_max = z + dz
nzl = t_last.normal().z collision = True
nxm = -t_max.normal().x z -= dz
nzm = t_max.normal().z if collision:
xl = cl_last.x pa.append(Point(x, y, z_max))
zl = cl_last.z else:
xm = cl_max.x pa.append(Point(x, y, z0))
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)
cl_last = cl_max
t_last = t_max
x += dx x += dx
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