Commit 42164895 authored by lode_leroy's avatar lode_leroy

fix PushCutter

git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@400 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 0dbbd848
...@@ -80,7 +80,6 @@ def get_free_paths_triangles(model, cutter, p1, p2): ...@@ -80,7 +80,6 @@ def get_free_paths_triangles(model, cutter, p1, p2):
# find all hits along scan line # find all hits along scan line
hits = [] hits = []
hits.append(Hit(p1, None, 0, None))
triangles = model.triangles(minx - cutter.radius, miny - cutter.radius, minz, triangles = model.triangles(minx - cutter.radius, miny - cutter.radius, minz,
maxx + cutter.radius, maxy + cutter.radius, INFINITE) maxx + cutter.radius, maxy + cutter.radius, INFINITE)
...@@ -89,69 +88,39 @@ def get_free_paths_triangles(model, cutter, p1, p2): ...@@ -89,69 +88,39 @@ def get_free_paths_triangles(model, cutter, p1, p2):
# normals point outward... and we want to approach the model from the outside! # normals point outward... and we want to approach the model from the outside!
n = t.normal().dot(forward) n = t.normal().dot(forward)
cutter.moveto(p1) cutter.moveto(p1)
if n >= 0:
(cl, d) = cutter.intersect(backward, t) (cl, d) = cutter.intersect(backward, t)
if cl: if cl:
hits.append(Hit(cl, t, -d, backward)) hits.append(Hit(cl, t, -d, backward))
hits.append(Hit(cl.sub(backward_small), t, -d + epsilon, backward))
hits.append(Hit(cl.add(backward_small), t, -d - epsilon, backward))
if n <= 0:
(cl, d) = cutter.intersect(forward, t) (cl, d) = cutter.intersect(forward, t)
if cl: if cl:
hits.append(Hit(cl, t, d, forward)) hits.append(Hit(cl, t, d, forward))
hits.append(Hit(cl.add(forward_small), t, d + epsilon, forward))
hits.append(Hit(cl.sub(forward_small), t, d - epsilon, forward))
hits.append(Hit(p2, None, xyz_dist, None))
# sort along the scan direction # sort along the scan direction
hits.sort(Hit.cmp) hits.sort(Hit.cmp)
# Remove duplicates (typically shared edges) c = None
# Remove hits outside the min/max area of x/y/z (especially useful for the t = []
# short-line cuts of the EngraveCutter points = []
filtered_hits = []
previous_hit = None
for one_hit in hits:
if not ((minx - epsilon) < one_hit.cl.x < (maxx + epsilon)):
continue
elif not ((miny - epsilon) < one_hit.cl.y < (maxy + epsilon)):
continue
elif not ((minz - epsilon) < one_hit.cl.z < (maxz + epsilon)):
continue
elif previous_hit and (abs(previous_hit.d - one_hit.d) < epsilon / 2):
continue
else:
previous_hit = one_hit
filtered_hits.append(one_hit)
hits = filtered_hits
# determine height at each interesting point
for h in hits:
(zmax, tmax) = drop_cutter_test(cutter, h.cl, model)
h.z = zmax
# find first hit cutter location that is below z-level
begin = hits[0].cl
end = None
for h in hits: for h in hits:
if h.z >= minz - epsilon / 10: if h.dir == forward:
if begin and end: if len(t)==0:
points.append(begin) if h.d >= 0:
points.append(end) if len(points) == 0:
begin = None points.append(p1)
end = None points.append(h.cl)
if h.z <= maxz + epsilon / 10: t.append(h.t)
if not begin:
begin = h.cl
else: else:
end = h.cl t.remove(h.t)
if len(t)==0:
if h.d <= xyz_dist:
points.append(h.cl)
if len(points)%2 == 1:
points.append(p2)
# add add possibly remaining couple from the previous loop if len(hits)==0:
if begin and end: points.append(p1)
points.append(begin) points.append(p2)
points.append(end)
return points return points
......
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