summaryrefslogtreecommitdiff
path: root/gerber
diff options
context:
space:
mode:
authorGarret Fick <garret@ficksworkshop.com>2016-02-21 10:23:03 +0800
committerGarret Fick <garret@ficksworkshop.com>2016-02-21 10:23:03 +0800
commit02dbc6a51e2ef417f2bd41d6159ba53cc736535d (patch)
treeafd2addc896f3ea40ec8551ffd883390485531cc /gerber
parent4bc7a6345b16bfeaa969f533a1da97cbf9e44e4c (diff)
downloadgerbonara-02dbc6a51e2ef417f2bd41d6159ba53cc736535d.tar.gz
gerbonara-02dbc6a51e2ef417f2bd41d6159ba53cc736535d.tar.bz2
gerbonara-02dbc6a51e2ef417f2bd41d6159ba53cc736535d.zip
Additional bounding box calcuation that considers only actual positions, not the movement of the machine
Diffstat (limited to 'gerber')
-rw-r--r--gerber/rs274x.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/gerber/rs274x.py b/gerber/rs274x.py
index 92f4c4b..4ab5472 100644
--- a/gerber/rs274x.py
+++ b/gerber/rs274x.py
@@ -110,6 +110,21 @@ class GerberFile(CamFile):
max_y = max(stmt.y, max_y)
return ((min_x, max_x), (min_y, max_y))
+
+ @property
+ def bounding_box(self):
+ min_x = min_y = 1000000
+ max_x = max_y = -1000000
+
+ for prim in self.primitives:
+ bounds = prim.bounding_box
+ min_x = min(bounds[0][0], min_x)
+ max_x = max(bounds[0][1], max_x)
+
+ min_y = min(bounds[1][0], min_y)
+ max_y = max(bounds[1][1], max_y)
+
+ return ((min_x, max_x), (min_y, max_y))
def write(self, filename, settings=None):
""" Write data out to a gerber file