Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GDSII layers #817

Merged
merged 3 commits into from
Apr 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,16 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <ctlgeom.h>]], [ctl_printf_callbac
##############################################################################
# check for libGDSII
AC_CHECK_HEADER(libGDSII.h, [have_gdsii=maybe], [have_gdsii=no])
if test $have_gdsii = maybe; then
if test "x$have_gdsii" = xmaybe; then
AC_CHECK_LIB(GDSII, libGDSIIExists)
if test "x$ac_cv_lib_GDSII_libGDSIIExists" = xyes; then
AC_MSG_CHECKING([for libGDSII::GetLayers])
have_gdsii_getlayers=no
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <libGDSII.h>]], [libGDSII::GetLayers("foo")])],
[have_gdsii_getlayers=yes
AC_DEFINE([HAVE_GDSII_GETLAYERS], [1], [If we have libGDSII::GetLayers])])
AC_MSG_RESULT($have_gdsii_getlayers)
fi
fi

##############################################################################
Expand Down
10 changes: 10 additions & 0 deletions doc/docs/Python_User_Interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -1485,6 +1485,16 @@ After `solve_cw` completes, it should be as if you had just run the simulation f

This feature is only available if Meep is built with [libGDSII](Build_From_Source.md#libgdsii).

**`mp.GDSII_layers(gdsii_filename)`**

Returns a list of integer-valued layer indices for the layers present in
the specified GDSII file.

```python
mp.GDSII_layers('python/examples/coupler.gds')
Out[2]: [0, 1, 2, 3, 4, 5, 31, 32]
```

**`mp.get_GDSII_prisms(material, gdsii_filename, layer)`**
Returns a list of `GeometricObject`s with `material` (`mp.Medium`) on layer number `layer` of a GDSII file `gdsii_filename`.
Expand Down
1 change: 1 addition & 0 deletions python/meep.i
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,7 @@ PyObject *_get_array_slice_dimensions(meep::fields *f, const meep::volume &where
dft_ldos,
display_progress,
during_sources,
GDSII_layers,
GDSII_vol,
get_center_and_size,
get_eigenmode_freqs,
Expand Down
2 changes: 2 additions & 0 deletions python/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2763,6 +2763,8 @@ def get_center_and_size(v):
size = v3rmax - v3rmin
return center, size

def GDSII_layers(fname):
return list(mp.get_GDSII_layers(fname))

def GDSII_vol(fname, layer, zmin, zmax):
meep_vol = mp.get_GDSII_volume(fname, layer, zmin, zmax)
Expand Down
11 changes: 11 additions & 0 deletions src/GDSIIgeom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,15 @@ meep::volume get_GDSII_volume(const char *GDSIIFile, int Layer, double zmin, dou

#endif // HAVE_LIBGDSII

std::vector<int> get_GDSII_layers(const char *GDSIIFile)
{
#if defined(HAVE_LIBGDSII) && defined(HAVE_GDSII_GETLAYERS)
return libGDSII::GetLayers(GDSIIFile);
#else
GDSIIError("get_GDSII_layers (needs libGDSII version 0.21 or later)");
std::vector<int> layers;
return layers;
#endif
}

} // namespace meep_geom
1 change: 1 addition & 0 deletions src/meepgeom.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ meep::volume get_GDSII_volume(const char *GDSIIFile, const char *Text, int Layer
double zmin = 0.0, double zmax = 0.0);
meep::volume get_GDSII_volume(const char *GDSIIFile, int Layer, double zmin = 0.0,
double zmax = 0.0);
std::vector<int> get_GDSII_layers(const char *GDSIIFile);

}; // namespace meep_geom

Expand Down