Commit 9c306007 authored by lode_leroy's avatar lode_leroy

minor bugfixes

git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@69 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent d38c7c85
...@@ -44,9 +44,9 @@ class BaseCutter: ...@@ -44,9 +44,9 @@ class BaseCutter:
if self.maxy < triangle.miny(): if self.maxy < triangle.miny():
return None return None
# check bounding sphere collision # check bounding circle collision
c = triangle.center() c = triangle.center()
if sqr(c.x-self.location.x)+sqr(c.y-self.location.y)>self.radiussq+self.radius*triangle.radius()+triangle.radiussq(): if sqr(c.x-self.location.x)+sqr(c.y-self.location.y)>(self.radiussq+2*self.radius*triangle.radius()+triangle.radiussq()):
return None return None
(cl,d)= self.intersect(BaseCutter.vertical, triangle) (cl,d)= self.intersect(BaseCutter.vertical, triangle)
......
...@@ -57,7 +57,9 @@ class SphericalCutter(BaseCutter): ...@@ -57,7 +57,9 @@ class SphericalCutter(BaseCutter):
def intersect_sphere_point(self, direction, point): def intersect_sphere_point(self, direction, point):
(ccp,cp,l) = intersect_sphere_point(self.center, self.radius, self.radiussq, direction, point) (ccp,cp,l) = intersect_sphere_point(self.center, self.radius, self.radiussq, direction, point)
# offset intersection # offset intersection
cl = self.location.add(direction.mul(l)) cl = None
if cp:
cl = self.location.add(direction.mul(l))
return (cl,ccp,cp,l) return (cl,ccp,cp,l)
def intersect_sphere_vertex(self, direction, point): def intersect_sphere_vertex(self, direction, point):
......
...@@ -146,7 +146,7 @@ class Triangle: ...@@ -146,7 +146,7 @@ class Triangle:
v = dot00 * dot12 - dot01 * dot02 v = dot00 * dot12 - dot01 * dot02
# Check if point is in triangle # Check if point is in triangle
return ((u * denom) > 0) and ((v * denom) > 0) and (u + v < denom) return ((u * denom) >= 0) and ((v * denom) >= 0) and (u + v <= denom)
def minx(self): def minx(self):
if not hasattr(self, "_minx"): if not hasattr(self, "_minx"):
......
...@@ -23,12 +23,12 @@ class DropCutter: ...@@ -23,12 +23,12 @@ class DropCutter:
x = minx x = minx
pa.new_scanline() pa.new_scanline()
t_last = None t_last = None
cl_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 t_max = None
cl_last = 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) 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: for t in triangles:
...@@ -79,12 +79,12 @@ class DropCutter: ...@@ -79,12 +79,12 @@ class DropCutter:
y = miny y = miny
pa.new_scanline() pa.new_scanline()
t_last = None t_last = None
cl_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 t_max = None
cl_last = 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) 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: for t in triangles:
......
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