def outline(elements, **kwargs) -> Component: """ Returns Component containing the outlined polygon(s). wraps phidl.geometry.outline Creates an outline around all the polygons passed in the `elements` argument. `elements` may be a Device, Polygon, or list of Devices. Args: elements: Device(/Reference), list of Device(/Reference), or Polygon Polygons to outline or Device containing polygons to outline. Keyword Args: distance: int or float Distance to offset polygons. Positive values expand, negative shrink. precision: float Desired precision for rounding vertex coordinates. num_divisions: array-like[2] of int The number of divisions with which the geometry is divided into multiple rectangular regions. This allows for each region to be processed sequentially, which is more computationally efficient. join: {'miter', 'bevel', 'round'} Type of join used to create the offset polygon. tolerance: int or float For miter joints, this number must be at least 2 and it represents the maximal distance in multiples of offset between new vertices and their original position before beveling to avoid spikes at acute joints. For round joints, it indicates the curvature resolution in number of points per full circle. join_first: bool Join all paths before offsetting to avoid unnecessary joins in adjacent polygon sides. max_points: int The maximum number of vertices within the resulting polygon. open_ports: bool or float If not False, holes will be cut in the outline such that the Ports are not covered. If True, the holes will have the same width as the Ports. If a float, the holes will be be widened by that value (useful for fully clearing the outline around the Ports for positive-tone processes layer: int, array-like[2], or set Specific layer(s) to put polygon geometry on.) """ return gf.read.from_phidl(component=pg.outline(elements, **kwargs))
E2 = pg.ellipse().movex(15) E3 = pg.ellipse().movex(30) qp([E1, E2, E3]) D2 = pg.boolean(A=[E1, E3], B=E2, operation='A-B') qp(D2) #============================================================================== # Creating outlines of shapes #============================================================================== # Sometimes, when writing in a positive-tone resist, it is useful to produce # an outline of an existing shape. The pg.outline() function allows you to do # exactly that D = pg.ellipse(layer=1) D2 = pg.outline(D, distance=1, layer=2) qp([D, D2]) #============================================================================== # Joining (Unioning) shapes together #============================================================================== # If you have several polygons which form a single compound shape and you want # to join (union) them all together, you can do it with the pg.union() command: # Note: Like all phidl.geometry functions, this will return NEW geometry! In # particular, this function will return a new *flattened* geometry D = Device() D << pg.ellipse(layer=0) D << pg.ellipse(layer=0).rotate(15 * 1) D << pg.ellipse(layer=0).rotate(15 * 2) D << pg.ellipse(layer=0).rotate(15 * 3)
D.add_ref(R) D.add_ref(C).movex(30) qp(D) # quickplot the geometry create_image(D, 'boolean') # example-outline import phidl.geometry as pg from phidl import quickplot as qp from phidl import Device # Create a blank device and add two shapes X = Device() X.add_ref(pg.cross(length = 25, width = 1, layer = 1)) X.add_ref(pg.ellipse(radii = [10,5], layer = 2)) O = pg.outline(X, distance = 1.5, precision = 1e-6, layer = 0) # Plot the original geometry and the result D = Device() D.add_ref(X) D.add_ref(O).movex(30) qp(D) # quickplot the geometry create_image(D, 'outline') # example-xor_diff import phidl.geometry as pg from phidl import quickplot as qp from phidl import Device A = Device() A.add_ref(pg.ellipse(radii = [10,5], layer = 1))
def test_outline(): A = pg.cross(length=10, width=3, layer=0) B = pg.ellipse(radii=(10, 5), angle_resolution=2.5, layer=1) D = pg.outline([A, B], distance=1, precision=1e-6, layer=2) h = D.hash_geometry(precision=1e-4) assert (h == '503522b071080be6c98017cdc616752c1a3d75ce')