From 3538398e84b6899a61cfd1e3010c24e1f3098c8f Mon Sep 17 00:00:00 2001 From: jaseg Date: Thu, 7 Oct 2021 11:18:18 +0200 Subject: Remove unnecessary primitives --- gerbonara/gerber/primitives.py | 429 ----------------------------------------- 1 file changed, 429 deletions(-) (limited to 'gerbonara/gerber/primitives.py') diff --git a/gerbonara/gerber/primitives.py b/gerbonara/gerber/primitives.py index afe6ec4..445b605 100644 --- a/gerbonara/gerber/primitives.py +++ b/gerbonara/gerber/primitives.py @@ -592,73 +592,6 @@ class Circle(Primitive): return nearly_equal(self.position, equiv_position) -class Ellipse(Primitive): - """ - """ - def __init__(self, position, width, height, **kwargs): - super(Ellipse, self).__init__(**kwargs) - validate_coordinates(position) - self._position = position - self._width = width - self._height = height - self._to_convert = ['position', 'width', 'height'] - - @property - def flashed(self): - return True - - @property - def position(self): - return self._position - - @position.setter - def position(self, value): - self._changed() - self._position = value - - @property - def width(self): - return self._width - - @width.setter - def width(self, value): - self._changed() - self._width = value - - @property - def height(self): - return self._height - - @height.setter - def height(self, value): - self._changed() - self._height = value - - @property - def bounding_box(self): - if self._bounding_box is None: - min_x = self.position[0] - (self.axis_aligned_width / 2.0) - max_x = self.position[0] + (self.axis_aligned_width / 2.0) - min_y = self.position[1] - (self.axis_aligned_height / 2.0) - max_y = self.position[1] + (self.axis_aligned_height / 2.0) - self._bounding_box = ((min_x, min_y), (max_x, max_y)) - return self._bounding_box - - @property - def axis_aligned_width(self): - ux = (self.width / 2.) * math.cos(math.radians(self.rotation)) - vx = (self.height / 2.) * \ - math.cos(math.radians(self.rotation) + (math.pi / 2.)) - return 2 * math.sqrt((ux * ux) + (vx * vx)) - - @property - def axis_aligned_height(self): - uy = (self.width / 2.) * math.sin(math.radians(self.rotation)) - vy = (self.height / 2.) * \ - math.sin(math.radians(self.rotation) + (math.pi / 2.)) - return 2 * math.sqrt((uy * uy) + (vy * vy)) - - class Rectangle(Primitive): """ When rotated, the rotation is about the center point. @@ -783,285 +716,6 @@ class Rectangle(Primitive): return self.__str__() -class Diamond(Primitive): - """ - """ - - def __init__(self, position, width, height, **kwargs): - super(Diamond, self).__init__(**kwargs) - validate_coordinates(position) - self._position = position - self._width = width - self._height = height - self._to_convert = ['position', 'width', 'height'] - - @property - def flashed(self): - return True - - @property - def position(self): - return self._position - - @position.setter - def position(self, value): - self._changed() - self._position = value - - @property - def width(self): - return self._width - - @width.setter - def width(self, value): - self._changed() - self._width = value - - @property - def height(self): - return self._height - - @height.setter - def height(self, value): - self._changed() - self._height = value - - @property - def bounding_box(self): - if self._bounding_box is None: - ll = (self.position[0] - (self.axis_aligned_width / 2.), - self.position[1] - (self.axis_aligned_height / 2.)) - ur = (self.position[0] + (self.axis_aligned_width / 2.), - self.position[1] + (self.axis_aligned_height / 2.)) - self._bounding_box = ((ll[0], ll[1]), (ur[0], ur[1])) - return self._bounding_box - - @property - def vertices(self): - if self._vertices is None: - delta_w = self.width / 2. - delta_h = self.height / 2. - top = (self.position[0], (self.position[1] + delta_h)) - right = ((self.position[0] + delta_w), self.position[1]) - bottom = (self.position[0], (self.position[1] - delta_h)) - left = ((self.position[0] - delta_w), self.position[1]) - self._vertices = [(((x * self._cos_theta) - (y * self._sin_theta)), - ((x * self._sin_theta) + (y * self._cos_theta))) - for x, y in [top, right, bottom, left]] - return self._vertices - - @property - def axis_aligned_width(self): - return (self._cos_theta * self.width + self._sin_theta * self.height) - - @property - def axis_aligned_height(self): - return (self._cos_theta * self.height + self._sin_theta * self.width) - - -class ChamferRectangle(Primitive): - """ - """ - def __init__(self, position, width, height, chamfer, corners=None, **kwargs): - super(ChamferRectangle, self).__init__(**kwargs) - validate_coordinates(position) - self._position = position - self._width = width - self._height = height - self._chamfer = chamfer - self._corners = corners if corners is not None else [True] * 4 - self._to_convert = ['position', 'width', 'height', 'chamfer'] - - @property - def flashed(self): - return True - - @property - def position(self): - return self._position - - @position.setter - def position(self, value): - self._changed() - self._position = value - - @property - def width(self): - return self._width - - @width.setter - def width(self, value): - self._changed() - self._width = value - - @property - def height(self): - return self._height - - @height.setter - def height(self, value): - self._changed() - self._height = value - - @property - def chamfer(self): - return self._chamfer - - @chamfer.setter - def chamfer(self, value): - self._changed() - self._chamfer = value - - @property - def corners(self): - return self._corners - - @corners.setter - def corners(self, value): - self._changed() - self._corners = value - - @property - def bounding_box(self): - if self._bounding_box is None: - ll = (self.position[0] - (self.axis_aligned_width / 2.), - self.position[1] - (self.axis_aligned_height / 2.)) - ur = (self.position[0] + (self.axis_aligned_width / 2.), - self.position[1] + (self.axis_aligned_height / 2.)) - self._bounding_box = ((ll[0], ll[1]), (ur[1], ur[1])) - return self._bounding_box - - @property - def vertices(self): - if self._vertices is None: - vertices = [] - delta_w = self.width / 2. - delta_h = self.height / 2. - # order is UR, UL, LL, LR - rect_corners = [ - ((self.position[0] + delta_w), (self.position[1] + delta_h)), - ((self.position[0] - delta_w), (self.position[1] + delta_h)), - ((self.position[0] - delta_w), (self.position[1] - delta_h)), - ((self.position[0] + delta_w), (self.position[1] - delta_h)) - ] - for idx, params in enumerate(zip(rect_corners, self.corners)): - corner, chamfered = params - x, y = corner - if chamfered: - if idx == 0: - vertices.append((x - self.chamfer, y)) - vertices.append((x, y - self.chamfer)) - elif idx == 1: - vertices.append((x + self.chamfer, y)) - vertices.append((x, y - self.chamfer)) - elif idx == 2: - vertices.append((x + self.chamfer, y)) - vertices.append((x, y + self.chamfer)) - elif idx == 3: - vertices.append((x - self.chamfer, y)) - vertices.append((x, y + self.chamfer)) - else: - vertices.append(corner) - self._vertices = [((x * self._cos_theta - y * self._sin_theta), - (x * self._sin_theta + y * self._cos_theta)) - for x, y in vertices] - return self._vertices - - @property - def axis_aligned_width(self): - return (self._cos_theta * self.width + - self._sin_theta * self.height) - - @property - def axis_aligned_height(self): - return (self._cos_theta * self.height + - self._sin_theta * self.width) - - -class RoundRectangle(Primitive): - """ - """ - - def __init__(self, position, width, height, radius, corners, **kwargs): - super(RoundRectangle, self).__init__(**kwargs) - validate_coordinates(position) - self._position = position - self._width = width - self._height = height - self._radius = radius - self._corners = corners - self._to_convert = ['position', 'width', 'height', 'radius'] - - @property - def flashed(self): - return True - - @property - def position(self): - return self._position - - @position.setter - def position(self, value): - self._changed() - self._position = value - - @property - def width(self): - return self._width - - @width.setter - def width(self, value): - self._changed() - self._width = value - - @property - def height(self): - return self._height - - @height.setter - def height(self, value): - self._changed() - self._height = value - - @property - def radius(self): - return self._radius - - @radius.setter - def radius(self, value): - self._changed() - self._radius = value - - @property - def corners(self): - return self._corners - - @corners.setter - def corners(self, value): - self._changed() - self._corners = value - - @property - def bounding_box(self): - if self._bounding_box is None: - ll = (self.position[0] - (self.axis_aligned_width / 2.), - self.position[1] - (self.axis_aligned_height / 2.)) - ur = (self.position[0] + (self.axis_aligned_width / 2.), - self.position[1] + (self.axis_aligned_height / 2.)) - self._bounding_box = ((ll[0], ll[1]), (ur[0], ur[1])) - return self._bounding_box - - @property - def axis_aligned_width(self): - return (self._cos_theta * self.width + - self._sin_theta * self.height) - - @property - def axis_aligned_height(self): - return (self._cos_theta * self.height + - self._sin_theta * self.width) - - class Obround(Primitive): def __init__(self, position, width, height, hole_diameter=0, hole_width=0,hole_height=0, **kwargs): @@ -1448,89 +1102,6 @@ class Region(Primitive): for p in self.primitives: p.offset(x_offset, y_offset) -class Donut(Primitive): - """ A Shape with an identical concentric shape removed from its center - """ - - def __init__(self, position, shape, inner_diameter, - outer_diameter, **kwargs): - super(Donut, self).__init__(**kwargs) - validate_coordinates(position) - self.position = position - if shape not in ('round', 'square', 'hexagon', 'octagon'): - raise ValueError( - 'Valid shapes are round, square, hexagon or octagon') - self.shape = shape - if inner_diameter >= outer_diameter: - raise ValueError( - 'Outer diameter must be larger than inner diameter.') - self.inner_diameter = inner_diameter - self.outer_diameter = outer_diameter - if self.shape in ('round', 'square', 'octagon'): - self.width = outer_diameter - self.height = outer_diameter - else: - # Hexagon - self.width = 0.5 * math.sqrt(3.) * outer_diameter - self.height = outer_diameter - - self._to_convert = ['position', 'width', - 'height', 'inner_diameter', 'outer_diameter'] - - # TODO This does not reset bounding box correctly - - @property - def flashed(self): - return True - - @property - def lower_left(self): - return (self.position[0] - (self.width / 2.), - self.position[1] - (self.height / 2.)) - - @property - def upper_right(self): - return (self.position[0] + (self.width / 2.), - self.position[1] + (self.height / 2.)) - - @property - def bounding_box(self): - if self._bounding_box is None: - ll = (self.position[0] - (self.width / 2.), - self.position[1] - (self.height / 2.)) - ur = (self.position[0] + (self.width / 2.), - self.position[1] + (self.height / 2.)) - self._bounding_box = (ll, ur) - return self._bounding_box - - -class SquareRoundDonut(Primitive): - """ A Square with a circular cutout in the center - """ - - def __init__(self, position, inner_diameter, outer_diameter, **kwargs): - super(SquareRoundDonut, self).__init__(**kwargs) - validate_coordinates(position) - self.position = position - if inner_diameter >= outer_diameter: - raise ValueError( - 'Outer diameter must be larger than inner diameter.') - self.inner_diameter = inner_diameter - self.outer_diameter = outer_diameter - self._to_convert = ['position', 'inner_diameter', 'outer_diameter'] - - @property - def flashed(self): - return True - - @property - def bounding_box(self): - if self._bounding_box is None: - ll = tuple([c - self.outer_diameter / 2. for c in self.position]) - ur = tuple([c + self.outer_diameter / 2. for c in self.position]) - self._bounding_box = (ll, ur) - return self._bounding_box - class Drill(Primitive): """ A drill hole -- cgit