summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2023-07-03 22:59:47 +0200
committerjaseg <git@jaseg.de>2023-07-03 22:59:47 +0200
commit34fae0a7c2cf894117eee0b25e32726a492d25a8 (patch)
treede458b3f81ae11f315cd919d5cafe4fb5e73ca9f
parent2eb88e812792c7819196662fe3535ce21c1e4e88 (diff)
downloadgerbonara-34fae0a7c2cf894117eee0b25e32726a492d25a8.tar.gz
gerbonara-34fae0a7c2cf894117eee0b25e32726a492d25a8.tar.bz2
gerbonara-34fae0a7c2cf894117eee0b25e32726a492d25a8.zip
Fix handling of circles on outline layer
-rw-r--r--gerbonara/graphic_primitives.py4
-rw-r--r--gerbonara/layers.py6
2 files changed, 10 insertions, 0 deletions
diff --git a/gerbonara/graphic_primitives.py b/gerbonara/graphic_primitives.py
index 7f0ddfa..ea8fd9f 100644
--- a/gerbonara/graphic_primitives.py
+++ b/gerbonara/graphic_primitives.py
@@ -212,6 +212,10 @@ class Arc(GraphicPrimitive):
#: Line width of this arc.
width : float
+ @property
+ def is_circle(self):
+ return math.isclose(self.x1, self.x2) and math.isclose(self.y1, self.y2)
+
def flip(self):
return replace(self, x1=self.x2, y1=self.y2, x2=self.x1, y2=self.y1,
cx=(self.x1 + self.cx) - self.x2, cy=(self.y1 + self.cy) - self.y2, clockwise=not self.clockwise)
diff --git a/gerbonara/layers.py b/gerbonara/layers.py
index e8ce1a3..daed004 100644
--- a/gerbonara/layers.py
+++ b/gerbonara/layers.py
@@ -1140,6 +1140,12 @@ class LayerStack:
joins = {}
for cur in lines:
+ # Special case: An arc may describe a complete circle, in which case we have to return it as-is since it
+ # is the only primitive that can join itself.
+ if isinstance(cur, gp.Arc) and cur.is_circle:
+ yield [cur]
+ continue
+
for (i, x, y) in [(0, cur.x1, cur.y1), (1, cur.x2, cur.y2)]:
x_left = bisect.bisect_left (by_x, x, key=lambda elem: elem[0] + tol)
x_right = bisect.bisect_right(by_x, x, key=lambda elem: elem[0] - tol)