layouttk 0.1.0

Integer-grid GDSII and OASIS layout processing with hierarchy-aware extraction
Documentation
# Drawing before snapping to the grid

`Polygon` holds a contour, its layer/datatype, and its ordered properties. `PolygonSet` owns independent copies of its input polygons. Coordinates and distances are in database units (DBU). Draft vertices retain fractional DBU until insertion into a layout.

```python
from fractions import Fraction
from layouttk import Layer, Layout, Polygon, PolygonSet, Property

device = Polygon.rectangle(
    (Fraction(1, 8), 0), (20, 12),
    layer=Layer(4, 1), properties=[Property.gds(7, b"device")],
)
pair = PolygonSet([device, device.copy().translate(18, 0)])
pair.scale(1, Fraction(3, 2)).mirror((0, 0), (3, 4)).rotate(15)
layout = Layout(dbu_meters=1e-9)
layout.add_cell("TOP")
pair.add_to(layout, "TOP")
```

Transform methods edit the draft and return it for chaining. Call `.copy()` before branching a design. `.area` and `.area_by_layer()` count overlapping polygons separately. `.bounds` gives unsnapped corners. At insertion, each vertex rounds to the nearest integer DBU, with half-grid ties going to the even integer. A polygon that collapses to a line causes the entire batch insertion to fail.

Python integers and fractions retain their exact values through translation, anisotropic scaling, reflection across an arbitrary line, and quarter turns. Other rotations use binary64 trigonometric coefficients. Choose a nearby rotation center for geometry with a large absolute origin. Give very large coordinates as integers, and use `Fraction` when an exact decimal matters.

## Choosing a working precision

`draft.offset(distance, precision=q)` places its input on a temporary integer grid with spacing `q` DBU and returns a new draft on that grid. Choose the finest grid needed for the features in the operation. With a file DBU of 1 nm, `precision=Fraction(1, 8)` gives 0.125 nm ticks. Distance and circular-join tolerance stay in the draft's DBU. A finer temporary grid increases the working-coordinate span, which may be at most 2^41 ticks per group. Writing the result to a 1 nm layout still snaps it to 1 nm.

Independent offsets are the default. Shrinking two adjacent rectangles leaves a gap along the former common edge. With `join_first=True`, the rectangles merge on their common layer before shrinking. When merged shapes carry different properties, pass the output properties explicitly. For example, `properties=[]` assigns an empty list to the resulting boundaries.

The low-level integer `boolean`, `slice`, and `fracture` functions interpret one coordinate tick as one working unit. For a finer calculation, represent all operands and cut positions on the same finer grid before calling them. Convert the result to destination DBU at the final export boundary. `tolerance` controls curve approximation and is independent of that grid spacing.