SuperStructure#

class zeroheliumkit.src.supercore.SuperStructure(route_config: dict)[source]#

Bases: Structure

A subclass of Structure representing a superstructure. Provides additional methods for routing and adding structures along a skeleton line.

Args

route_config : dict Configuration for routing.

Methods

add(layer)

Adds a layer to the class with the given name and geometry.

add_along_skeletone(bound_anchors, structure)

Adds structures along the skeleton line.

append(structure[, anchoring, ...])

Appends an Entity or Structure to the Structure.

bufferize_routing_line(line, layers[, ...])

Appends route to skeleton and create polygons by buffering.

clean()

Removes all layers with empty polygons

copy([rename_anchors, with_suffix])

Creates a deep copy of the Entity instance.

crop(geom[, loc])

Crops polygons in all layers.

cut(geom[, loc])

Cuts the specified polygon from polygons in all layers.

export_dict([remove_holes])

Returns all layer names and their corresponding geometries in a Dictionary.

export_dxf(filename, layer_cfg)

Exports layers as a DXF file.

export_gds(filename, layer_cfg)

Exports all layers as a GDS file.

export_pickle(filename)

Exports all layers as a pickle file.

get(lname)

Retrieves a layer by its name.

has_layer(name)

Check if a layer exists in the class.

mirror(aroundaxis[, keep_original, ...])

Mirror all objects around a specified axis.

move(dx, dy)

Moves all objects in the class by the specified (dx, dy) offset.

quickplot([size, color_config, zoom, ...])

Plots the Entity object with predefined colors for each layer.

remove(lname)

Removes a layer from the class.

rename(old, new)

Changes the name of a layer/attribute in the class.

return_mirrored(aroundaxis, **kwargs)

Returns a mirrored copy of the Structure class.

rotate([angle, origin])

Rotates all objects in the class

round_corner(layers, around_point, radius, ...)

Rounds the corner of the polygon closest to a given Point in a specific layer.

route(anchors[, layers, airbridge, ...])

Routes between anchors and creates a route line with optional buffering.

scale([xfact, yfact, origin])

Scales all objects by the specified factors along the x and y axes.

slice(slice_line)

Slices polygons in a layer using a given line.

snap_to(point_from, point_to)

Snaps all objects in the class so that point_from aligns with point_to.

Attributes

anchors

colors

errors

layers

skeletone

route(anchors: tuple, layers: dict = None, airbridge: Entity | Structure = None, extra_rotation: float = 0, print_status: bool = False, rm_anchor: bool | tuple | str = False, rm_route: bool = False, cap_style: str = 'flat', **kwargs) None[source]#

Routes between anchors and creates a route line with optional buffering. If airbridge is provided, it will be added to the route, allowing for crossings with the skeleton line.

Parameters:
  • anchors (tuple) – The anchors to route between. Provide labels.

  • layers (dict) – The layer width information.

  • airbridge (Entity | Structure) – The airbridge structure. Should contain ‘in’ and ‘out’ anchors. Defaults to None

  • extra_rotation (float, optional) – Additional rotation angle for the airbridge. Defaults to 0.

  • print_status (bool, optional) – Whether to print the status of the route creation. Defaults to False.

  • rm_anchor (bool or str, optional) – If True, removes the anchor points after appending. If a string is provided, removes the specified anchor point. Defaults to False.

  • rm_route (bool, optional) – Whether to remove created route line. Defaults to False.

  • cap_style (str, optional) – The cap style for the buffered line. Defaults to “flat”.

add_along_skeletone(bound_anchors: tuple, structure: Structure | Entity, locs: list = None, num: int = 1, endpoints: bool | tuple = False, normalized: bool = False, additional_rotation: float | int = 0, line_idx: int = None) None[source]#

Adds structures along the skeleton line.

Parameters:
  • bound_anchors (tuple) – Skeleton region contained between two anchors.

  • structure (Structure | Entity) – Structure to be added.

  • locs (list, optional) – List of locations along the skeleton line where the structures will be added. If not provided, the structures will be evenly distributed between the two anchor points.

  • num (int, optional) – Number of structures to be added. Ignored if locs is provided.

  • endpoints (bool|tuple, optional) – Whether to include the endpoints of the skeleton line as locations for adding structures. ex. tuple = (1,0) includes start point and excludes end point. Defaults to False.

  • normalized (bool, optional) – Whether the locations are normalized along the skeleton line. Defaults to False.

Raises:

WrongSizeError – If the number of bound_anchors is not equal to 2.

Example

# Adds 5 structures evenly distributed along the skeleton line between anchor1 and anchor2 >>> add_along_skeleton((anchor1, anchor2), structure, num=5) # Adds 3 structures at specific locations along the skeleton line between anchor1 and anchor2 >>> add_along_skeleton((anchor1, anchor2), structure, locs=[0.2, 0.5, 0.8])

bufferize_routing_line(line: LineString, layers: float | int | list | dict, keep_line: bool = True, cap_style: str = 'flat') None[source]#

Appends route to skeleton and create polygons by buffering.

Parameters:
  • line (LineString) – The route line.

  • layers (Union[float, int, list, dict]) – The layer information. It can be a single value, a list of values, or a dictionary with distances and widths.

Examples

>>> line = LineString([(0, 0), (1, 1), (2, 2)])
>>> layers = {'layer1': 0.1, 'layer2': [0.2, 0.3, 0.4]}
>>> bufferize_routing_line(line, layers)
>>> line = LineString([(0, 0), (1, 1), (2, 2)])
>>> layers = {'layer1': {'d': [0, 0.5, 1], 'w': [0.1, 0.2, 0.1], 'normalized': True}}
>>> bufferize_routing_line(line, layers)
>>> line = LineString([(0, 0), (1, 1), (2, 2)])
>>> layers = {'layer1': [0.1, 0.2, 0.3], 'layer2': {'d': [0, 0.5, 1], 'w': [0.2, 0.3, 0.2], 'normalized': False}}
>>> bufferize_routing_line(line, layers)
round_corner(layers: str | list[str], around_point: tuple | Point, radius: float, **kwargs) SuperStructure[source]#

Rounds the corner of the polygon closest to a given Point in a specific layer.

Parameters:
  • layers (str | list[str]) – The layer(s) on which the operation should be performed.

  • around_point (tuple | Point) – The point around which the corner should be rounded.

  • radius (float | int) – The radius to be applied for rounding the corners.

  • **kwargs – Additional keyword arguments to be passed to the rounding function.

Returns:

The modified SuperStructure instance with the rounded corner applied to the specified layer.

Return type:

SuperStructure