Skip to main content

Module edit

Module edit 

Source
Expand description

Hierarchy editing primitives.

All operations return new CellBuilders — frozen cells in the Library are never mutated. The caller chooses whether to insert the result into the same library, a new library, or just inspect it.

Available operations:

  • flatten — produce a single cell containing all shapes from the instance subtree, transforms composed.
  • remap_layers — return a new CellBuilder with shapes remapped to different layers per a LayerMap.
  • replace_instances — rewrite instances of one cell to another by a user-supplied predicate.

Structs§

LayerMap
A layer remapping table — fromto rewrites every shape on from to land on to. Layers not in the map pass through unchanged.

Functions§

clip_cell
Clip a cell to bbox — return a CellBuilder containing only shapes whose bbox intersects bbox. Boxes are clipped to bbox; polygons and paths whose bbox extends past it are kept whole (proper polygon clipping needs klayout-geom’s boolean ops — call those if exact edge clipping matters). Instances are kept if their placement bbox (trans.disp) lies inside bbox and dropped otherwise.
flatten
Flatten a cell’s instance hierarchy max_depth levels deep into a single cell. max_depth = 0 is a no-op (no children flattened); max_depth = usize::MAX flattens everything.
local_bbox
Bbox of the cell restricted to its top-level shapes (no descent into instance children). Convenience for clip-at-top workflows.
remap_layers
Rebuild cell with all shapes’ layers translated through map. Instances are preserved unchanged (the caller can also remap layers on each child by walking the hierarchy themselves).
replace_instances
Rewrite instances of cells matching predicate to point at replacement. The predicate is called with the original instance’s CellId and returns true to swap. Shapes are preserved.