Пример #1
0
def getverticesGdsii(name, markerlayer=[]):

    global GDS

    GDS = pg.import_gds(filename=name)

    if len(GDS.layers) > 1:
        print('Multiple layers. Type layer and confirm with enter \n')
        for layer in GDS.layers:
            print('#' + str(layer))
        markerlayer = [int(input())]
    else:
        for thelayer in GDS.layers:
            markerlayer = [thelayer]

    GDS.flatten()

    GDSLayered = pg.extract(GDS, layers=markerlayer)
    vertices = []
    for polygon in GDSLayered:
        #print(polygon)
        for vertex in polygon.polygons[0]:
            vertices.append(vertex)
            #print(vertex)
    return np.array(vertices).tolist()
Пример #2
0
def read_port_markers(gdspath, layers=[(69, 0)]):
    """loads a GDS and returns the extracted device for a particular layer

    Args:
        gdspath: gdspath or Component
        layer: GDS layer
    """
    D = gdspath if isinstance(gdspath, Device) else pg.import_gds(gdspath)
    return pg.extract(D, layers=layers)
Пример #3
0
def read_port_markers(
    component: object, layers: Tuple[Tuple[int, int], ...] = ((1, 10), )
) -> Device:
    """Loads a GDS and returns the extracted ports from layer markers

    Args:
        component: or Component
        layers: Iterable of GDS layers
    """
    return pg.extract(component, layers=layers)
Пример #4
0
def read_port_markers(gdspath, layer=69):
    """ loads a GDS and read port

    Args:
        gdspath:
        layer: GDS layer
    """
    D = pg.import_gds(gdspath)
    D = pg.extract(D, layers=[layer])
    for e in D.elements:
        print(e.x, e.y)
# Say you want to grab all the polygons of a single layer from your Device. You
# can do this using the pg.extract() function, which will create a new Device
# with all of the polygons from D.  Note that the Device created from this
# function is necessarily flattened (otherwise it could inadvertantly modify
# other Devices which share references with the extracted Device)

D = Device()
E1 = pg.ellipse(layer=1)
E2 = pg.rectangle(layer=2)
E3 = pg.arc(layer=3)
D.add_ref(E1)
D.add_ref(E2).movex(15)
D.add_ref(E3).movex(30)
qp(D)

D_only_layers_1_and_2 = pg.extract(D, layers=[1, 2])
qp(D_only_layers_1_and_2)

#==============================================================================
# Making boolean shapes
#==============================================================================
# If you want to subtract one shape from another, merge two shapes, or
# perform an XOR on them, you can do that with the pg.boolean() function.
# the ``operation`` argument should be {not, and, or, xor, 'A-B', 'B-A', 'A+B'}.
# Note that 'A+B' is equivalent to 'or', 'A-B' is equivalent to 'not', and
#  'B-A' is equivalent to 'not' with the operands switched

D = Device()
E1 = pg.ellipse()
E2 = pg.ellipse().movex(15)
E3 = pg.ellipse().movex(30)
Пример #6
0
        offset_per_notch = 0.1,
        row_spacing = 0,
        layer1 = 1,
        layer2 = 2)
qp(D) # quickplot the geometry
create_image(D, 'litho_calipers')

# example-extract
import phidl.geometry as pg
from phidl import quickplot as qp
from phidl import Device

E = Device()
E.add_ref(pg.ellipse(layer = {0,1}))
#X = pg.ellipse(layer = {0,1})
D = pg.extract(E, layers = [0,1])
qp(D) # quickplot the geometry
create_image(D, 'extract')

# example-copy
import phidl.geometry as pg
from phidl import quickplot as qp

X = pg.ellipse()
D = pg.copy(X)
qp(D) # quickplot the geometry
create_image(D, 'copy')

# example-deepcopy
import phidl.geometry as pg
from phidl import quickplot as qp