Commit 6364ac9a authored by sumpfralle's avatar sumpfralle

fixed some code-style issues


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@495 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent f113e154
...@@ -21,16 +21,13 @@ You should have received a copy of the GNU General Public License ...@@ -21,16 +21,13 @@ You should have received a copy of the GNU General Public License
along with PyCAM. If not, see <http://www.gnu.org/licenses/>. along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
""" """
import pycam.Geometry
from pycam.Geometry import * from pycam.Geometry.Point import Point
from pycam.Geometry.utils import *
from pycam.Geometry.utils import *
from math import sqrt
class BaseCutter:
class BaseCutter(object):
id = 0 id = 0
vertical = Point(0,0,-1) vertical = Point(0, 0, -1)
def __init__(self, radius, location=None, height=None): def __init__(self, radius, location=None, height=None):
if location is None: if location is None:
...@@ -46,7 +43,8 @@ class BaseCutter: ...@@ -46,7 +43,8 @@ class BaseCutter:
self.required_distance = 0 self.required_distance = 0
self.distance_radius = self.radius self.distance_radius = self.radius
self.distance_radiussq = self.distance_radius * self.distance_radius self.distance_radiussq = self.distance_radius * self.distance_radius
# self.minx, self.maxx, self.miny and self.maxy are defined as properties below # self.minx, self.maxx, self.miny and self.maxy are defined as
# properties below
self.shape = {} self.shape = {}
def _get_minx(self): def _get_minx(self):
...@@ -95,7 +93,8 @@ class BaseCutter: ...@@ -95,7 +93,8 @@ class BaseCutter:
set_pos_func(location.x, location.y, location.z) set_pos_func(location.x, location.y, location.z)
def intersect(self, direction, triangle): def intersect(self, direction, triangle):
return (None, None, None, INFINITE) raise NotImplementedError("Inherited class of BaseCutter does not " \
+ "implement the required function 'intersect'.")
def drop(self, triangle): def drop(self, triangle):
# check bounding box collision # check bounding box collision
...@@ -110,10 +109,12 @@ class BaseCutter: ...@@ -110,10 +109,12 @@ class BaseCutter:
# check bounding circle 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.distance_radiussq+2*self.distance_radius*triangle.radius()+triangle.radiussq()): if (c.x - self.location.x) ** 2 + (c.y - self.location.y) ** 2 \
> (self.distance_radiussq + 2 * self.distance_radius \
* triangle.radius() + triangle.radiussq()):
return None return None
(cl,d)= self.intersect(BaseCutter.vertical, triangle) (cl, d)= self.intersect(BaseCutter.vertical, triangle)
return cl return cl
def push(self, dx, dy, triangle): def push(self, dx, dy, triangle):
...@@ -129,16 +130,16 @@ class BaseCutter: ...@@ -129,16 +130,16 @@ class BaseCutter:
return None return None
if self.maxx < triangle.minx(): if self.maxx < triangle.minx():
return None return None
if triangle.maxz()<self.location.z: if triangle.maxz() < self.location.z:
return None return None
# check bounding sphere collision # check bounding sphere collision
c = triangle.center() c = triangle.center()
d = (c.x-self.location.x)*dy-(c.y-self.location.y)*dx d = (c.x - self.location.x) * dy -(c.y - self.location.y) * dx
t = self.radius + triangle.radius() t = self.radius + triangle.radius()
if d < -t or d > t: if abs(d) > t:
return None return None
(cl,d)= self.intersect(Point(dx,dy,0), triangle) (cl, d)= self.intersect(Point(dx, dy, 0), triangle)
return cl return cl
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -20,13 +20,13 @@ You should have received a copy of the GNU General Public License ...@@ -20,13 +20,13 @@ You should have received a copy of the GNU General Public License
along with PyCAM. If not, see <http://www.gnu.org/licenses/>. along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
""" """
list = [ "SphericalCutter", "CylindricalCutter", "ToroidalCutter" ] __all__ = [ "SphericalCutter", "CylindricalCutter", "ToroidalCutter",
__all__ = [ "BaseCutter" ] + list "BaseCutter" ]
from BaseCutter import BaseCutter from pycam.Cutters.BaseCutter import BaseCutter
from SphericalCutter import SphericalCutter from pycam.Cutters.SphericalCutter import SphericalCutter
from CylindricalCutter import CylindricalCutter from pycam.Cutters.CylindricalCutter import CylindricalCutter
from ToroidalCutter import ToroidalCutter from pycam.Cutters.ToroidalCutter import ToroidalCutter
def get_tool_from_settings(tool_settings, height=None): def get_tool_from_settings(tool_settings, height=None):
......
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