Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Layout cross-section import (finding)

Status: blocked upstream. No import code exists. This page records what the pinned layout tool offers, so the next step is a precise upstream request rather than a second layout reader in this tree.

The pin

Layout reading is not reimplemented in lindhard; it is meant to come from the klayout-tools package at one pinned version. The pin lives in one file, tools/klayout-tools.pin (currently 0.7.0, the latest PyPI release when this was written). Bump it deliberately, in its own change, and re-run the check below.

Run a pinned release without touching any installed tool:

uvx --from "klayout-tools==$(cat tools/klayout-tools.pin)" klt --help

What 0.7.0 offers

Checked by running each verb on a two-rectangle layout written with klt draw.

VerbGivesPolygons?
klt layers --flattened --format jsonlayer/datatype list, shape counts, per-layer bounding boxno
klt stats --per-layer --format jsonper-layer drawn area (area_um2, a raw sum with overlaps double-counted; merged_area_um2 is the union), polygon and vertex countsno
klt clip --region '[l,b,r,t]' -o out.gdsa GDSII/OASIS stream of the regiononly as a stream
klt drawwrites a stream from JSON polygonswrite side only

The Python modules of the package (klayout_tools._layout and friends) are underscore-private and not documented as an interface, and klayout.db is a transitive dependency, not part of the package’s contract. None of them is a supported polygon export.

Finding

The pinned release has no machine-readable path from a layout region to polygons. The only way to get geometry out of a region is klt clip, which writes a stream, and reading that stream back would be a second GDS/OASIS reader in this tree. That is ruled out, so the cross-section import (process stack, 2D/3D target build, area cross-check against the layout tool) is not started.

What is needed upstream

A read-side verb or documented Python function in klayout-tools that, for a layout, an optional --region and a layer list, returns per-layer merged polygons as JSON:

  • units of micrometres and the database unit, as klt layers already reports;
  • one entry per (layer, datatype) with a list of polygons, each a hull plus holes as vertex lists, hierarchy flattened and merged (same rule as merged_area_um2);
  • a schema_version, so the seam can fail on an unsupported version.

With that, the import needs only a process-stack input format (layer to material, thickness, mask/etch rule), its validation, the target builders on the Phase 1 geometry kernels, and a test comparing imported areas with klt stats for a fixture layout.