From 20a9af279ac2217a39b73903ff94b916a3025be2 Mon Sep 17 00:00:00 2001 From: Garret Fick Date: Tue, 1 Mar 2016 00:06:14 +0800 Subject: More rendering of AMGroup to statements --- gerber/primitives.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'gerber/primitives.py') diff --git a/gerber/primitives.py b/gerber/primitives.py index 07a28db..3c85f17 100644 --- a/gerber/primitives.py +++ b/gerber/primitives.py @@ -397,6 +397,19 @@ class Circle(Primitive): def offset(self, x_offset=0, y_offset=0): self.position = tuple(map(add, self.position, (x_offset, y_offset))) + + def equivalent(self, other, offset): + '''Is this the same as the other circle, ignoring the offiset?''' + + if not isinstance(other, Circle): + return False + + if self.diameter != other.diameter: + return False + + equiv_position = tuple(map(add, other.position, offset)) + + return nearly_equal(self.position, equiv_position) class Ellipse(Primitive): @@ -487,6 +500,19 @@ class Rectangle(Primitive): return (math.cos(math.radians(self.rotation)) * self.height + math.sin(math.radians(self.rotation)) * self.width) + def equivalent(self, other, offset): + '''Is this the same as the other rect, ignoring the offiset?''' + + if not isinstance(other, Rectangle): + return False + + if self.width != other.width or self.height != other.height or self.rotation != other.rotation: + return False + + equiv_position = tuple(map(add, other.position, offset)) + + return nearly_equal(self.position, equiv_position) + class Diamond(Primitive): """ @@ -815,6 +841,9 @@ class Outline(Primitive): self.primitives = primitives self._to_convert = ['primitives'] + if self.primitives[0].start != self.primitives[-1].end: + raise ValueError('Outline must be closed') + @property def flashed(self): return True @@ -833,6 +862,9 @@ class Outline(Primitive): def offset(self, x_offset=0, y_offset=0): for p in self.primitives: p.offset(x_offset, y_offset) + + if self.primitives[0].start != self.primitives[-1].end: + raise ValueError('Outline must be closed') @property def width(self): -- cgit