Commit b8cdc088 authored by sumpfralle's avatar sumpfralle

fixed and simplified center positioning of cutters


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@580 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 160bf6ff
......@@ -33,7 +33,6 @@ class BaseCutter(object):
def __init__(self, radius, location=None, height=None):
if location is None:
location = Point(0, 0, 0)
self.location = location
if height is None:
height = 10
radius = number(radius)
......@@ -48,6 +47,7 @@ class BaseCutter(object):
# self.minx, self.maxx, self.miny and self.maxy are defined as
# properties below
self.shape = {}
self.moveto(location)
def _get_minx(self):
return self.location.x - self.distance_radius
......
......@@ -22,7 +22,7 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
"""
from pycam.Geometry.utils import INFINITE, sqrt, epsilon
from pycam.Geometry.Point import Point
from pycam.Geometry.Point import Point, Vector
from pycam.Geometry.intersection import intersect_circle_plane, \
intersect_circle_point, intersect_circle_line, \
intersect_cylinder_point, intersect_cylinder_line
......@@ -41,9 +41,7 @@ class CylindricalCutter(BaseCutter):
def __init__(self, radius, **kwargs):
BaseCutter.__init__(self, radius, **kwargs)
self.axis = Point(0, 0, 1)
self.center = self.location.sub(Point(0, 0,
self.get_required_distance()))
self.axis = Vector(0, 0, 1)
def __repr__(self):
return "CylindricalCutter<%s,%s>" % (self.location, self.radius)
......@@ -134,7 +132,7 @@ class CylindricalCutter(BaseCutter):
def moveto(self, location):
BaseCutter.moveto(self, location)
self.center = location.sub(Point(0, 0, self.get_required_distance()))
self.center = Point(location.x, location.y, location.z - self.get_required_distance())
def intersect_circle_plane(self, direction, triangle):
(ccp, cp, d) = intersect_circle_plane(self.center, self.distance_radius,
......@@ -199,7 +197,7 @@ class CylindricalCutter(BaseCutter):
self.distance_radius, self.distance_radiussq, direction, edge)
# offset intersection
if ccp:
cl = cp.add(self.location.sub(ccp))
cl = self.location.add(cp.sub(ccp))
return (cl, ccp, cp, l)
return (None, None, None, INFINITE)
......
......@@ -22,7 +22,7 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
"""
from pycam.Geometry import Matrix
from pycam.Geometry.Point import Point
from pycam.Geometry.Point import Point, Vector
from pycam.Geometry.utils import INFINITE, epsilon, sqrt
from pycam.Geometry.intersection import intersect_sphere_plane, \
intersect_sphere_point, intersect_sphere_line, \
......@@ -42,9 +42,7 @@ class SphericalCutter(BaseCutter):
def __init__(self, radius, **kwargs):
BaseCutter.__init__(self, radius, **kwargs)
self.axis = Point(0, 0, 1)
self.center = Point(self.location.x, self.location.y,
self.location.z + self.radius)
self.axis = Vector(0, 0, 1)
def __repr__(self):
return "SphericalCutter<%s,%s>" % (self.location, self.radius)
......@@ -142,7 +140,7 @@ class SphericalCutter(BaseCutter):
def moveto(self, location):
BaseCutter.moveto(self, location)
self.center = Point(location.x, location.y, location.z+self.radius)
self.center = Point(location.x, location.y, location.z + self.radius)
def intersect_sphere_plane(self, direction, triangle):
(ccp, cp, d) = intersect_sphere_plane(self.center, self.distance_radius,
......@@ -192,7 +190,7 @@ class SphericalCutter(BaseCutter):
return (cl, l)
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,
self.distance_radius, self.distance_radiussq, direction, point)
# offset intersection
if ccp:
......
......@@ -41,13 +41,12 @@ except ImportError:
class ToroidalCutter(BaseCutter):
def __init__(self, radius, minorradius, **kwargs):
BaseCutter.__init__(self, radius, **kwargs)
minorradius = number(minorradius)
self.majorradius = self.radius - minorradius
self.minorradius = minorradius
# we need "minorradius" for "moveto" - thus set it before parent's init
BaseCutter.__init__(self, radius, **kwargs)
self.majorradius = self.radius - minorradius
self.axis = Point(0, 0, 1)
self.center = Point(self.location.x, self.location.y,
self.location.z + minorradius)
self.majorradiussq = self.majorradius ** 2
self.minorradiussq = self.minorradius ** 2
self.distance_majorradius = self.majorradius \
......
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