summaryrefslogtreecommitdiff
path: root/gerber
diff options
context:
space:
mode:
Diffstat (limited to 'gerber')
-rw-r--r--gerber/am_statements.py5
-rw-r--r--gerber/primitives.py18
-rw-r--r--gerber/render/rs274x_backend.py7
3 files changed, 29 insertions, 1 deletions
diff --git a/gerber/am_statements.py b/gerber/am_statements.py
index 084439c..faaed05 100644
--- a/gerber/am_statements.py
+++ b/gerber/am_statements.py
@@ -461,6 +461,11 @@ class AMPolygonPrimitive(AMPrimitive):
------
ValueError, TypeError
"""
+
+ @classmethod
+ def from_primitive(cls, primitive):
+ return cls(5, 'on', primitive.sides, primitive.position, primitive.diameter, primitive.rotation)
+
@classmethod
def from_gerber(cls, primitive):
modifiers = primitive.strip(' *').split(",")
diff --git a/gerber/primitives.py b/gerber/primitives.py
index 3c85f17..08aa634 100644
--- a/gerber/primitives.py
+++ b/gerber/primitives.py
@@ -736,6 +736,10 @@ class Polygon(Primitive):
@property
def flashed(self):
return True
+
+ @property
+ def diameter(self):
+ return self.radius * 2
@property
def bounding_box(self):
@@ -759,6 +763,20 @@ class Polygon(Primitive):
points.append(rotate_point((self.position[0] + self.radius, self.position[1]), offset + da * i, self.position))
return points
+
+ def equivalent(self, other, offset):
+ '''
+ Is this the outline the same as the other, ignoring the position offset?
+ '''
+
+ # Quick check if it even makes sense to compare them
+ if type(self) != type(other) or self.sides != other.sides or self.radius != other.radius:
+ return False
+
+ equiv_pos = tuple(map(add, other.position, offset))
+
+ return nearly_equal(self.position, equiv_pos)
+
class AMGroup(Primitive):
"""
diff --git a/gerber/render/rs274x_backend.py b/gerber/render/rs274x_backend.py
index d4456e2..04ecbe6 100644
--- a/gerber/render/rs274x_backend.py
+++ b/gerber/render/rs274x_backend.py
@@ -2,7 +2,7 @@
from .render import GerberContext
from ..am_statements import *
from ..gerber_statements import *
-from ..primitives import AMGroup, Arc, Circle, Line, Outline, Rectangle
+from ..primitives import AMGroup, Arc, Circle, Line, Outline, Polygon, Rectangle
from copy import deepcopy
class AMGroupContext(object):
@@ -28,6 +28,8 @@ class AMGroupContext(object):
self._render_rectangle(primitive)
elif isinstance(primitive, Line):
self._render_line(primitive)
+ elif isinstance(primitive, Polygon):
+ self._render_polygon(primitive)
else:
raise ValueError('amgroup')
@@ -53,6 +55,9 @@ class AMGroupContext(object):
def _render_outline(self, outline):
self.statements.append(AMOutlinePrimitive.from_primitive(outline))
+
+ def _render_polygon(self, polygon):
+ self.statements.append(AMPolygonPrimitive.from_primitive(polygon))
def _render_thermal(self, thermal):
pass