diff options
author | Hamilton Kibbe <hamilton.kibbe@gmail.com> | 2015-08-09 15:11:13 -0400 |
---|---|---|
committer | Hamilton Kibbe <hamilton.kibbe@gmail.com> | 2015-08-09 15:11:13 -0400 |
commit | cb2fa34e881a389cf8a4bc98fd12be662ff687f8 (patch) | |
tree | 5b4a287ff27a8cfe5a3e93b180b7394c0514b403 /gerber/rs274x.py | |
parent | d4a870570855265b9b37f1609dd2bc9f49699bb6 (diff) | |
download | gerbonara-cb2fa34e881a389cf8a4bc98fd12be662ff687f8.tar.gz gerbonara-cb2fa34e881a389cf8a4bc98fd12be662ff687f8.tar.bz2 gerbonara-cb2fa34e881a389cf8a4bc98fd12be662ff687f8.zip |
Add support for arcs in regions.
This fixes the circular cutout issue described in #32. Regions were previously stored as a collection of points, now they are stored as a collection of line and arc primitives.
Diffstat (limited to 'gerber/rs274x.py')
-rw-r--r-- | gerber/rs274x.py | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/gerber/rs274x.py b/gerber/rs274x.py index b4963d1..1df3646 100644 --- a/gerber/rs274x.py +++ b/gerber/rs274x.py @@ -468,22 +468,29 @@ class GerberParser(object): stmt.op = self.op if self.op == "D01": - if self.region_mode == 'on': - if self.current_region is None: - self.current_region = [(self.x, self.y), ] - self.current_region.append((x, y,)) - else: - start = (self.x, self.y) - end = (x, y) + start = (self.x, self.y) + end = (x, y) - if self.interpolation == 'linear': + if self.interpolation == 'linear': + if self.region_mode == 'off': self.primitives.append(Line(start, end, self.apertures[self.aperture], level_polarity=self.level_polarity, units=self.settings.units)) else: - i = 0 if stmt.i is None else stmt.i - j = 0 if stmt.j is None else stmt.j - center = (start[0] + i, start[1] + j) + if self.current_region is None: + self.current_region = [Line(start, end, self.apertures[self.aperture], level_polarity=self.level_polarity, units=self.settings.units),] + else: + self.current_region.append(Line(start, end, self.apertures[self.aperture], level_polarity=self.level_polarity, units=self.settings.units)) + else: + i = 0 if stmt.i is None else stmt.i + j = 0 if stmt.j is None else stmt.j + center = (start[0] + i, start[1] + j) + if self.region_mode == 'off': self.primitives.append(Arc(start, end, center, self.direction, self.apertures[self.aperture], level_polarity=self.level_polarity, units=self.settings.units)) - + else: + if self.current_region is None: + self.current_region = [Arc(start, end, center, self.direction, self.apertures[self.aperture], level_polarity=self.level_polarity, units=self.settings.units),] + else: + self.current_region.append(Arc(start, end, center, self.direction, self.apertures[self.aperture], level_polarity=self.level_polarity, units=self.settings.units)) + elif self.op == "D02": pass |