Cleaned out the tests folder. Added simple test gerber. Added simple unit test using the GUI.

This commit is contained in:
Juan Pablo Caram
2015-10-27 21:27:27 -04:00
parent 45c7f8efab
commit 95f51b2870
11 changed files with 96 additions and 20 deletions

47
tests/other/test_plotg.py Normal file
View File

@@ -0,0 +1,47 @@
from shapely.geometry import LineString, Polygon
from shapely.ops import cascaded_union, unary_union
from matplotlib.pyplot import plot, subplot, show
from camlib import *
def plotg2(geo, solid_poly=False, color="black", linestyle='solid'):
try:
for sub_geo in geo:
plotg2(sub_geo, solid_poly=solid_poly, color=color, linestyle=linestyle)
except TypeError:
if type(geo) == Polygon:
if solid_poly:
patch = PolygonPatch(geo,
#facecolor="#BBF268",
facecolor=color,
edgecolor="#006E20",
alpha=0.5,
zorder=2)
ax = subplot(111)
ax.add_patch(patch)
else:
x, y = geo.exterior.coords.xy
plot(x, y, color=color, linestyle=linestyle)
for ints in geo.interiors:
x, y = ints.coords.xy
plot(x, y, color=color, linestyle=linestyle)
if type(geo) == LineString or type(geo) == LinearRing:
x, y = geo.coords.xy
plot(x, y, color=color, linestyle=linestyle)
if type(geo) == Point:
x, y = geo.coords.xy
plot(x, y, 'o')
if __name__ == "__main__":
p = Polygon([[0, 0], [0, 5], [5, 5], [5, 0]])
paths = [
LineString([[0.5, 2], [2, 4.5]]),
LineString([[2, 0.5], [4.5, 2]])
]
plotg2(p, solid_poly=True)
plotg2(paths, linestyle="dashed")
show()