summaryrefslogtreecommitdiff
path: root/gerbonara/cad/primitives.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2023-04-26 23:37:38 +0200
committerjaseg <git@jaseg.de>2023-04-26 23:37:38 +0200
commit958b47ab471053798ff55194c4aff4cf52f7602a (patch)
treec072350ff0a7a3db367fe9a236bd327761bd4141 /gerbonara/cad/primitives.py
parent38f766dc42e3bec72236cc34c6b74fc4dab37c4e (diff)
downloadgerbonara-958b47ab471053798ff55194c4aff4cf52f7602a.tar.gz
gerbonara-958b47ab471053798ff55194c4aff4cf52f7602a.tar.bz2
gerbonara-958b47ab471053798ff55194c4aff4cf52f7602a.zip
Speed up protoboard generation
Diffstat (limited to 'gerbonara/cad/primitives.py')
-rw-r--r--gerbonara/cad/primitives.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/gerbonara/cad/primitives.py b/gerbonara/cad/primitives.py
index 80373c6..ce69bae 100644
--- a/gerbonara/cad/primitives.py
+++ b/gerbonara/cad/primitives.py
@@ -7,7 +7,7 @@ from itertools import zip_longest, chain
from dataclasses import dataclass, field, KW_ONLY
from collections import defaultdict
-from ..utils import LengthUnit, MM, rotate_point, svg_arc, sum_bounds, bbox_intersect, Tag
+from ..utils import LengthUnit, MM, rotate_point, svg_arc, sum_bounds, bbox_intersect, Tag, offset_bounds
from ..layers import LayerStack
from ..graphic_objects import Line, Arc, Flash
from ..apertures import Aperture, CircleAperture, ObroundAperture, RectangleAperture, ExcellonTool
@@ -215,6 +215,24 @@ class ObjectGroup(Positioned):
fe.offset(x, y, self.unit)
target.objects.append(fe)
+ def bounding_box(self, unit=MM):
+ if math.isclose(self.rotation, 0, abs_tol=1e-3):
+ return offset_bounds(sum_bounds((obj.bounding_box(unit=unit) for obj in chain(
+ self.top_copper,
+ self.top_mask,
+ self.top_silk,
+ self.top_paste,
+ self.bottom_copper,
+ self.bottom_mask,
+ self.bottom_silk,
+ self.bottom_paste,
+ self.drill_npth,
+ self.drill_pth,
+ self.objects,
+ ))), unit(self.x, self.unit), unit(self.y, self.unit))
+ else:
+ return super().bounding_box(unit)
+
@property
def single_sided(self):
any_top = self.top_copper or self.top_mask or self.top_paste or self.top_silk