diff options
author | Garret Fick <garret@ficksworkshop.com> | 2016-01-08 00:19:47 +0800 |
---|---|---|
committer | Garret Fick <garret@ficksworkshop.com> | 2016-01-08 00:19:47 +0800 |
commit | 83ae0670d11b5f5ef8ba3a6c362b7129a9e31ab3 (patch) | |
tree | e52cf8fc36cedb570af80d39aae8a410e8bd42b5 /gerber | |
parent | f61eee807f87c329f6f88645ecdb48f01b887c52 (diff) | |
download | gerbonara-83ae0670d11b5f5ef8ba3a6c362b7129a9e31ab3.tar.gz gerbonara-83ae0670d11b5f5ef8ba3a6c362b7129a9e31ab3.tar.bz2 gerbonara-83ae0670d11b5f5ef8ba3a6c362b7129a9e31ab3.zip |
More stability fixes for poorly constructed files
Diffstat (limited to 'gerber')
-rw-r--r-- | gerber/render/cairo_backend.py | 6 | ||||
-rw-r--r-- | gerber/rs274x.py | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/gerber/render/cairo_backend.py b/gerber/render/cairo_backend.py index 68e9e98..fbc4271 100644 --- a/gerber/render/cairo_backend.py +++ b/gerber/render/cairo_backend.py @@ -76,7 +76,10 @@ class GerberCairoContext(GerberContext): radius = self.scale[0] * arc.radius
angle1 = arc.start_angle
angle2 = arc.end_angle
- width = arc.aperture.diameter if arc.aperture.diameter != 0 else 0.001
+ if isinstance(arc.aperture, Circle):
+ width = arc.aperture.diameter if arc.aperture.diameter != 0 else 0.001
+ else:
+ width = max(arc.aperture.width, arc.aperture.height, 0.001)
self.ctx.set_source_rgba(color[0], color[1], color[2], self.alpha)
self.ctx.set_operator(cairo.OPERATOR_OVER if (arc.level_polarity == "dark" and not self.invert)else cairo.OPERATOR_CLEAR)
self.ctx.set_line_width(width * self.scale[0])
@@ -163,7 +166,6 @@ class GerberCairoContext(GerberContext): self.ctx.line_to(*map(mul, v, self.scale))
self.ctx.fill()
-
def _render_drill(self, circle, color):
self._render_circle(circle, color)
diff --git a/gerber/rs274x.py b/gerber/rs274x.py index 2ecc57d..12400a1 100644 --- a/gerber/rs274x.py +++ b/gerber/rs274x.py @@ -80,8 +80,10 @@ class GerberFile(CamFile): `bounds` is stored as ((min x, max x), (min y, max y)) """ - def __init__(self, statements, settings, primitives, filename=None): + def __init__(self, statements, settings, primitives, apertures, filename=None): super(GerberFile, self).__init__(statements, settings, primitives, filename) + + self.apertures = apertures @property def comments(self): @@ -227,7 +229,7 @@ class GerberParser(object): for stmt in self.statements: stmt.units = self.settings.units - return GerberFile(self.statements, self.settings, self.primitives, filename) + return GerberFile(self.statements, self.settings, self.primitives, self.apertures.values(), filename) def dump_json(self): stmts = {"statements": [stmt.__dict__ for stmt in self.statements]} |