Skip to content

Commit

Permalink
GDSII layers (NanoComp#817)
Browse files Browse the repository at this point in the history
* updates

* add configure check for libGDSII::GetLayers

* better error message
  • Loading branch information
HomerReid authored and stevengj committed Apr 19, 2019
1 parent 31874c1 commit c114308
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 1 deletion.
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 @@ -1489,6 +1489,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 @@ -2762,6 +2762,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

0 comments on commit c114308

Please sign in to comment.