Commit df116c21 authored by sumpfralle's avatar sumpfralle

added the point of collision in the triangle to the result of the intersection...

added the point of collision in the triangle to the result of the intersection function of the CylindricalCutter


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@672 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 61311568
...@@ -137,7 +137,7 @@ class CylindricalCutter(BaseCutter): ...@@ -137,7 +137,7 @@ class CylindricalCutter(BaseCutter):
def intersect_circle_plane(self, direction, triangle): def intersect_circle_plane(self, direction, triangle):
(ccp, cp, d) = intersect_circle_plane(self.center, self.distance_radius, (ccp, cp, d) = intersect_circle_plane(self.center, self.distance_radius,
direction, triangle) direction, triangle)
if ccp: if ccp and cp:
cl = cp.add(self.location.sub(ccp)) cl = cp.add(self.location.sub(ccp))
return (cl, ccp, cp, d) return (cl, ccp, cp, d)
return (None, None, None, INFINITE) return (None, None, None, INFINITE)
...@@ -145,8 +145,8 @@ class CylindricalCutter(BaseCutter): ...@@ -145,8 +145,8 @@ class CylindricalCutter(BaseCutter):
def intersect_circle_triangle(self, direction, triangle): def intersect_circle_triangle(self, direction, triangle):
(cl, ccp, cp, d) = self.intersect_circle_plane(direction, triangle) (cl, ccp, cp, d) = self.intersect_circle_plane(direction, triangle)
if cp and triangle.point_inside(cp): if cp and triangle.point_inside(cp):
return (cl, d) return (cl, d, cp)
return (None, INFINITE) return (None, INFINITE, None)
def intersect_circle_point(self, direction, point): def intersect_circle_point(self, direction, point):
(ccp, cp, l) = intersect_circle_point(self.center, self.axis, (ccp, cp, l) = intersect_circle_point(self.center, self.axis,
...@@ -158,7 +158,7 @@ class CylindricalCutter(BaseCutter): ...@@ -158,7 +158,7 @@ class CylindricalCutter(BaseCutter):
def intersect_circle_vertex(self, direction, point): def intersect_circle_vertex(self, direction, point):
(cl, ccp, cp, l) = self.intersect_circle_point(direction, point) (cl, ccp, cp, l) = self.intersect_circle_point(direction, point)
return (cl, l) return (cl, l, cp)
def intersect_circle_line(self, direction, edge): def intersect_circle_line(self, direction, edge):
(ccp, cp, l) = intersect_circle_line(self.center, self.axis, (ccp, cp, l) = intersect_circle_line(self.center, self.axis,
...@@ -174,8 +174,8 @@ class CylindricalCutter(BaseCutter): ...@@ -174,8 +174,8 @@ class CylindricalCutter(BaseCutter):
# check if the contact point is between the endpoints # check if the contact point is between the endpoints
m = cp.sub(edge.p1).dot(edge.dir) m = cp.sub(edge.p1).dot(edge.dir)
if (m < 0) or (m > edge.len + epsilon): if (m < 0) or (m > edge.len + epsilon):
return (None, INFINITE) return (None, INFINITE, cp)
return (cl, l) return (cl, l, cp)
def intersect_cylinder_point(self, direction, point): def intersect_cylinder_point(self, direction, point):
(ccp, cp, l) = intersect_cylinder_point(self.center, self.axis, (ccp, cp, l) = intersect_cylinder_point(self.center, self.axis,
...@@ -189,8 +189,8 @@ class CylindricalCutter(BaseCutter): ...@@ -189,8 +189,8 @@ class CylindricalCutter(BaseCutter):
def intersect_cylinder_vertex(self, direction, point): def intersect_cylinder_vertex(self, direction, point):
(cl, ccp, cp, l) = self.intersect_cylinder_point(direction, point) (cl, ccp, cp, l) = self.intersect_cylinder_point(direction, point)
if ccp and ccp.z < self.center.z - epsilon: if ccp and ccp.z < self.center.z - epsilon:
return (None, INFINITE) return (None, INFINITE, None)
return (cl, l) return (cl, l, cp)
def intersect_cylinder_line(self, direction, edge): def intersect_cylinder_line(self, direction, edge):
(ccp, cp, l) = intersect_cylinder_line(self.center, self.axis, (ccp, cp, l) = intersect_cylinder_line(self.center, self.axis,
...@@ -204,81 +204,95 @@ class CylindricalCutter(BaseCutter): ...@@ -204,81 +204,95 @@ class CylindricalCutter(BaseCutter):
def intersect_cylinder_edge(self, direction, edge): def intersect_cylinder_edge(self, direction, edge):
(cl, ccp, cp, l) = self.intersect_cylinder_line(direction, edge) (cl, ccp, cp, l) = self.intersect_cylinder_line(direction, edge)
if not ccp: if not ccp:
return (None, INFINITE) return (None, INFINITE, None)
m = cp.sub(edge.p1).dot(edge.dir) m = cp.sub(edge.p1).dot(edge.dir)
if (m < 0) or (m > edge.len + epsilon): if (m < 0) or (m > edge.len + epsilon):
return (None, INFINITE) return (None, INFINITE, None)
if ccp.z < self.center.z - epsilon: if ccp.z < self.center.z - epsilon:
return (None, INFINITE) return (None, INFINITE, None)
return (cl, l) return (cl, l, cp)
def intersect_plane(self, direction, triangle): def intersect_plane(self, direction, triangle):
return self.intersect_circle_plane(direction, triangle) return self.intersect_circle_plane(direction, triangle)
def intersect(self, direction, triangle): def intersect(self, direction, triangle):
(cl_t, d_t) = self.intersect_circle_triangle(direction, triangle) (cl_t, d_t, cp_t) = self.intersect_circle_triangle(direction, triangle)
d = INFINITE d = INFINITE
cl = None cl = None
cp = None
if d_t < d: if d_t < d:
d = d_t d = d_t
cl = cl_t cl = cl_t
cp = cp_t
if cl and (direction.x == 0) and (direction.y == 0): if cl and (direction.x == 0) and (direction.y == 0):
return (cl, d) return (cl, d, cp)
(cl_e1, d_e1) = self.intersect_circle_edge(direction, triangle.e1) (cl_e1, d_e1, cp_e1) = self.intersect_circle_edge(direction, triangle.e1)
(cl_e2, d_e2) = self.intersect_circle_edge(direction, triangle.e2) (cl_e2, d_e2, cp_e2) = self.intersect_circle_edge(direction, triangle.e2)
(cl_e3, d_e3) = self.intersect_circle_edge(direction, triangle.e3) (cl_e3, d_e3, cp_e3) = self.intersect_circle_edge(direction, triangle.e3)
if d_e1 < d: if d_e1 < d:
d = d_e1 d = d_e1
cl = cl_e1 cl = cl_e1
cp = cp_e1
if d_e2 < d: if d_e2 < d:
d = d_e2 d = d_e2
cl = cl_e2 cl = cl_e2
cp = cp_e2
if d_e3 < d: if d_e3 < d:
d = d_e3 d = d_e3
cl = cl_e3 cl = cl_e3
cp = cp_e3
if cl and (direction.x == 0) and (direction.y == 0): if cl and (direction.x == 0) and (direction.y == 0):
return (cl, d) return (cl, d, cp)
(cl_p1, d_p1) = self.intersect_circle_vertex(direction, triangle.p1) (cl_p1, d_p1, cp_p1) = self.intersect_circle_vertex(direction, triangle.p1)
(cl_p2, d_p2) = self.intersect_circle_vertex(direction, triangle.p2) (cl_p2, d_p2, cp_p2) = self.intersect_circle_vertex(direction, triangle.p2)
(cl_p3, d_p3) = self.intersect_circle_vertex(direction, triangle.p3) (cl_p3, d_p3, cp_p3) = self.intersect_circle_vertex(direction, triangle.p3)
if d_p1 < d: if d_p1 < d:
d = d_p1 d = d_p1
cl = cl_p1 cl = cl_p1
cp = cp_p1
if d_p2 < d: if d_p2 < d:
d = d_p2 d = d_p2
cl = cl_p2 cl = cl_p2
cp = cp_p2
if d_p3 < d: if d_p3 < d:
d = d_p3 d = d_p3
cl = cl_p3 cl = cl_p3
cp = cp_p3
if cl and (direction.x == 0) and (direction.y == 0): if cl and (direction.x == 0) and (direction.y == 0):
return (cl, d) return (cl, d, cp)
if (direction.x != 0) or (direction.y != 0): if (direction.x != 0) or (direction.y != 0):
(cl_p1, d_p1) = self.intersect_cylinder_vertex(direction, (cl_p1, d_p1, cp_p1) = self.intersect_cylinder_vertex(direction,
triangle.p1) triangle.p1)
(cl_p2, d_p2) = self.intersect_cylinder_vertex(direction, (cl_p2, d_p2, cp_p2) = self.intersect_cylinder_vertex(direction,
triangle.p2) triangle.p2)
(cl_p3, d_p3) = self.intersect_cylinder_vertex(direction, (cl_p3, d_p3, cp_p3) = self.intersect_cylinder_vertex(direction,
triangle.p3) triangle.p3)
if d_p1 < d: if d_p1 < d:
d = d_p1 d = d_p1
cl = cl_p1 cl = cl_p1
cp = cp_p1
if d_p2 < d: if d_p2 < d:
d = d_p2 d = d_p2
cl = cl_p2 cl = cl_p2
cp = cp_p2
if d_p3 < d: if d_p3 < d:
d = d_p3 d = d_p3
cl = cl_p3 cl = cl_p3
(cl_e1, d_e1) = self.intersect_cylinder_edge(direction, triangle.e1) cp = cp_p3
(cl_e2, d_e2) = self.intersect_cylinder_edge(direction, triangle.e2) (cl_e1, d_e1, cp_e1) = self.intersect_cylinder_edge(direction, triangle.e1)
(cl_e3, d_e3) = self.intersect_cylinder_edge(direction, triangle.e3) (cl_e2, d_e2, cp_e2) = self.intersect_cylinder_edge(direction, triangle.e2)
(cl_e3, d_e3, cp_e3) = self.intersect_cylinder_edge(direction, triangle.e3)
if d_e1 < d: if d_e1 < d:
d = d_e1 d = d_e1
cl = cl_e1 cl = cl_e1
cp = cp_e1
if d_e2 < d: if d_e2 < d:
d = d_e2 d = d_e2
cl = cl_e2 cl = cl_e2
cp = cp_e2
if d_e3 < d: if d_e3 < d:
d = d_e3 d = d_e3
cl = cl_e3 cl = cl_e3
return (cl, d) cp = cp_e3
return (cl, d, cp)
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