Commit e3a6a053 authored by sumpfralle's avatar sumpfralle

implemented a separate generator class for object ID generation

* replaces the class variable based approach


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@1240 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent c9123e0a
...@@ -22,6 +22,7 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>. ...@@ -22,6 +22,7 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
""" """
from pycam.Geometry import IDGenerator
from pycam.Geometry.Point import Point from pycam.Geometry.Point import Point
from pycam.Geometry.utils import number, INFINITE, epsilon from pycam.Geometry.utils import number, INFINITE, epsilon
from pycam.Geometry.intersection import intersect_cylinder_point, \ from pycam.Geometry.intersection import intersect_cylinder_point, \
...@@ -29,19 +30,18 @@ from pycam.Geometry.intersection import intersect_cylinder_point, \ ...@@ -29,19 +30,18 @@ from pycam.Geometry.intersection import intersect_cylinder_point, \
import uuid import uuid
class BaseCutter(object): class BaseCutter(IDGenerator):
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):
super(BaseCutter, self).__init__()
if location is None: if location is None:
location = Point(0, 0, 0) location = Point(0, 0, 0)
if height is None: if height is None:
height = 10 height = 10
radius = number(radius) radius = number(radius)
self.height = number(height) self.height = number(height)
self.id = BaseCutter.id
BaseCutter.id += 1
self.radius = radius self.radius = radius
self.radiussq = radius ** 2 self.radiussq = radius ** 2
self.required_distance = 0 self.required_distance = 0
......
...@@ -184,6 +184,21 @@ def get_bezier_lines(points_with_bulge, segments=32): ...@@ -184,6 +184,21 @@ def get_bezier_lines(points_with_bulge, segments=32):
return result return result
def _id_generator():
current_id = 0
while True:
yield current_id
current_id += 1
class IDGenerator(object):
__id_gen_func = _id_generator()
def __init__(self):
self.id = self.__id_gen_func.next()
class TransformableContainer(object): class TransformableContainer(object):
""" a base class for geometrical objects containing other elements """ a base class for geometrical objects containing other elements
......
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