summaryrefslogtreecommitdiff
path: root/gerber/tests
diff options
context:
space:
mode:
authorHamilton Kibbe <hamilton.kibbe@gmail.com>2015-08-09 15:11:13 -0400
committerHamilton Kibbe <hamilton.kibbe@gmail.com>2015-08-09 15:11:13 -0400
commitcb2fa34e881a389cf8a4bc98fd12be662ff687f8 (patch)
tree5b4a287ff27a8cfe5a3e93b180b7394c0514b403 /gerber/tests
parentd4a870570855265b9b37f1609dd2bc9f49699bb6 (diff)
downloadgerbonara-cb2fa34e881a389cf8a4bc98fd12be662ff687f8.tar.gz
gerbonara-cb2fa34e881a389cf8a4bc98fd12be662ff687f8.tar.bz2
gerbonara-cb2fa34e881a389cf8a4bc98fd12be662ff687f8.zip
Add support for arcs in regions.
This fixes the circular cutout issue described in #32. Regions were previously stored as a collection of points, now they are stored as a collection of line and arc primitives.
Diffstat (limited to 'gerber/tests')
-rw-r--r--gerber/tests/test_primitives.py34
1 files changed, 14 insertions, 20 deletions
diff --git a/gerber/tests/test_primitives.py b/gerber/tests/test_primitives.py
index 67c7822..f8a32da 100644
--- a/gerber/tests/test_primitives.py
+++ b/gerber/tests/test_primitives.py
@@ -4,6 +4,7 @@
# Author: Hamilton Kibbe <ham@hamiltonkib.be>
from ..primitives import *
from .tests import *
+from operator import add
def test_primitive_smoketest():
@@ -766,38 +767,31 @@ def test_polygon_offset():
def test_region_ctor():
""" Test Region creation
"""
+ apt = Circle((0,0), 0)
+ lines = (Line((0,0), (1,0), apt), Line((1,0), (1,1), apt), Line((1,1), (0,1), apt), Line((0,1), (0,0), apt))
points = ((0, 0), (1,0), (1,1), (0,1))
- r = Region(points)
- for i, point in enumerate(points):
- assert_array_almost_equal(r.points[i], point)
+ r = Region(lines)
+ for i, p in enumerate(lines):
+ assert_equal(r.primitives[i], p)
def test_region_bounds():
""" Test region bounding box calculation
"""
- points = ((0, 0), (1,0), (1,1), (0,1))
- r = Region(points)
+ apt = Circle((0,0), 0)
+ lines = (Line((0,0), (1,0), apt), Line((1,0), (1,1), apt), Line((1,1), (0,1), apt), Line((0,1), (0,0), apt))
+ r = Region(lines)
xbounds, ybounds = r.bounding_box
assert_array_almost_equal(xbounds, (0, 1))
assert_array_almost_equal(ybounds, (0, 1))
-def test_region_conversion():
- points = ((2.54, 25.4), (254.0,2540.0), (25400.0,254000.0), (2.54,25.4))
- r = Region(points, units='metric')
- r.to_inch()
- assert_equal(set(r.points), {(0.1, 1.0), (10.0, 100.0), (1000.0, 10000.0)})
-
- points = ((0.1, 1.0), (10.0, 100.0), (1000.0, 10000.0), (0.1, 1.0))
- r = Region(points, units='inch')
- r.to_metric()
- assert_equal(set(r.points), {(2.54, 25.4), (254.0, 2540.0), (25400.0, 254000.0)})
def test_region_offset():
- points = ((0, 0), (1,0), (1,1), (0,1))
- r = Region(points)
- r.offset(1, 0)
- assert_equal(set(r.points), {(1, 0), (2, 0), (2,1), (1, 1)})
+ apt = Circle((0,0), 0)
+ lines = (Line((0,0), (1,0), apt), Line((1,0), (1,1), apt), Line((1,1), (0,1), apt), Line((0,1), (0,0), apt))
+ r = Region(lines)
+ xlim, ylim = r.bounding_box
r.offset(0, 1)
- assert_equal(set(r.points), {(1, 1), (2, 1), (2,2), (1, 2)})
+ assert_array_almost_equal((xlim, tuple([y+1 for y in ylim])), r.bounding_box)
def test_round_butterfly_ctor():
""" Test round butterfly creation