From 958b47ab471053798ff55194c4aff4cf52f7602a Mon Sep 17 00:00:00 2001 From: jaseg Date: Wed, 26 Apr 2023 23:37:38 +0200 Subject: Speed up protoboard generation --- gerbonara/cad/primitives.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'gerbonara/cad/primitives.py') 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 -- cgit