diff options
author | jaseg <git@jaseg.de> | 2023-04-26 23:37:38 +0200 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2023-04-26 23:37:38 +0200 |
commit | 958b47ab471053798ff55194c4aff4cf52f7602a (patch) | |
tree | c072350ff0a7a3db367fe9a236bd327761bd4141 /gerbonara/graphic_objects.py | |
parent | 38f766dc42e3bec72236cc34c6b74fc4dab37c4e (diff) | |
download | gerbonara-958b47ab471053798ff55194c4aff4cf52f7602a.tar.gz gerbonara-958b47ab471053798ff55194c4aff4cf52f7602a.tar.bz2 gerbonara-958b47ab471053798ff55194c4aff4cf52f7602a.zip |
Speed up protoboard generation
Diffstat (limited to 'gerbonara/graphic_objects.py')
-rw-r--r-- | gerbonara/graphic_objects.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/gerbonara/graphic_objects.py b/gerbonara/graphic_objects.py index 432a988..bc205db 100644 --- a/gerbonara/graphic_objects.py +++ b/gerbonara/graphic_objects.py @@ -21,7 +21,7 @@ import copy from dataclasses import dataclass, astuple, field, fields from itertools import zip_longest -from .utils import MM, InterpMode, to_unit, rotate_point +from .utils import MM, InterpMode, to_unit, rotate_point, sum_bounds from . import graphic_primitives as gp from .aperture_macros import primitive as amp @@ -152,12 +152,7 @@ class GraphicObject: :returns: tuple of tuples of floats: ``(min_x, min_y), (max_x, max_y)`` """ - bboxes = [ p.bounding_box() for p in self.to_primitives(unit) ] - min_x = min(min_x for (min_x, _min_y), _ in bboxes) - min_y = min(min_y for (_min_x, min_y), _ in bboxes) - max_x = max(max_x for _, (max_x, _max_y) in bboxes) - max_y = max(max_y for _, (_max_x, max_y) in bboxes) - return ((min_x, min_y), (max_x, max_y)) + return sum_bounds(p.bounding_box() for p in self.to_primitives(unit)) def to_primitives(self, unit=None): """ Render this object into low-level graphical primitives (subclasses of :py:class:`.GraphicPrimitive`). This @@ -219,6 +214,10 @@ class Flash(GraphicObject): def tool(self, value): self.aperture = value + def bounding_box(self, unit=None): + (min_x, min_y), (max_x, max_y) = self.aperture.bounding_box(unit) + return (min_x+self.x, min_y+self.y), (max_x+self.x, max_x+self.y) + @property def plated(self): """ (Excellon only) Returns if this is a plated hole. ``True`` (plated), ``False`` (non-plated) or ``None`` |