A Modified gdsimport() that Uniquely Names Each Imported Polygon in the Imported Layer

Hello,

I’m of the mind that if I’ve drawn a certain structure in one software, I would rather not learn how to draw it again in other software. It’s for that reason I find the gdsimport() command in Lumerical valuable. However, I have found there are some limiting cases with the GDS import that prevent full usefulness; namely, if your application involves importing a layer that contains multiple polygons, you desire the manipulate each individual polygon separately from the others, and you want your simulation setup to be fully scripted.

The issue arises from the fact that every imported polygon in the specified layer is placed into a common structure group with the same name, “poly”. To select an individual polygon, each would need a unique name – which could be achieved by appending ascending numbers to each imported polygon (i.e., “poly0”, “poly1”, etc.). Since the idea to extend this capability to the standard gdsimport() command seems to have failed on the Idea Exchange, I wanted to share a method I’ve devised to achieve the desired outcome.

I pre-process my GDS files in MATLAB using the (free) GDS-II Toolbox to take all the polygons in a specified layer and place them in their own unique layer. Right now, the new layer number of the polygon becomes a concatenation of the original layer number and data type (not a perfect hashing method), and the new data type is the i-th instance of a polygon in that layer. You can acquire the GDS-II Toolbox at either of the following locations:

https://sites.google.com/site/ulfgri/numerical/gdsii-toolbox

Here is the MATLAB code I’ve written using that toolbox to separate the polygons into different layers:
DEVICE_PolygonReplace.m (1.5 KB)
FindLayerInstances.m (804 Bytes)
PolygonsInLayer_Separator.m (846 Bytes) (Main function user interacts with)

Those functions will transform the first attached GDS into the second:
Test_Processed_v2.gds (344 Bytes)
Test_Processed_v2_PolygonSplit.gds (536 Bytes)

Now that the GDS is pre-processed, we can write a user-defined function that imports each unique layer individually, names each polygon uniquely, then stores them in a common structure group with the same features as the standard structure group from the gdsimport() command. You’ll find such a function below. Be aware that this version was written specifically for DEVICE, so the object tree path isn’t identical to what’s needed in the other solvers at the moment:
gdsImport_UniquePolygons.lsf (2.4 KB)

Here’s an example script calling both the standard and modified GDS import functions:
GDS_Import_Compare.lsf (271 Bytes)

And voila:
UniqueImport_ObjectTree

Cheers,
Andy

2 Likes

Thank you, @anetherton for sharing this with our community.