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 newCellBuilderwith shapes remapped to different layers per aLayerMap.replace_instances— rewrite instances of one cell to another by a user-supplied predicate.
Structs§
- Layer
Map - A layer remapping table —
from→torewrites every shape onfromto land onto. Layers not in the map pass through unchanged.
Functions§
- clip_
cell - Clip a cell to
bbox— return aCellBuildercontaining only shapes whose bbox intersectsbbox. Boxes are clipped tobbox; polygons and paths whose bbox extends past it are kept whole (proper polygon clipping needsklayout-geom’s boolean ops — call those if exact edge clipping matters). Instances are kept if their placement bbox (trans.disp) lies insidebboxand dropped otherwise. - flatten
- Flatten a cell’s instance hierarchy
max_depthlevels deep into a single cell.max_depth = 0is a no-op (no children flattened);max_depth = usize::MAXflattens 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
cellwith all shapes’ layers translated throughmap. 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
predicateto point atreplacement. Thepredicateis called with the original instance’sCellIdand returnstrueto swap. Shapes are preserved.