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)) (cl, d) = cutter.intersect(forward, t)
hits.append(Hit(cl.sub(backward_small), t, -d + epsilon, backward)) if cl:
hits.append(Hit(cl.add(backward_small), t, -d - epsilon, backward)) hits.append(Hit(cl, t, d, forward))
if n <= 0:
(cl, d) = cutter.intersect(forward, t)
if cl:
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 = [] for h in hits:
previous_hit = None if h.dir == forward:
for one_hit in hits: if len(t)==0:
if not ((minx - epsilon) < one_hit.cl.x < (maxx + epsilon)): if h.d >= 0:
continue if len(points) == 0:
elif not ((miny - epsilon) < one_hit.cl.y < (maxy + epsilon)): points.append(p1)
continue points.append(h.cl)
elif not ((minz - epsilon) < one_hit.cl.z < (maxz + epsilon)): t.append(h.t)
continue
elif previous_hit and (abs(previous_hit.d - one_hit.d) < epsilon / 2):
continue
else: else:
previous_hit = one_hit t.remove(h.t)
filtered_hits.append(one_hit) if len(t)==0:
hits = filtered_hits if h.d <= xyz_dist:
points.append(h.cl)
# determine height at each interesting point if len(points)%2 == 1:
for h in hits: points.append(p2)
(zmax, tmax) = drop_cutter_test(cutter, h.cl, model)
h.z = zmax
# find first hit cutter location that is below z-level if len(hits)==0:
begin = hits[0].cl points.append(p1)
end = None points.append(p2)
for h in hits:
if h.z >= minz - epsilon / 10:
if begin and end:
points.append(begin)
points.append(end)
begin = None
end = None
if h.z <= maxz + epsilon / 10:
if not begin:
begin = h.cl
else:
end = h.cl
# add add possibly remaining couple from the previous loop
if begin and end:
points.append(begin)
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