-
Notifications
You must be signed in to change notification settings - Fork 0
/
boolean_test.py
38 lines (31 loc) · 1.17 KB
/
boolean_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import numpy as np
import gdspy
from gdsCAD import *
from matplotlib.font_manager import FontProperties
from matplotlib.textpath import TextPath
import fonts
from fonts import *
a=core.Boundary([[(0.0,0.0),(1.0,0.0),(1.0,1.0),(0.0,1.0)],[(0.0,0.0),(0.5,0.0),(0.5,0.5),(0.0,0.5)]], layer=1)
b=gdspy.PolygonSet([[(0.0,0.0),(2.0,0.0),(2.0,2.0),(0.0,2.0)],[(0.0,0.0),(3.0,0.0),(3.0,3.0),(0.0,3.0)]], layer=1)
c=gdspy.PolygonSet(a.points, layer=1)
d=core.Boundary(b.polygons, layer=1)
def cadply(ply, ly):
return gdspy.Polygon([list(i) for i in ply], layer=ly)
#end
def pypol2bdy(plst, ly):
return core.Boundary(plst.polygons, layer=ly)
#end
e=gdspy.boolean(cadply(c.polygons[0],1), cadply(c.polygons[1],1), 'not')
# print(map(tuple, e.polygons[0]))
f=gdspy.boolean(gdspy.Polygon(b.polygons[1]), gdspy.Polygon(b.polygons[0]), 'not')
cl_cad = core.Cell('gdsCAD')
ly_cad = core.Layout('gdsCAD')
cl_cad.add(core.Boundary(map(tuple, e.polygons[0]), layer=1))
# cl_cad.add(d)
ly_cad.add(cl_cad)
ly_cad.save('boolean_test_gdsCAD.gds')
cl_py= gdspy.Cell('gdspy')
# cl_py.add(b)
cl_py.add(f)
cl_py.add(e)
gdspy.write_gds('boolean_test_gdspy.gds',cells=[cl_py])