Skip to content

Commit 4dcfd14

Browse files
authored
Merge pull request #583 from gdsfactory/remove-gdstk-dependency
removing gdstk dependencies anywhere other than the tidy3d module
2 parents 73da7c6 + ba0764b commit 4dcfd14

5 files changed

Lines changed: 27 additions & 144 deletions

File tree

gplugins/common/utils/get_component_with_local_layers.py

Lines changed: 0 additions & 128 deletions
This file was deleted.

gplugins/gfviz/netlist.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from functools import lru_cache
22

33
import gdsfactory as gf
4-
import gdstk
54
import numpy as np
65
import shapely.geometry as sg
6+
import shapely.ops as so
77
from natsort import natsorted
88

99

@@ -225,10 +225,12 @@ def get_icon_poly(name):
225225
polys = min(polys_priority.items(), key=lambda x: x[0])[1]
226226
if not polys:
227227
return default
228-
polys = gdstk.boolean(polys, [], operation="or")
228+
polys = [sg.Polygon(p) for p in polys]
229+
polys = so.unary_union(polys)
230+
polys = _extract_vertices(polys)
229231
if not polys:
230232
return default
231-
poly = rdp(polys[0].points)
233+
poly = rdp(polys[0])
232234
if (poly.shape[0] < 3) or (poly.shape[0] > 100):
233235
return default
234236
poly = (poly - c.bbox_np()[0:1]) / (c.bbox_np()[1:2] - c.bbox_np()[0:1])
@@ -242,6 +244,14 @@ def get_icon_poly(name):
242244
return poly
243245

244246

247+
def _extract_vertices(geometry):
248+
if geometry.geom_type == 'Polygon':
249+
return [list(geometry.exterior.coords)]
250+
elif geometry.geom_type == 'MultiPolygon':
251+
return [list(p.exterior.coords) for p in geometry.geoms]
252+
else:
253+
raise TypeError(f"Unhandled geometry type: {geometry.geom_type}")
254+
245255
def rdp(poly, eps=0.1):
246256
poly = np.asarray(poly)
247257
if not poly.shape:

gplugins/gmeep/write_sparameters_meep_mpi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def write_sparameters_meep_mpi(
164164
with open(parameters_file, "wb") as outp:
165165
pickle.dump(settings, outp, pickle.HIGHEST_PROTOCOL)
166166

167-
# Save component to disk through gds for gdstk compatibility
167+
# Save component to disk through gds
168168
component_file = tempfile.with_suffix(".gds")
169169
component.write_gds(component_file, with_metadata=True)
170170

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ classifiers = [
1515
dependencies = [
1616
"gdsfactory>=9.3.5",
1717
"pint",
18-
"gdstk",
1918
"tqdm",
2019
"numpy",
2120
"xarray==2025.1.2"
@@ -71,7 +70,7 @@ sax = [
7170
"ray"
7271
]
7372
schematic = ["bokeh", "ipywidgets", "natsort"]
74-
tidy3d = ["tidy3d>=2.8.2,<2.9", "meshio", "numpy", "meshwell~=1.0.7"]
73+
tidy3d = ["tidy3d>=2.8.2,<2.9", "meshio", "numpy", "meshwell~=1.0.7", "gdstk"]
7574
vlsir = ["vlsir", "vlsirtools"]
7675

7776
[tool.codespell]

uv.lock

Lines changed: 12 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)