diff --git a/DOCS.md b/DOCS.md
index a9cf9b9..0c5d480 100644
--- a/DOCS.md
+++ b/DOCS.md
@@ -22,8 +22,8 @@ If you're new to Inire, start with the [single-net quick start](README.md#route-
## Check and improve a route
- [Check the result](docs/user/tune-and-troubleshoot.md#read-the-result) to see whether each net reached its target port and passed verification.
-- [Export verified geometry](docs/user/route-a-layout.md#export-verified-geometry) to use the physical polygons in your layout.
-- [Check geometry against fabrication inputs](docs/user/fabrication.md) for layout-grid rounding, process layers, optical joins, and coplanar waveguides.
+- [Save a placement recipe](docs/user/route-a-layout.md#save-a-placement-recipe) to place the verified components in your layout.
+- [Route with process constraints](docs/user/fabrication.md) for placed ports, process layers, authored lengths, and coplanar waveguides.
- [Diagnose an unfinished net](docs/user/tune-and-troubleshoot.md#why-a-net-stopped-short) to decide whether to change the layout or spend more search time.
- [Choose a routing mode](docs/user/tune-and-troubleshoot.md#choose-a-routing-mode) when your layout calls for a specific planner.
- [Adjust a setting](docs/user/tune-and-troubleshoot.md#choose-the-next-setting) if routes collide, take too long, or use too many bends.
diff --git a/README.md b/README.md
index 51ab66d..e339b54 100644
--- a/README.md
+++ b/README.md
@@ -33,7 +33,7 @@ else:

-The example prints `200.0` in the layout's coordinate unit. Both ports use heading 0 because the path leaves the source and enters the target travelling east. Use this result to try [exporting the physical path](docs/user/route-a-layout.md#export-verified-geometry).
+The example prints `200.0` in the layout's coordinate unit. Both ports use heading 0 because the path leaves the source and enters the target travelling east. Use `result.as_seed()` to [save the placement recipe](docs/user/route-a-layout.md#save-a-placement-recipe).
## Route your own layout
diff --git a/docs/architecture.md b/docs/architecture.md
index 79aef02..856c9d2 100644
--- a/docs/architecture.md
+++ b/docs/architecture.md
@@ -36,7 +36,7 @@ The near-port attempt uses up to 100 nodes per search and two congestion iterati
## Geometry and refinement
-A result carries the requested and effective net specs so export can check the original width and terminal contract after heading inference. Fixed routes carry their owner and physical polygons into the same collision world used by search and verification. The world applies distinct-net clearance to fixed geometry, and planners see fixed routes alongside keepouts. [Route reuse and export](user/route-a-layout.md#reuse-an-existing-route)
+A result carries the requested and effective net specs. The effective net records the resolved ports for replaying the move sequence after heading inference. Fixed routes carry their owner and physical polygons into the same collision world used by search and verification. The world applies distinct-net clearance to fixed geometry, and planners see fixed routes alongside keepouts. [Placement recipes](user/route-a-layout.md#save-a-placement-recipe)
Search, seed replay, and refinement share analytic endpoint and circular sampling calculations. Preparation rejects oversized sampling requests before allocating the outline. Verification uses the materialized polygons for exact containment and clearance.
diff --git a/docs/user/api-reference.md b/docs/user/api-reference.md
index 9800af8..f84f923 100644
--- a/docs/user/api-reference.md
+++ b/docs/user/api-reference.md
@@ -43,14 +43,15 @@ The fields below appear in constructor order. Use one layout unit for coordinate
| `RoutingRunResult.results_by_net` | A read-only mapping from net ID to `RoutingResult`. Use `dict(run.results_by_net)` to make an editable copy. |
| `RoutingResult.is_valid` and `outcome` | `is_valid` is true when the outcome is `completed`. Read `outcome` to distinguish success, a failed geometry check (`colliding`), a path that stopped short (`partial`), or an empty path (`unroutable`). |
| `RoutingResult.requested_net` and `effective_net` | The net as supplied and the net used by the worker, including resolved headings. |
-| `RoutingResult.path` | Ordered path components from the source to the last reached state. An unroutable result has an empty path. |
+| `RoutingResult.path` | Ordered path components from the source to the last reached state. Each component carries its move specification and placed start and end ports. An unroutable result has an empty path. |
| `RoutingResult.reached_target` | Whether the path reached the target position and heading. With heading inference, the check uses the chosen heading. Read `is_valid` for the result of geometry verification. |
| `RoutingResult.report` | `total_length` in layout units plus static, dynamic, and self-collision counts. `out_of_bounds` flags geometry outside the board. `discontinuous` flags missing or point-only joins, including at terminal faces. `invalid_geometry` flags invalid or empty physical polygons. `seed_error` identifies a supplied bend that cannot carry the net's width or cannot be safely materialized. `terminal_error` identifies an inaccessible start or target face. |
-| `RoutingResult.locked_geometry` and `as_seed()` | Physical polygons and the sequence of moves, respectively. Check validity before exporting polygons or [reserving a completed net](route-a-layout.md#reuse-an-existing-route). |
+| `RoutingResult.as_seed()` | The ordered moves for [saving a placement recipe](route-a-layout.md#save-a-placement-recipe) or replaying a path. |
+| `RoutingResult.locked_geometry` | Physical polygons checked during routing. Use these to inspect the route or [reserve a completed net](route-a-layout.md#reuse-an-existing-route). |
| `RoutingRunResult.automatic` | In automatic mode, the selected planner, verified IDs, stage history, and any capacity or port-conflict bound. `None` for explicit modes. |
| `RoutingRunResult.topology` and `metrics` | Corridor counts and seed work when reported by the selected worker, plus work counters across the run. |
-To read a route's polygons and write them to a test file, follow the [geometry export steps](route-a-layout.md#export-verified-geometry). For saved route provenance and full-layer checks, see [Check a complete layer before writing](fabrication.md#check-a-complete-layer-before-writing).
+Check `is_valid` and keep the effective net and geometry settings with each placement recipe. [Placement workflow](route-a-layout.md#save-a-placement-recipe)
## Options and defaults
@@ -86,7 +87,7 @@ To read a route's polygons and write them to a test file, follow the [geometry e
| `bend_physical_length` | `None` | Optional authored centerline length for the shared custom 90-degree template, including tangent extensions. Search, refinement, and reports use it when supplied. |
| `distance_heuristic_weight` | `1.0` | Finite, nonnegative multiplier for the remaining-distance term only. Increase it to favor progress toward the target relative to estimated turn penalties. The routed path's objective stays the same. |
-A custom S-bend outline uses local coordinates. Its input face is centered at `(0, 0)`, its output face at `(span, offset)`, and both ports face east. Use the same grid span as `SBendSeed(offset, radius)`, including any tangent extension to reach the output face. For example, an offset of `40` with radius `50` has its output at `(80, 40)`. The router rotates and translates the entire outline and uses it for collision checks and export. Supply a separate outline to customize the opposite offset. Width matching allows a relative difference of `1e-12` to account for floating-point conversions. An ambiguous match raises an error. Unmatched moves use the circular S-bend. Set `SBendOutline.length` to use a process-specific centerline length for scoring, refinement, and reporting. The default is the nominal circular length. Automatic mode uses lattice search when a registered outline matches a net width. Bundle mode requires circular bends for its nets.
+A custom S-bend outline uses local coordinates. Its input face is centered at `(0, 0)`, its output face at `(span, offset)`, and both ports face east. Use the same grid span as `SBendSeed(offset, radius)`, including any tangent extension to reach the output face. For example, an offset of `40` with radius `50` has its output at `(80, 40)`. The router rotates and translates the entire outline and uses it for collision checks and seed replay. Supply a separate outline to customize the opposite offset. Width matching allows a relative difference of `1e-12` to account for floating-point conversions. An ambiguous match raises an error. Unmatched moves use the circular S-bend. Set `SBendOutline.length` to use a process-specific centerline length for scoring, refinement, and reporting. The default is the nominal circular length. Automatic mode uses lattice search when a registered outline matches a net width. Bundle mode requires circular bends for its nets.
When migrating a half-arc template, supply the complete outline through `sbend_outlines` and keep `bend_physical_geometry` for custom 90-degree bends. Both terminal faces of each custom polygon must be centered on their ports and match the routed width. A custom 90-degree template is shared across nets, so it can only be used by nets whose width matches its faces. Replay an `SBendSeed` with the same outlines and bend settings to recover its physical geometry.
diff --git a/docs/user/fabrication.md b/docs/user/fabrication.md
index a71d372..c04acc3 100644
--- a/docs/user/fabrication.md
+++ b/docs/user/fabrication.md
@@ -1,6 +1,6 @@
-# Check routed geometry before fabrication
+# Route with process constraints
-Inire checks continuity, board containment, and clearance for the shapes and constraints in the routing problem. The placed-cell and process data determine port compatibility, layer assignment, length tolerances, and conductor connectivity. Keep those values with the layout through verification and export.
+Inire checks routed-path continuity, board containment, and clearance for the geometry in the routing problem. Use the placed-cell and process data for port compatibility, layer assignment, and length tolerances. Keep that context with each [placement recipe](route-a-layout.md#save-a-placement-recipe) when assembling the layout.
## Check placed optical ports
@@ -15,114 +15,71 @@ taper_input = PlacedPort(Port(70000, 10000, 0), width=500)
net = source.connect("source_to_taper", taper_input)
```
-For a 3,000 nm target, place the 40 µm taper with its 500 nm face at `taper_input` and its 3,000 nm face abutting the target. Include the placed taper in the cell geometry and open only the intentional join in the routing keepouts. Check the two actual joins in the assembled layer after writing the file. [EBeam taper cell](https://github.com/SiEPIC/SiEPIC_EBeam_PDK/blob/363fbb52eefa8669100499ab531d3fe7befc4867/klayout/EBeam/gds/EBeam/ebeam_routing_taper_te1550_w%3D500nm_to_w%3D3000nm_L%3D40um.gds)
+For a 3,000 nm target, place the 40 µm taper with its 500 nm face at `taper_input` and its 3,000 nm face abutting the target. Use routing keepouts with local openings for the terminal leads. When you assemble the layout, place the verified route against the device ports and check the physical joins. [EBeam taper cell](https://github.com/SiEPIC/SiEPIC_EBeam_PDK/blob/363fbb52eefa8669100499ab531d3fe7befc4867/klayout/EBeam/gds/EBeam/ebeam_routing_taper_te1550_w%3D500nm_to_w%3D3000nm_L%3D40um.gds)
## Preserve length-sensitive paths
-Keep the original polygons and authored length when rerouting one arm of an interferometer. Compare the replacement to the tolerance supplied by the circuit designer. For a matched pair, compare the signed difference between the two arm lengths before and after the replacement.
+Keep the original placement and authored length when rerouting one arm of an interferometer. Compare the replacement to the tolerance supplied by the circuit designer. For a matched pair, compare the signed difference between the two arm lengths before and after the replacement.
```python
from inire.layout import preserves_length
# Lengths are in the same units as the routing layout.
-geometry = replacement.locked_geometry if preserves_length(replacement, authored_length, length_tolerance) else original_geometry
+placement = original_placement
+if preserves_length(replacement, authored_length, length_tolerance):
+ placement = (replacement.effective_net, replacement.as_seed(), options.search)
```
-An authored 286.770 µm path in the Raymond MZI array can be replaced geometrically by a 127.208 µm route. If the circuit uses process-specific Bézier bends, supply the measured centerline length with the custom bend template and use the same setting for search and replay. Use the geometry comparison above to retain the original path when the replacement falls outside the circuit tolerance. [Raymond MZI layout](https://github.com/SiEPIC/openEBL-2025-02/blob/a887476a301db2a014be007717cd1821e111f58e/submissions/EBeam_hannahraymond_MZIv21.gds) · [Custom bend lengths](api-reference.md#searchoptions)
-
-## Check the export grid
-
-Use the layout writer's rounding grid in routing units. `verify_export_grid` rounds route vertices while holding the supplied keepouts fixed. Supply the keepout geometry as it will appear in the file and pass all intended routes on the layer in one call so they are checked against each other. The function requires each result to match the net’s width and terminal contract and to have passed routing verification. For fixed routes, supply their final layout polygons as described in the [route reuse workflow](route-a-layout.md#reuse-an-existing-route). Recheck the assembled cell after writing when the writer performs further operations such as path merging or coordinate transforms.
-
-```python
-from inire.layout import verify_export_grid
-
-results = {net.net_id: run.results_by_net[net.net_id] for net in problem.nets}
-export = verify_export_grid(problem, results, grid=1.0)
-if not export.is_valid:
- raise ValueError(export.reports_by_net)
-geometry_by_net = export.geometry_by_net
-```
-
-For example, two concentric bends with approximately 70.02 nm floating-point clearance can fall below 70 nm on a 1 nm grid. Use an allowed finer database unit or increase the route's margin, then recheck the rounded geometry and run the process deck. [Pinned EBeam spacing deck](https://github.com/SiEPIC/SiEPIC_EBeam_PDK/blob/363fbb52eefa8669100499ab531d3fe7befc4867/klayout/EBeam/drc/SiEPIC_EBeam.drc)
+An authored 286.770 µm path in the Raymond MZI array can be replaced geometrically by a 127.208 µm route. If the circuit uses process-specific Bézier bends, supply the measured centerline length with the custom bend template and use the same setting for search and replay. The length check retains the original placement when the replacement falls outside the circuit tolerance. [Raymond MZI layout](https://github.com/SiEPIC/openEBL-2025-02/blob/a887476a301db2a014be007717cd1821e111f58e/submissions/EBeam_hannahraymond_MZIv21.gds) · [Custom bend lengths](api-reference.md#searchoptions)
## Keep layers and process profiles with the nets
-Each `RoutingProblem` represents one collision plane. Group independent layers by the layer and datatype used by the writer, then keep that pair on the output. Add projected keepouts from other layers when the process requires cross-layer spacing. Keep intentional transitions between layers as placed circuit devices.
+Each `RoutingProblem` represents one collision plane. Group independent layers by layer and datatype and keep that pair with the placement recipes. Add projected keepouts from other layers when the process requires cross-layer spacing. Keep intentional transitions between layers as placed circuit devices.
```python
from inire import RoutingProblem, route
-from inire.layout import partition_layers, verify_export_grid
+from inire.layout import partition_layers
-geometry_by_layer = {}
+placements_by_layer = {}
for layer, nets in partition_layers([((1, 0), silicon_net), ((4, 0), nitride_net)]).items():
- plane = RoutingProblem(bounds, nets, static_obstacles=keepouts_by_layer[layer], clearance=clearance_by_layer[layer])
- run = route(plane, options=options_by_layer[layer])
- export = verify_export_grid(plane, run.results_by_net, grid=1.0)
- if not export.is_valid:
- raise ValueError(export.reports_by_net)
- geometry_by_layer[layer] = export.geometry_by_net
+ plane = RoutingProblem(
+ bounds, nets, static_obstacles=keepouts_by_layer[layer], clearance=clearance_by_layer[layer],
+ )
+ options = options_by_layer[layer]
+ run = route(plane, options=options)
+ placements = {}
+ for net_id, result in run.results_by_net.items():
+ if not result.is_valid:
+ raise ValueError(f"Route {net_id!r} ended with outcome {result.outcome!r}")
+ placements[net_id] = (result.effective_net, result.as_seed(), options.search)
+ placements_by_layer[layer] = placements
```
For different bend rules on the same layer, supply each group's allowed radii in `SearchOptions`. `route_profiles` applies those options to search, seed replay, and refinement, and reserves the verified groups in the order supplied. In the QFoundry example, the flux line can use 15 µm radius while the feedline requires at least 50 µm although both have a 15.5 µm signal width and 7 µm gaps. [QFoundry process profiles](https://github.com/tii-qfoundry/PDK_QFoundry/blob/9c31db1d6879c96bd98460ee134181a865481d75/qfoundry/tech/waveguides.xml#L21-L64)
```python
from inire import RoutingProblem
-from inire.layout import route_profiles, verify_export_grid
+from inire.layout import route_profiles
cpw_plane = RoutingProblem(
bounds, (flux_net, feed_net), static_obstacles=cpw_keepouts, clearance=ground_strip_width,
)
-results = route_profiles(cpw_plane, [
+profiles = [
((flux_net.net_id,), flux_options),
((feed_net.net_id,), feed_options),
-])
-export = verify_export_grid(cpw_plane, results, grid=1.0)
-if not export.is_valid:
- raise ValueError(export.reports_by_net)
+]
+results = route_profiles(cpw_plane, profiles)
+placements = {}
+for net_ids, options in profiles:
+ for net_id in net_ids:
+ result = results[net_id]
+ if not result.is_valid:
+ raise ValueError(f"Route {net_id!r} ended with outcome {result.outcome!r}")
+ placements[net_id] = (result.effective_net, result.as_seed(), options.search)
```
-## Check a complete layer before writing
+## Route a coplanar waveguide envelope
-For a saved layout, keep each route with its source layer, coordinate scale, and revision. Use `SavedRoute` with the verified result from the original run. Supply the current profile for every active net when exporting. The layer check replays each saved move sequence with the current profile and checks its authored length and geometry on the writer’s grid.
+For a 15.5 µm signal with a 7 µm gap on each side, route with a width of 29.5 µm. Use the required ground-strip width as the clearance between envelopes. Save the verified placement recipe for your component library. To verify the same path at the signal width, replay its seed with a 15.5 µm net using the same effective ports and bend rules.
-```python
-from inire.layout import SavedRoute, verify_layer_export
-
-layer = (1, 0)
-meters_per_unit = 1e-9
-saved_routes = {
- net_id: SavedRoute(
- result, layer=layer, meters_per_unit=meters_per_unit, profile_revision=source_revision,
- )
- for net_id, result in original_run.results_by_net.items()
-}
-profiles_by_net = {
- net.net_id: (current_revision, current_options_by_net[net.net_id].search)
- for net in plane.nets
-}
-export = verify_layer_export(
- plane, saved_routes, grid=1.0, layer=layer,
- meters_per_unit=meters_per_unit, profiles_by_net=profiles_by_net,
-)
-if not export.is_valid:
- raise ValueError({net_id: check for net_id, check in export.checks_by_net.items() if not check.is_valid})
-geometry_to_write = export.geometry_by_net
-```
-
-Use `export.checks_by_net` to inspect the recorded revision for active nets and the geometric checks for imported fixed routes. Fixed polygons must be in final layer coordinates and on the writer’s grid. The layer check checks their clearance against other fixed owners, keepouts, and the newly routed polygons. `geometry_to_write` contains the new polygons. The imported polygons are already present in the layout. Verification records and their projected mappings are read-only snapshots.
-
-## Verify a coplanar waveguide cross-section
-
-For a 15.5 µm signal with a 7 µm gap on each side, route the 29.5 µm envelope. Use the required ground-strip width as the clearance between envelopes. Replay the verified seed with a 15.5 µm net using the same ports and bend rules. The conductor and envelope together define the negative gap mask. `coplanar_geometry` checks for side contact and allows the gap to end at the terminal faces. Check the process minimum gap in the assembled layout. A separate wider ground exclusion can be buffered locally from the envelope. This fills the inside of turns where a constant-width circular strip wider than the bend diameter would collapse.
-
-```python
-from inire.layout import coplanar_geometry
-
-cpw = coplanar_geometry(verified_signal, verified_envelope, ground_margin=10000)
-signal = cpw.conductor
-negative_gap_mask = cpw.gaps
-ground_exclusion = cpw.ground_exclusion
-```
-
-On the 1 nm grid, a 3 µm minimum ground strip rejects the 28 µm and 32 µm pitches. A 36 µm pitch leaves a 6.5 µm strip. After applying the negative mask in the layout tool, check that the expected ground regions are connected and that separate signal conductors remain separate. For a coupling capacitor, route one connection on either side of the intentional conductor break and keep its etch mask in the layout. Removing that mask can short the two sections even when a width check passes. [QFoundry DRC](https://github.com/tii-qfoundry/PDK_QFoundry/blob/9c31db1d6879c96bd98460ee134181a865481d75/qfoundry/tech/drc/drc.lydrc) · [CPW chip with coupling capacitor](https://github.com/paulggin/klayout-cpw-design/blob/a38dc34cf6785ba0af41b27f43b6137fd2b69cc7/layouts/cpw_full_layout.gds)
+A 3 µm minimum ground strip rejects parallel tracks at 28 µm and 32 µm pitches. A 36 µm pitch leaves a 6.5 µm strip between their envelopes.
diff --git a/docs/user/route-a-layout.md b/docs/user/route-a-layout.md
index 56b1104..d3d0bed 100644
--- a/docs/user/route-a-layout.md
+++ b/docs/user/route-a-layout.md
@@ -8,14 +8,14 @@ To get a result you can experiment with, run the [single-net quick start](../../
2. **Set source and target headings.** A heading is the direction the waveguide travels as it leaves its source or enters its target. Heading 0 points east and 90 points north. If a device labels a target port by the direction it faces outward, reverse that heading by 180 degrees. For example, a waveguide entering a west-facing port travels east, so its target heading is 0.
3. **Add a net for each connection.** Give each `NetSpec` a unique ID and the guide width. Use your process's allowed bend radii in [`SearchOptions`](api-reference.md#searchoptions).
4. **Set the board and keepouts.** Pass the board rectangle as `bounds`, Shapely polygons as `static_obstacles`, and the required physical spacing as `clearance`. For the defaults and accepted inputs, see [`RoutingProblem`](api-reference.md#routingproblem).
-5. **Route and check.** Call `route(problem, options=options)`. Automatic mode is the default. Before exporting, [check each net's result](tune-and-troubleshoot.md#read-the-result).
+5. **Route and check.** Call `route(problem, options=options)`. Automatic mode is the default. Before using a placement recipe, [check the net's result](tune-and-troubleshoot.md#read-the-result).
## Route between placed crossings
1. **Place the crossing cells.** Keep each cell's physical footprint and internal connections in your layout. Get the port positions and headings in board coordinates after applying placement and rotation.
-2. **Reserve routing keepouts around the cells.** Use the device's routing keepout if supplied. Otherwise, start from its footprint and make local openings at the ports you're connecting. Keep the full physical cell in the exported layout.
+2. **Reserve routing keepouts around the cells.** Use the device's routing keepout if supplied. Otherwise, start from its footprint and make local openings at the ports you're connecting. Keep the full physical cell in your layout.
3. **Route the external connections.** Give Inire one net per connection between devices. The example connects A's east port to B's west port. B's arrival heading points east into the cell.

@@ -63,36 +63,33 @@ result = run.results_by_net[net_id]
assert result.is_valid
```
-Before export, check the port joins and clearance against the actual placed-cell geometry. Inire verifies the external route against the keepouts you supplied.
+When assembling the layout, check the port joins and clearance against the actual placed-cell geometry. Inire verifies the external route against the keepouts you supplied.
For declared port widths and transition cells, see [Check placed optical ports](fabrication.md#check-placed-optical-ports).
-## Export verified geometry
+## Save a placement recipe
-Use `result.locked_geometry` to pass a verified net's physical polygons to a layout writer. To inspect the coordinates in a text file, continue from the quick start or the crossing example and write the polygons as well-known text (WKT). Keep track of your coordinate unit when importing the file into another tool.
-
-Port positions snap to integers. Arc vertices can remain fractional. If the writer uses an integer database grid, [verify the coordinates that will be written](fabrication.md#check-the-export-grid).
+After checking `result.is_valid`, use `result.as_seed()` to get the ordered moves. Keep the effective net, the component settings, and your coordinate unit with the recipe. The effective net records the resolved terminal positions and headings and the route width.
```python
-from pathlib import Path
-
-from shapely.geometry import GeometryCollection
-
if not result.is_valid:
- raise ValueError(f"{result.net_id}: {result.outcome}")
+ raise ValueError(f"Route {result.net_id!r} ended with outcome {result.outcome!r}")
-geometry = GeometryCollection(result.locked_geometry)
-Path("route.wkt").write_text(geometry.wkt + "\n", encoding="utf-8")
+placement = (result.effective_net, result.as_seed(), options.search)
```
-For a multi-net layout, apply the validity check to every net you intend to export. If a route is short or colliding, use its outcome to choose the [next troubleshooting check](tune-and-troubleshoot.md#read-the-result).
+The example uses the `options` from the crossing example. If you called `route(problem)`, use `RoutingOptions().search`.
+
+Place the first move at the effective start port and each subsequent move at the previous move's end port. For explicit placements, read the `move_spec`, `start_port`, and `end_port` of each component in `result.path`. Use the same width, radii, tangent extensions, and custom outlines that the router checked.
+
+Your layout tool realizes the components and writes the layout. Choose widths and clearance with enough margin for any downstream rounding. Inire's verification describes the supplied geometry in routing units. Use `result.locked_geometry` to inspect the polygons it checked or reserve them in a later routing run.
## Reuse an existing route
- **Give the router a route it can move.** Put `result.as_seed()` in `initial_paths` under the net's ID. A seed uses the current start port, width, and geometry settings. Search can follow a partial seed from the first iteration and can leave it to find another approach. To build a hint from turns and straights, see the [path seed reference](api-reference.md#path-seeds).
-- **Hold a route fixed.** Check `result.is_valid`, then use `FixedRoute.from_result(result)` and pass it in `fixed_routes` alongside the remaining nets. The next run respects it as a distinct net, including at zero clearance. Verify the groups together before [exporting the layer](fabrication.md#check-the-export-grid).
+- **Hold a route fixed.** Check `result.is_valid`, then use `FixedRoute.from_result(result)` and pass it in `fixed_routes` alongside the remaining nets. The next run respects it as a distinct net, including at zero clearance.
-When terminal headings are inferred, store the two selected ports alongside the seed, width, and geometry options. Use those exact ports to replay the route and export the same polygons.
+When terminal headings are inferred, use the effective net with the saved moves to replay the same placement.
```python
from dataclasses import replace
@@ -105,7 +102,7 @@ seeds = {}
for net in problem.nets:
result = chosen.results_by_net[net.net_id]
if result.is_valid:
- verified_nets.append(replace(net, start=result.path[0].start_port, target=result.path[-1].end_port))
+ verified_nets.append(result.effective_net)
seeds[net.net_id] = result.as_seed()
replay = route(
@@ -129,7 +126,6 @@ Route a straight net, then reserve it while routing another net on the same laye
from dataclasses import replace
from inire import FixedRoute, NetSpec, Port, RoutingOptions, RoutingProblem, SearchOptions, route
-from inire.layout import verify_export_grid
bounds = (0, -50, 100, 50)
options = RoutingOptions(search=SearchOptions(bend_radii=(10,)))
@@ -139,12 +135,11 @@ problem = RoutingProblem(bounds=bounds, nets=(fixed_net, detour_net), clearance=
fixed = route(replace(problem, nets=(fixed_net,)), options=options).results_by_net["fixed"]
remaining = replace(problem, nets=(detour_net,), fixed_routes=(FixedRoute.from_result(fixed),))
-run = route(remaining, options=options)
-export = verify_export_grid(remaining, run.results_by_net, grid=1.0)
-if not export.is_valid:
- raise ValueError(export.reports_by_net)
+detour = route(remaining, options=options).results_by_net["detour"]
+assert detour.is_valid
+detour_placement = (detour.effective_net, detour.as_seed(), options.search)
```
-For imported metal or waveguide polygons, use `FixedRoute("existing_net", imported_polygons)`. Supply fixed polygons in their final layer coordinates. Export checks new routes against them and returns the new polygons.
+For imported metal or waveguide polygons that belong to an existing net, use `FixedRoute("existing_net", imported_polygons)`. Supply polygons in board coordinates. For other artwork that blocks routing, use `static_obstacles`.
To compare the two paths on a plot, see the [fixed-route example](../../examples/README.md#route-around-fixed-geometry).
diff --git a/docs/user/tune-and-troubleshoot.md b/docs/user/tune-and-troubleshoot.md
index 49e7c6f..2e95589 100644
--- a/docs/user/tune-and-troubleshoot.md
+++ b/docs/user/tune-and-troubleshoot.md
@@ -6,12 +6,12 @@ Start with `run.results_by_net[net_id].outcome`. It distinguishes a path that st
| `result.outcome` | What to inspect |
| --- | --- |
-| `completed` | The path reached its target and passed verification. Read its length in `report.total_length` and follow the [geometry export steps](route-a-layout.md#export-verified-geometry). |
+| `completed` | The path reached its target and passed verification. Read its length in `report.total_length` and [save its placement recipe](route-a-layout.md#save-a-placement-recipe). |
| `colliding` | The path reached its target and failed verification. Check `result.report` for keepout clearance, conflicts with another route, self-overlap, invalid geometry, a bad join, or geometry outside the board. |
| `partial` | Read the position and heading of `result.path[-1].end_port`. Check room for the path to continue from that heading. If the next turn fits, compare search limits. |
| `unroutable` | The path is empty. Check the launch heading and room for the first straight or bend. |
-Check `is_valid` before exporting. Every routing mode checks that the physical polygons fit within the board.
+Check `is_valid` before placing a result. Every routing mode checks that the physical polygons fit within the board.
## Why a net stopped short
diff --git a/examples/03_locked_paths.py b/examples/03_locked_paths.py
index cba1e0a..a7b9a19 100644
--- a/examples/03_locked_paths.py
+++ b/examples/03_locked_paths.py
@@ -1,7 +1,6 @@
from dataclasses import replace
from inire import FixedRoute, NetSpec, ObjectiveWeights, Port, RoutingOptions, RoutingProblem, SearchOptions, TopologyOptions, route
-from inire.layout import verify_export_grid
from inire.utils.visualization import plot_routing_results
@@ -26,9 +25,11 @@ def main() -> None:
print("Routing detour net around locked path...")
remaining = replace(problem, nets=(detour_net,), fixed_routes=(FixedRoute.from_result(fixed),))
run = route(remaining, options=options)
- export = verify_export_grid(remaining, run.results_by_net, grid=1)
- if not export.is_valid:
- raise ValueError(export.reports_by_net)
+ detour = run.results_by_net[detour_net.net_id]
+ if not detour.is_valid:
+ raise ValueError(detour.report)
+ print("Detour net", detour.effective_net)
+ print("Placement recipe", detour.as_seed())
fig, _ax = plot_routing_results({fixed.net_id: fixed, **run.results_by_net}, [], bounds)
fig.savefig("examples/03_locked_paths.png")
diff --git a/examples/README.md b/examples/README.md
index ae87f35..b3a865f 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -20,7 +20,7 @@ After [installing Inire](../README.md#install), run the example scripts with Pyt

-The first call routes a straight waveguide. `FixedRoute.from_result()` reserves its exact polygons, so the new connection passes to the left of the fixed route. The example checks the new route on the export grid against the fixed polygons. Run [`03_locked_paths.py`](03_locked_paths.py) to reproduce the detour. To hold a route fixed in your own design, follow the [route reuse workflow](../docs/user/route-a-layout.md#reuse-an-existing-route).
+The first call routes a straight waveguide. `FixedRoute.from_result()` reserves its exact polygons, so the new connection detours around one end of the fixed route. Run [`03_locked_paths.py`](03_locked_paths.py) to plot the detour and print its resolved net and placement recipe. To hold a route fixed in your own design, follow the [route reuse workflow](../docs/user/route-a-layout.md#reuse-an-existing-route).
diff --git a/inire/geometry/collision.py b/inire/geometry/collision.py
index ad0f163..692b1a4 100644
--- a/inire/geometry/collision.py
+++ b/inire/geometry/collision.py
@@ -779,35 +779,6 @@ class RoutingWorld:
component_conflicts=tuple(sorted(component_conflicts)),
)
- def verify_fixed_footprint(self, net_id: str, polygons: Sequence[Polygon]) -> RoutingReport:
- """Check an imported owner's geometry against the board and other owners."""
- self._ensure_static_raw_tree()
- index = self._static_obstacles
- tree = index.raw_tree
- clearance = self.clearance
- static_collisions = dynamic_collisions = 0
- for polygon in polygons:
- peers = {
- owner for owner, _, other in self._physical_candidates(net_id, polygon)
- if _violates_net_clearance(polygon, other, clearance)
- }
- if tree is not None:
- xmin, ymin, xmax, ymax = polygon.bounds
- candidates = tree.query(box(xmin - clearance, ymin - clearance, xmax + clearance, ymax + clearance))
- for hit in candidates:
- owner = index.raw_owners[hit]
- other = tree.geometries[hit]
- if owner is None:
- static_collisions += int(_violates_clearance(polygon, other, clearance))
- elif owner != net_id and _violates_net_clearance(polygon, other, clearance):
- peers.add(owner)
- dynamic_collisions += len(peers)
- return RoutingReport(
- static_collision_count=static_collisions,
- dynamic_collision_count=dynamic_collisions,
- out_of_bounds=self.board is not None and any(not self.board.covers(polygon) for polygon in polygons),
- )
-
def verify_path_report(self, net_id: str, components: Sequence[ComponentResult]) -> RoutingReport:
return self.verify_path_details(net_id, components).report
diff --git a/inire/layout.py b/inire/layout.py
index 5390298..9ba8b03 100644
--- a/inire/layout.py
+++ b/inire/layout.py
@@ -1,33 +1,21 @@
-"""Checks for assembling and exporting routed geometry with process data."""
+"""Routing helpers for placed ports, authored lengths, and process profiles."""
from __future__ import annotations
-from dataclasses import dataclass, field, replace
-from math import fsum, isclose, isfinite, ulp
-from numbers import Integral
-from typing import TYPE_CHECKING, Literal
-
-from shapely import get_coordinates, set_precision, union_all
-from shapely.geometry import LineString
+from dataclasses import dataclass, replace
+from math import fsum, isfinite
+from typing import TYPE_CHECKING
from inire import route
-from inire._snapshot import snapshot
from inire.constants import TOLERANCE_LINEAR
-from inire.geometry.collision import RoutingWorld
-from inire.geometry.primitives import rotate_cardinal
from inire.model import FixedRoute, NetSpec
-from inire.router._seed_materialization import materialize_path_seed
if TYPE_CHECKING:
- from collections.abc import Iterable, Mapping
+ from collections.abc import Iterable
- from shapely.geometry.base import BaseGeometry
- from shapely.geometry import Polygon
-
- from inire.geometry.components import ComponentResult
from inire.geometry.primitives import Port
- from inire.model import RoutingOptions, RoutingProblem, SearchOptions
- from inire.results import RoutingReport, RoutingResult
+ from inire.model import RoutingOptions, RoutingProblem
+ from inire.results import RoutingResult
@dataclass(frozen=True, slots=True)
@@ -45,242 +33,6 @@ class PlacedPort:
return NetSpec(net_id, self.port, target.port, self.width)
-@dataclass(frozen=True, slots=True)
-class SavedRoute:
- """A verified route with its source layer, units, and profile revision."""
-
- result: RoutingResult
- layer: tuple[int, int] = field(kw_only=True)
- meters_per_unit: float = field(kw_only=True)
- profile_revision: str = field(kw_only=True)
-
- def __post_init__(self) -> None:
- object.__setattr__(self, "layer", _layout_layer(self.layer, self.meters_per_unit))
- if not self.result.is_valid:
- raise ValueError(f"Saved route {self.result.net_id!r} must be completed and verified")
- _check_profile_revision(self.profile_revision)
-
-
-def _layout_layer(layer: tuple[int, int], meters_per_unit: float) -> tuple[int, int]:
- values = tuple(layer)
- if len(values) != 2 or any(isinstance(value, bool) or not isinstance(value, Integral) or value < 0 for value in values):
- raise ValueError("Layout layer and datatype must be nonnegative integers")
- if not isfinite(meters_per_unit) or meters_per_unit <= 0:
- raise ValueError("Layout meters_per_unit must be finite and positive")
- return int(values[0]), int(values[1])
-
-
-def _check_profile_revision(revision: str) -> None:
- if not isinstance(revision, str) or not revision.strip():
- raise ValueError("Profile revision must be a nonempty string")
-
-
-@dataclass(frozen=True, slots=True)
-class ExportNetCheck:
- net_id: str
- polygons: tuple[Polygon, ...]
- report: RoutingReport
- source: Literal["route", "fixed"] = "route"
- on_grid: bool = True
- profile_revision: str | None = None
-
- def __post_init__(self) -> None:
- object.__setattr__(self, "polygons", tuple(self.polygons))
-
- @property
- def is_valid(self) -> bool:
- return self.on_grid and self.report.is_valid
-
-
-@dataclass(frozen=True, slots=True)
-class ExportVerification:
- checks_by_net: Mapping[str, ExportNetCheck]
- grid: float
- layer: tuple[int, int] | None = None
- meters_per_unit: float | None = None
-
- def __post_init__(self) -> None:
- checks = snapshot(self.checks_by_net)
- if any(key != check.net_id for key, check in checks.items()):
- raise ValueError("Export checks must be indexed by their net ID")
- object.__setattr__(self, "checks_by_net", checks)
-
- @property
- def geometry_by_net(self) -> Mapping[str, tuple[Polygon, ...]]:
- return snapshot({key: check.polygons for key, check in self.checks_by_net.items() if check.source == "route"})
-
- @property
- def reports_by_net(self) -> Mapping[str, RoutingReport]:
- return snapshot({key: check.report for key, check in self.checks_by_net.items() if check.source == "route"})
-
- @property
- def is_valid(self) -> bool:
- return all(check.is_valid for check in self.checks_by_net.values())
-
-
-def verify_export_grid(
- problem: RoutingProblem,
- results: Mapping[str, RoutingResult],
- *,
- grid: float,
-) -> ExportVerification:
- """Round and check the supplied routes together against the problem's keepouts."""
- paths = _round_paths(problem, results, grid)
- return ExportVerification(_check_rounded_paths(_install_export_paths(problem, paths), paths), grid)
-
-
-def verify_layer_export(
- problem: RoutingProblem,
- saved_routes: Mapping[str, SavedRoute],
- *,
- grid: float,
- layer: tuple[int, int],
- meters_per_unit: float,
- profiles_by_net: Mapping[str, tuple[str, SearchOptions]],
-) -> ExportVerification:
- """Check current process geometry and all supplied owners on one collision plane."""
- layer = _layout_layer(layer, meters_per_unit)
- active_ids = {net.net_id for net in problem.nets}
- if saved_routes.keys() != active_ids:
- raise ValueError("Whole-layer export needs one saved route for every active net")
- if profiles_by_net.keys() != active_ids:
- raise ValueError("Whole-layer export needs one current profile for every active net")
-
- results = {key: saved.result for key, saved in saved_routes.items()}
- paths = _round_paths(problem, results, grid)
- revisions = {}
- for net in problem.nets:
- saved = saved_routes[net.net_id]
- if saved.layer != layer or not isclose(saved.meters_per_unit, meters_per_unit, rel_tol=1e-12):
- raise ValueError(f"Saved route {net.net_id!r} has a different layer or coordinate scale")
- revision, search = profiles_by_net[net.net_id]
- _check_profile_revision(revision)
- _check_current_profile(saved.result, net, search, paths[net.net_id], grid)
- revisions[net.net_id] = revision
-
- world = _install_export_paths(problem, paths)
- checks = {
- key: replace(check, profile_revision=revisions[key])
- for key, check in _check_rounded_paths(world, paths).items()
- }
- for fixed in problem.fixed_routes:
- checks[fixed.net_id] = ExportNetCheck(
- fixed.net_id, fixed.polygons, world.verify_fixed_footprint(fixed.net_id, fixed.polygons),
- source="fixed", on_grid=all(_polygon_on_grid(polygon, grid) for polygon in fixed.polygons),
- )
- return ExportVerification(checks, grid, layer=layer, meters_per_unit=meters_per_unit)
-
-
-def _check_current_profile(
- result: RoutingResult, net: NetSpec, search: SearchOptions, rounded_path: tuple[ComponentResult, ...], grid: float,
-) -> None:
- seed = result.as_seed()
- error = search.seed_geometry_error(seed)
- if error:
- raise ValueError(f"Saved route {net.net_id!r} {error} in the current profile")
- effective = result.effective_net or net
- replay = materialize_path_seed(seed, start=effective.start, net_width=effective.width, search=search, clearance=0)
- if not replay or replay[-1].end_port != effective.target:
- raise ValueError(f"Saved route {net.net_id!r} cannot be replayed under the current profile")
- saved_length = fsum(component.length for component in result.path)
- current_length = fsum(component.length for component in replay)
- if not isclose(saved_length, current_length, rel_tol=0, abs_tol=TOLERANCE_LINEAR):
- raise ValueError(f"Saved route {net.net_id!r} has a different authored length under the current profile")
- for saved, current in zip(rounded_path, replay, strict=True):
- rounded = _round_component(current, grid)
- if saved.physical_geometry == rounded.physical_geometry:
- continue
- if (
- not saved.physical_checks[0] or not rounded.physical_checks[0]
- or not union_all(saved.physical_geometry).equals(union_all(rounded.physical_geometry))
- ):
- raise ValueError(f"Saved route {net.net_id!r} has different geometry under the current profile")
-
-
-def _polygon_on_grid(polygon: Polygon, grid: float) -> bool:
- for coordinate in get_coordinates(polygon).flat:
- steps = float(coordinate) / grid
- if not isfinite(steps) or abs(steps - round(steps)) > 4 * ulp(steps):
- return False
- return True
-
-
-def _round_paths(
- problem: RoutingProblem, results: Mapping[str, RoutingResult], grid: float,
-) -> dict[str, tuple[ComponentResult, ...]]:
- if not isfinite(grid) or grid <= 0:
- raise ValueError("Export grid must be finite and positive")
- nets = {net.net_id: net for net in problem.nets}
- paths = {}
- for net_id, result in results.items():
- net = nets.get(net_id)
- if net is None or net_id != result.net_id:
- raise ValueError(f"Export result {net_id!r} has no matching routing net")
- if not result.is_valid:
- raise ValueError(f"Export result {net_id!r} must already be verified")
- _check_export_net(net, result)
- paths[net_id] = tuple(_round_component(component, grid) for component in result.path)
- return paths
-
-
-def _install_export_paths(problem: RoutingProblem, paths: Mapping[str, tuple[ComponentResult, ...]]) -> RoutingWorld:
- world = RoutingWorld.from_problem(problem)
- for net_id, path in paths.items():
- # Invalid snapped outlines still get a report. Only valid polygons can enter the index.
- if all(component.physical_checks[0] for component in path):
- world.install_path(net_id, path)
- return world
-
-
-def _check_rounded_paths(
- world: RoutingWorld, paths: Mapping[str, tuple[ComponentResult, ...]],
-) -> dict[str, ExportNetCheck]:
- return {
- net_id: ExportNetCheck(
- net_id,
- tuple(polygon for component in path for polygon in component.physical_geometry),
- world.verify_path_report(net_id, path),
- )
- for net_id, path in paths.items()
- }
-
-
-def _check_export_net(net: NetSpec, result: RoutingResult) -> None:
- effective = result.effective_net or net
- candidates = (effective, result.requested_net) if result.effective_net is not None else (net,)
- ports = (net.start, net.target)
- if not any(
- spec is not None and spec.net_id == net.net_id and (spec.start, spec.target) == ports
- for spec in candidates
- ) or (result.path[0].start_port, result.path[-1].end_port) != (effective.start, effective.target):
- raise ValueError(f"Export result {net.net_id!r} has different terminal ports")
- if not isclose(effective.width, net.width, rel_tol=1e-12):
- raise ValueError(f"Export result {net.net_id!r} has a different width")
- for component in result.path:
- if component.width is None:
- matches = all(
- face is not None and max(abs(face[0] + net.width / 2), abs(face[1] - net.width / 2)) <= TOLERANCE_LINEAR
- for face in component.port_faces
- )
- else:
- matches = isclose(component.width, net.width, rel_tol=1e-12)
- if not matches:
- raise ValueError(f"Export result {net.net_id!r} has a different width")
-
-
-def _round_component(component: ComponentResult, grid: float) -> ComponentResult:
- # Keep the snapped vertices while allowing verification at sub-grid clearances.
- rounded = tuple(
- set_precision(set_precision(polygon, grid, mode="pointwise"), 0, mode="pointwise")
- for polygon in component.physical_geometry
- )
- return replace(
- component, physical_geometry=rounded, collision_geometry=rounded,
- dilated_physical_geometry=rounded, dilated_collision_geometry=rounded,
- standard_faces=False, width=None,
- )
-
-
def preserves_length(result: RoutingResult, authored_length: float, tolerance: float) -> bool:
"""Check the recorded length of a verified replacement against an authored length."""
if not isfinite(authored_length) or authored_length <= 0 or not isfinite(tolerance) or tolerance < 0:
@@ -288,50 +40,6 @@ def preserves_length(result: RoutingResult, authored_length: float, tolerance: f
return result.is_valid and abs(fsum(component.length for component in result.path) - authored_length) <= tolerance
-@dataclass(frozen=True, slots=True)
-class CPWGeometry:
- conductor: BaseGeometry
- gaps: BaseGeometry
- ground_exclusion: BaseGeometry
-
-
-def coplanar_geometry(
- conductor: RoutingResult,
- gap_envelope: RoutingResult,
- *,
- ground_margin: float = 0.0,
-) -> CPWGeometry:
- """Assemble a negative gap mask and optional wider ground exclusion for one CPW."""
- if not isfinite(ground_margin) or ground_margin < 0:
- raise ValueError("CPW ground margin must be finite and nonnegative")
- if not conductor.is_valid or not gap_envelope.is_valid or conductor.as_seed() != gap_envelope.as_seed():
- raise ValueError("CPW conductor and gap envelope need verified geometry from the same seed")
- if any(
- a.start_port != b.start_port or a.end_port != b.end_port for a, b in zip(conductor.path, gap_envelope.path, strict=True)
- ):
- raise ValueError("CPW conductor and gap envelope must use the same ports")
- core = union_all(conductor.locked_geometry)
- envelope = union_all(gap_envelope.locked_geometry)
- if not envelope.covers(core) and not envelope.buffer(TOLERANCE_LINEAR).covers(core):
- raise ValueError("CPW gap envelope must contain its conductor")
- gaps = envelope.difference(core)
- if gaps.is_empty:
- raise ValueError("CPW gap envelope must leave a nonempty gap")
- contact = core.intersection(envelope.boundary)
- if not contact.is_empty:
- first, last = conductor.path[0], conductor.path[-1]
- terminal_regions = []
- for port, face in ((first.start_port, first.port_faces[0]), (last.end_port, last.port_faces[1])):
- if face is None:
- raise ValueError("CPW conductor must have a face at each terminal")
- endpoints = [rotate_cardinal(0, offset, int(port.r)) for offset in face[:2]]
- terminal = LineString([(port.x + dx, port.y + dy) for dx, dy in endpoints])
- terminal_regions.append(terminal.buffer(TOLERANCE_LINEAR))
- if not union_all(terminal_regions).covers(contact):
- raise ValueError("CPW gap closes away from the terminal faces")
- return CPWGeometry(core, gaps, envelope.buffer(ground_margin) if ground_margin else envelope)
-
-
def partition_layers(nets_with_layers: Iterable[tuple[tuple[int, int], NetSpec]]) -> dict[tuple[int, int], tuple[NetSpec, ...]]:
"""Group nets by layout layer and datatype while retaining their input order."""
layers: dict[tuple[int, int], list[NetSpec]] = {}
diff --git a/inire/tests/example_scenarios.py b/inire/tests/example_scenarios.py
index e6b6cfc..19d1166 100644
--- a/inire/tests/example_scenarios.py
+++ b/inire/tests/example_scenarios.py
@@ -11,6 +11,7 @@ from shapely.geometry import Polygon, box
from inire import (
CongestionOptions,
DiagnosticsOptions,
+ FixedRoute,
NetSpec,
ObjectiveWeights,
RoutingOptions,
@@ -121,7 +122,7 @@ def snapshot_example_03() -> ScenarioSnapshot:
problem_b = RoutingProblem(
bounds=problem_a.bounds,
nets=(NetSpec("netB", Port(50, -20, 90), Port(50, 20, 90)),),
- static_obstacles=results_a["netA"].locked_geometry,
+ fixed_routes=(FixedRoute.from_result(results_a["netA"]),),
)
finder_b = build_routing_stack(problem_b, options).finder
results_b = finder_b.route_all()
diff --git a/inire/tests/test_layer_export.py b/inire/tests/test_layer_export.py
deleted file mode 100644
index 6756bb3..0000000
--- a/inire/tests/test_layer_export.py
+++ /dev/null
@@ -1,130 +0,0 @@
-from dataclasses import replace
-
-import pytest
-from shapely.geometry import box
-
-from inire import Bend90Seed, FixedRoute, NetSpec, PathSeed, Port, RefinementOptions, RoutingOptions, RoutingProblem, SearchOptions, route
-from inire.layout import SavedRoute, verify_export_grid, verify_layer_export
-
-
-_LAYER = (1, 0)
-_METERS = 1e-9
-
-
-def _save_route(problem):
- search = SearchOptions(node_limit=0, bend_radii=(15,))
- options = RoutingOptions(search=search, refinement=RefinementOptions(enabled=False))
- result = route(problem, options=options).results_by_net["track"]
- return SavedRoute(result, layer=_LAYER, meters_per_unit=_METERS, profile_revision="rev1"), search
-
-
-def _layer_export(problem, saved_routes, profiles, *, layer=_LAYER, meters_per_unit=_METERS):
- return verify_layer_export(
- problem, saved_routes, grid=1, layer=layer, meters_per_unit=meters_per_unit, profiles_by_net=profiles,
- )
-
-
-@pytest.fixture
-def bend_problem():
- net = NetSpec("track", Port(20, 30, 0), Port(35, 45, 90))
- return RoutingProblem((0, 0, 100, 100), (net,), initial_paths={"track": PathSeed((Bend90Seed(15, "CCW"),))})
-
-
-def test_layer_export_rechecks_current_radius_and_records_revision(bend_problem) -> None:
- saved, search = _save_route(bend_problem)
- with pytest.raises(ValueError, match=r"radius 15 outside bend_radii"):
- _layer_export(bend_problem, {"track": saved}, {"track": ("rev2", replace(search, bend_radii=(50,)))})
-
- export = _layer_export(bend_problem, {"track": saved}, {"track": ("rev2", replace(search, bend_radii=(15, 50)))})
- assert export.is_valid
- assert export.layer == _LAYER
- assert export.meters_per_unit == _METERS
- assert export.grid == 1
- assert export.checks_by_net["track"].profile_revision == "rev2"
- assert export.geometry_by_net == verify_export_grid(bend_problem, {"track": saved.result}, grid=1).geometry_by_net
-
-
-def test_layer_export_checks_current_outline_even_under_same_revision(bend_problem) -> None:
- saved, search = _save_route(bend_problem)
- custom = box(0, -16, 16, -14).union(box(14, -14, 16, 0))
- with pytest.raises(ValueError, match="different geometry under the current profile"):
- _layer_export(bend_problem, {"track": saved}, {"track": ("rev1", replace(search, bend_physical_geometry=custom))})
-
-
-def test_layer_export_checks_authored_length(bend_problem) -> None:
- custom = box(0, -16, 16, -14).union(box(14, -14, 16, 0))
- search = SearchOptions(node_limit=0, bend_radii=(15,), bend_physical_geometry=custom, bend_physical_length=28)
- options = RoutingOptions(search=search, refinement=RefinementOptions(enabled=False))
- result = route(bend_problem, options=options).results_by_net["track"]
- saved = SavedRoute(result, layer=_LAYER, meters_per_unit=_METERS, profile_revision="rev1")
- assert result.report.total_length == 28
- with pytest.raises(ValueError, match="different authored length"):
- _layer_export(bend_problem, {"track": saved}, {"track": ("rev2", replace(search, bend_physical_length=31))})
-
-
-@pytest.mark.parametrize("expected", [{"layer": (2, 0)}, {"meters_per_unit": 1e-6}])
-def test_layer_export_checks_source_layer_and_unit_scale(bend_problem, expected) -> None:
- saved, search = _save_route(bend_problem)
- with pytest.raises(ValueError, match="different layer or coordinate scale"):
- _layer_export(bend_problem, {"track": saved}, {"track": ("rev1", search)}, **expected)
-
-
-def test_layer_export_requires_coverage_and_profiles_for_all_active_nets(bend_problem) -> None:
- saved, search = _save_route(bend_problem)
- with pytest.raises(ValueError, match="saved route for every active net"):
- _layer_export(bend_problem, {}, {"track": ("rev1", search)})
- with pytest.raises(ValueError, match="current profile for every active net"):
- _layer_export(bend_problem, {"track": saved}, {})
- assert verify_export_grid(bend_problem, {}, grid=1).is_valid
-
-
-@pytest.mark.parametrize(
- ("second", "clearance", "valid"),
- [(box(14, 14, 24, 24), 0, False), (box(20, 20, 30, 30), 0, False),
- (box(23, 10, 30, 20), 4, False), (box(24, 10, 30, 20), 4, True)],
-)
-def test_whole_layer_checks_clearance_between_fixed_owners(second, clearance, valid) -> None:
- first = FixedRoute("first", (box(10, 10, 20, 20), box(12, 12, 16, 16)))
- problem = RoutingProblem((0, 0, 50, 50), clearance=clearance, fixed_routes=(first, FixedRoute("second", (second,))))
-
- export = _layer_export(problem, {}, {})
-
- assert export.is_valid is valid
- assert not export.geometry_by_net
- assert not export.reports_by_net
- assert {key: entry.source for key, entry in export.checks_by_net.items()} == {"first": "fixed", "second": "fixed"}
- assert all((entry.report.dynamic_collision_count == 0) is valid for entry in export.checks_by_net.values())
-
-
-def test_whole_layer_checks_fixed_grid_board_and_keepouts() -> None:
- fixed = (
- FixedRoute("off_grid", (box(20.25, 20, 23, 22),)),
- FixedRoute("over_edge", (box(49, 10, 51, 13),)),
- FixedRoute("touching", (box(5, 5, 10, 10),)),
- FixedRoute("blocked", (box(8, 25, 14, 31),)),
- )
- keepouts = (box(10, 5, 15, 10), box(10, 25, 15, 30))
- problem = RoutingProblem((0, 0, 50, 50), static_obstacles=keepouts, clearance=0, fixed_routes=fixed)
-
- export = _layer_export(problem, {}, {})
-
- assert not export.is_valid
- assert not export.checks_by_net["off_grid"].on_grid
- assert export.checks_by_net["over_edge"].report.out_of_bounds
- assert export.checks_by_net["touching"].is_valid
- assert export.checks_by_net["blocked"].report.static_collision_count == 1
-
-
-def test_whole_layer_checks_rounded_routes_against_imported_geometry() -> None:
- net = NetSpec("track", Port(10, 20, 0), Port(90, 20, 0), 1.4)
- fixed = FixedRoute("existing", (box(20, 21, 30, 24),))
- problem = RoutingProblem((0, 0, 100, 50), (net,), clearance=0, fixed_routes=(fixed,))
- result = route(problem).results_by_net["track"]
- saved = SavedRoute(result, layer=_LAYER, meters_per_unit=_METERS, profile_revision="rev1")
-
- export = _layer_export(problem, {"track": saved}, {"track": ("rev1", SearchOptions())})
-
- assert not export.is_valid
- assert export.reports_by_net["track"].static_collision_count == 1
- assert export.checks_by_net["existing"].report.dynamic_collision_count == 1
- assert tuple(export.geometry_by_net) == ("track",)
diff --git a/inire/tests/test_layout.py b/inire/tests/test_layout.py
index f83b27a..3d56bd0 100644
--- a/inire/tests/test_layout.py
+++ b/inire/tests/test_layout.py
@@ -4,13 +4,13 @@ from dataclasses import replace
import pytest
from shapely import union_all
-from shapely.geometry import Polygon, box
+from shapely.geometry import box
from inire import (
Bend90Seed, CongestionOptions, FixedRoute, NetSpec, PathSeed, Port, RefinementOptions,
- RoutingOptions, RoutingProblem, SBendOutline, SBendSeed, SearchOptions, StraightSeed, TopologyOptions, route,
+ RoutingOptions, RoutingProblem, SBendOutline, SearchOptions, StraightSeed, TopologyOptions, route,
)
-from inire.layout import PlacedPort, coplanar_geometry, partition_layers, preserves_length, route_profiles, verify_export_grid
+from inire.layout import PlacedPort, partition_layers, preserves_length, route_profiles
_REPLAY = RoutingOptions(search=SearchOptions(node_limit=0), refinement=RefinementOptions(enabled=False))
@@ -30,8 +30,8 @@ def test_declared_port_width_check_requires_transition_for_wider_device() -> Non
assert rotated.start.r == rotated.target.r == 90
-@pytest.mark.parametrize(("outer_radius", "grid", "valid"), [(3070, 1, False), (3070, 0.01, True), (3072, 1, True)])
-def test_export_verifies_actual_rounded_bend_clearance(outer_radius, grid, valid) -> None:
+@pytest.mark.parametrize(("outer_radius", "valid"), [(3069, False), (3070, True)])
+def test_replay_verifies_actual_concentric_bend_clearance(outer_radius, valid) -> None:
center_x, center_y = 3000, 6070
inner = NetSpec("inside", Port(center_x, center_y - 2500, 0), Port(center_x + 2500, center_y, 90), 490)
outer = NetSpec("outside", Port(center_x, center_y - outer_radius, 0), Port(center_x + outer_radius, center_y, 90), 509.94)
@@ -39,27 +39,11 @@ def test_export_verifies_actual_rounded_bend_clearance(outer_radius, grid, valid
problem = RoutingProblem((0, 0, 7000, 7000), (inner, outer), initial_paths=seeds, clearance=70)
options = replace(_REPLAY, search=replace(_REPLAY.search, bend_radii=(2500, outer_radius)))
results = route(problem, options=options).results_by_net
- assert all(result.is_valid for result in results.values())
-
- exported = verify_export_grid(problem, results, grid=grid)
-
- assert exported.is_valid is valid
- assert all(not report.discontinuous for report in exported.reports_by_net.values())
- assert all(report.dynamic_collision_count == int(not valid) for report in exported.reports_by_net.values())
-
-
-def test_export_rejects_stale_net_specs_and_accepts_legacy_results() -> None:
- net = NetSpec("track", Port(10, 20, 0), Port(90, 20, 0))
- problem = RoutingProblem((0, 0, 100, 50), (net,))
- results = route(problem).results_by_net
- result = results["track"]
- assert result.requested_net == net
- assert result.effective_net == net
- for stale in (replace(net, width=6), replace(net, target=Port(90, 20, 90))):
- with pytest.raises(ValueError, match="different"):
- verify_export_grid(replace(problem, nets=(stale,)), results, grid=1)
- legacy = replace(result, requested_net=None, effective_net=None)
- assert verify_export_grid(problem, {"track": legacy}, grid=1).is_valid
+ for net_id, result in results.items():
+ assert result.as_seed() == seeds[net_id]
+ assert result.is_valid is valid
+ assert not result.report.discontinuous
+ assert result.report.dynamic_collision_count == int(not valid)
@pytest.mark.parametrize("mode", ["automatic", "off", "guide", "seed"])
@@ -77,8 +61,6 @@ def test_imported_fixed_routes_hold_clearance_at_edges_and_vertices(mode, start_
assert set(results) == {"new"}
assert results["new"].is_valid is valid
- if valid:
- assert verify_export_grid(problem, results, grid=1).is_valid
def test_fixed_route_from_result_preserves_polygon_and_owner() -> None:
@@ -91,93 +73,29 @@ def test_fixed_route_from_result_preserves_polygon_and_owner() -> None:
replace(problem, fixed_routes=(fixed,))
-@pytest.mark.parametrize(("keepout_y", "clearance", "valid"), [(21, 0.2, False), (21.2, 0.4, False), (21.25, 0.2, True)])
-def test_export_checks_keepout_clearance_smaller_than_the_grid(keepout_y, clearance, valid) -> None:
- net = NetSpec("signal", Port(10, 20, 0), Port(90, 20, 0), 1.4)
- keepout = box(20, keepout_y, 30, 24)
- problem = RoutingProblem((0, 0, 100, 50), (net,), (keepout,), clearance=clearance)
- results = route(problem).results_by_net
- assert results[net.net_id].is_valid
-
- export = verify_export_grid(problem, results, grid=1)
-
- assert export.geometry_by_net[net.net_id][0].bounds == (10, 19, 90, 21)
- assert export.is_valid is valid
- assert export.reports_by_net[net.net_id].static_collision_count == int(not valid)
-
-
@pytest.mark.parametrize(("pitch", "valid"), [(28000, False), (32000, False), (36000, True)])
-def test_cpw_ground_strip_is_verified_using_gap_envelope(pitch, valid) -> None:
- width = 15500
- nets = tuple(NetSpec(f"cpw{i}", Port(10000, 30000 + i * pitch, 0), Port(210000, 30000 + i * pitch, 0), width)
+def test_cpw_envelope_clearance_and_signal_recipe_replay(pitch, valid) -> None:
+ nets = tuple(NetSpec(f"cpw{i}", Port(10000, 30000 + i * pitch, 0), Port(210000, 30000 + i * pitch, 0), 29500)
for i in range(2))
seeds = {net.net_id: PathSeed((StraightSeed(200000),)) for net in nets}
problem = RoutingProblem((0, 0, 220000, 100000), nets, initial_paths=seeds, clearance=3000)
- signals = route(problem, options=_REPLAY).results_by_net
- envelopes = route(replace(problem, nets=tuple(replace(net, width=29500) for net in nets)), options=_REPLAY).results_by_net
- assert all(signal.is_valid for signal in signals.values())
+
+ envelopes = route(problem, options=_REPLAY).results_by_net
+
assert all(envelope.is_valid for envelope in envelopes.values()) == valid
if valid:
- shapes = [coplanar_geometry(signals[net.net_id], envelopes[net.net_id]) for net in nets]
- assert shapes[0].ground_exclusion.distance(shapes[1].ground_exclusion) == 6500
- assert all(shape.gaps.area == 14000 * 200000 for shape in shapes)
-
-
-def test_cpw_turn_builds_wider_exclusion_from_the_verified_envelope() -> None:
- radius = 15000
- net = NetSpec("flux", Port(35000, 20000, 0), Port(50000, 35000, 90), 15500)
- problem = RoutingProblem((0, 0, 100000, 80000), (net,), initial_paths={"flux": PathSeed((Bend90Seed(radius, "CCW"),))})
- options = replace(_REPLAY, search=SearchOptions(node_limit=0, bend_radii=(radius,), sbend_radii=()))
- signal = route(problem, options=options).results_by_net["flux"]
- envelope = route(replace(problem, nets=(replace(net, width=29500),)), options=options).results_by_net["flux"]
-
- cpw = coplanar_geometry(signal, envelope, ground_margin=10000)
-
- assert cpw.ground_exclusion.covers(union_all(envelope.locked_geometry))
- assert cpw.gaps.area > 0
-
-
-@pytest.mark.parametrize("gap", [0, 0.5])
-def test_cpw_checks_for_side_contact_between_terminal_faces(gap) -> None:
- signal_outline = Polygon([(0, -1), (3, -1), (12, 5), (15, 5), (15, 7), (12, 7), (3, 1), (0, 1)])
- envelope_outline = Polygon([(0, -2), (3, -1 - gap), (12, 5 - gap), (15, 4), (15, 8), (12, 8), (3, 2), (0, 2)])
- net = NetSpec("signal", Port(10, 20, 0), Port(25, 26, 0), 2)
- problem = RoutingProblem((0, 0, 100, 50), (net,), initial_paths={net.net_id: PathSeed((SBendSeed(6, 10),))})
- options = replace(_REPLAY, search=replace(_REPLAY.search, sbend_outlines=(
- SBendOutline(6, 10, 2, signal_outline), SBendOutline(6, 10, 4, envelope_outline),
- )))
- signal = route(problem, options=options).results_by_net[net.net_id]
- envelope = route(replace(problem, nets=(replace(net, width=4),)), options=options).results_by_net[net.net_id]
- assert signal.is_valid
- assert envelope.is_valid
-
- with pytest.raises(ValueError, match="nonempty gap"):
- coplanar_geometry(signal, signal)
- if gap:
- assert coplanar_geometry(signal, envelope).gaps.area > 0
- else:
- with pytest.raises(ValueError, match="closes away from the terminal faces"):
- coplanar_geometry(signal, envelope)
-
-
-def test_cpw_coupling_etch_keeps_two_signal_sections_separate() -> None:
- # The two nets abut opposite faces of the authored 5 µm interruption.
- nets = (
- NetSpec("before", Port(10000, 30000, 0), Port(97500, 30000, 0), 15500),
- NetSpec("after", Port(102500, 30000, 0), Port(210000, 30000, 0), 15500),
- )
- seeds = {"before": PathSeed((StraightSeed(87500),)), "after": PathSeed((StraightSeed(107500),))}
- problem = RoutingProblem((0, 0, 220000, 60000), nets, initial_paths=seeds)
- run = route(problem, options=_REPLAY)
- export = verify_export_grid(problem, run.results_by_net, grid=1)
- assert export.is_valid
- assembled = union_all([polygon for polygons in export.geometry_by_net.values() for polygon in polygons])
-
- original_metal = box(10000, 22250, 210000, 37750)
- coupling_etch = box(97500, 22250, 102500, 37750)
- assert assembled.equals(original_metal.difference(coupling_etch))
- assert len(assembled.geoms) == 2
- assert assembled.union(coupling_etch).equals(original_metal)
+ signals = replace(
+ problem,
+ nets=tuple(replace(net, width=15500) for net in nets),
+ initial_paths={key: result.as_seed() for key, result in envelopes.items()},
+ )
+ replay = route(signals, options=_REPLAY)
+ assert replay.metrics.nodes_expanded == 0
+ for net in signals.nets:
+ result = replay.results_by_net[net.net_id]
+ assert result.is_valid
+ assert result.effective_net == net
+ assert result.as_seed() == envelopes[net.net_id].as_seed()
def test_profile_options_apply_to_active_search_and_seed_replay() -> None:
@@ -219,7 +137,7 @@ def test_profile_reserves_replayed_net_against_zero_clearance_contact(second_y,
assert results["first"].is_valid
assert results["second"].is_valid is valid
if valid:
- assert verify_export_grid(problem, results, grid=1).is_valid
+ assert results["second"].as_seed() == seeds["second"]
def test_independent_layer_outputs_retain_assignment_and_connectivity() -> None:
@@ -231,10 +149,11 @@ def test_independent_layer_outputs_retain_assignment_and_connectivity() -> None:
(0, 0, 20000, 20000), nets,
initial_paths={net.net_id: PathSeed((StraightSeed(18000),)) for net in nets},
)
- results = route(problem, options=_REPLAY).results_by_net
- export = verify_export_grid(problem, results, grid=1)
- assert export.is_valid
- geometry[layer] = union_all(tuple(polygon for shapes in export.geometry_by_net.values() for polygon in shapes))
+ result, = route(problem, options=_REPLAY).results_by_net.values()
+ assert result.is_valid
+ assert result.effective_net == nets[0]
+ assert result.as_seed() == problem.initial_paths[result.net_id]
+ geometry[layer] = union_all(result.locked_geometry)
assert set(geometry) == {(1, 0), (4, 0)}
assert all(shape.geom_type == "Polygon" for shape in geometry.values())
assert geometry[1, 0].intersection(geometry[4, 0]).area > 0
@@ -272,7 +191,7 @@ def test_authored_sbend_length_survives_seed_replay() -> None:
assert preserves_length(replay, 95, tolerance=0)
-def test_export_and_routing_results_are_detached_snapshots() -> None:
+def test_routing_inputs_and_results_are_detached_snapshots() -> None:
track = NetSpec("track", Port(10, 20, 0), Port(90, 20, 0))
seeds = {"track": PathSeed((StraightSeed(80),))}
problem = RoutingProblem((0, 0, 100, 50), (track,), initial_paths=seeds)
@@ -280,25 +199,10 @@ def test_export_and_routing_results_are_detached_snapshots() -> None:
assert tuple(problem.initial_paths) == ("track",)
run = route(problem, options=_REPLAY, iteration_callback=lambda _, results: results.clear())
- original = dict(run.results_by_net)
- export = verify_export_grid(problem, original, grid=1)
- original.clear()
-
with pytest.raises(TypeError):
problem.initial_paths["track"] = PathSeed(())
with pytest.raises(TypeError):
del run.results_by_net["track"]
- with pytest.raises(TypeError):
- export.geometry_by_net["track"] = (box(0, 0, 1, 1),)
- with pytest.raises(TypeError):
- del export.reports_by_net["track"]
- with pytest.raises(TypeError):
- del export.checks_by_net["track"]
-
- copied = dict(export.geometry_by_net)
- copied.clear()
- assert tuple(export.geometry_by_net) == ("track",)
- assert export.is_valid
assert run.results_by_net["track"].is_valid
@@ -306,10 +210,8 @@ def test_read_only_snapshots_survive_python_copy_and_pickle() -> None:
track = NetSpec("track", Port(10, 20, 0), Port(90, 20, 0))
problem = RoutingProblem((0, 0, 100, 50), (track,))
run = route(problem)
- export = verify_export_grid(problem, run.results_by_net, grid=1)
for copy in (deepcopy, lambda value: pickle.loads(pickle.dumps(value))):
assert copy(problem) == problem
- assert copy(export) == export
restored = copy(run)
assert restored == run
with pytest.raises(TypeError):
diff --git a/inire/tests/test_terminal_bench.py b/inire/tests/test_terminal_bench.py
index 841999e..0c828c6 100644
--- a/inire/tests/test_terminal_bench.py
+++ b/inire/tests/test_terminal_bench.py
@@ -9,7 +9,6 @@ from shapely.geometry import box
from inire import Bend90Seed, DiagnosticsOptions, Port, SBendSeed, TopologyOptions, route
from inire.constants import TOLERANCE_LINEAR
-from inire.layout import _check_export_net
from inire.router._waypoints import export_waypoints
from inire.tests.terminal_bench_lane_plan import terminal_bench_lane_problem
from inire.tests.terminal_bench_scenario import (
@@ -158,5 +157,32 @@ def test_automatic_constructs_bundle_without_triangulation(unsupported, monkeypa
assert result.path[-1].end_port.r == 180
assert result.requested_net == requested
assert result.effective_net == replace(requested, target=replace(requested.target, r=180))
- _check_export_net(requested, result)
- _check_export_net(result.effective_net, result)
+
+
+def test_placement_recipes_replay_with_resolved_ports() -> None:
+ problem = terminal_bench_problem()
+ options = replace(
+ terminal_bench_options(node_limit=100, max_iterations=1),
+ topology=TopologyOptions(infer_terminal_headings=True),
+ )
+ run = route(problem, options=options)
+ assert all(result.is_valid for result in run.results_by_net.values())
+ seeds = {key: result.as_seed() for key, result in run.results_by_net.items()}
+ replay_options = replace(
+ options, search=replace(options.search, node_limit=0), topology=TopologyOptions(mode="off"),
+ refinement=replace(options.refinement, enabled=False),
+ )
+ requested = route(replace(problem, initial_paths=seeds), options=replay_options)
+ assert not requested.results_by_net["net_08"].reached_target
+
+ nets = tuple(result.effective_net for result in run.results_by_net.values())
+ assert all(net is not None for net in nets)
+ replay = route(replace(problem, nets=nets, initial_paths=seeds), options=replay_options)
+ assert replay.metrics.nodes_expanded == 0
+ assert replay.results_by_net.keys() == run.results_by_net.keys()
+ for key, result in replay.results_by_net.items():
+ original = run.results_by_net[key]
+ assert result.is_valid
+ assert result.effective_net == original.effective_net
+ assert result.as_seed() == seeds[key]
+ assert result.locked_geometry == original.locked_geometry
diff --git a/plans/full-project-review.md b/plans/full-project-review.md
index 39f39ed..c0196e8 100644
--- a/plans/full-project-review.md
+++ b/plans/full-project-review.md
@@ -248,7 +248,7 @@ Verify supplied paths once when the search budget is zero and return the physica
In the Raymond fabrication submission, the two `MZI9` arms carry authored length annotations of 286.770 µm (`Waveguide$10`) and 183.637 µm (`Waveguide$1`). Replacing the former with the automatic route from `(261120, -46270, 0)` to `(261120, -167770, 180)` on the 1 nm grid gives a 127.208 µm path, using two clockwise 5 µm quarter turns and a 111.5 µm straight. Both 500 nm port faces join the existing silicon, and the modified MZI array still passes the published EBeam deck. The signed arm-length difference changes from +103.133 µm to −56.429 µm. Even when the original waypoints and radius are replayed, the circular replacement's reported length can differ from the authored waveguide length. The EBeam 500 nm strip definition specifies Bézier bends, and the `Waveguide` cell's authored 156.137 µm becomes 154.948 µm with circular bends. [Raymond fabrication layout](https://github.com/SiEPIC/openEBL-2025-02/blob/a887476a301db2a014be007717cd1821e111f58e/submissions/EBeam_hannahraymond_MZIv21.gds) · [EBeam waveguide definitions](https://github.com/SiEPIC/SiEPIC_EBeam_PDK/blob/363fbb52eefa8669100499ab531d3fe7befc4867/klayout/EBeam/WAVEGUIDES.xml#L3-L15) · [Public results](../docs/user/api-reference.md#results)
-Document which geometric and fabrication checks are covered and which circuit constraints callers must supply and check. Add a reuse example that compares a verified replacement with the authored length and preserves the incumbent when the length difference falls outside tolerance. Evaluate a per-net length target or pairwise length-difference constraint, and carry the actual process-specific bend length through search, refinement, and export when that model is supplied. Use both a length-sensitive MZI and an unconstrained connection as acceptance cases. [Export workflow](../docs/user/route-a-layout.md#export-verified-geometry)
+Document which geometric and fabrication checks are covered and which circuit constraints callers must supply and check. Add a reuse example that compares a verified replacement with the authored length and preserves the incumbent when the length difference falls outside tolerance. Evaluate a per-net length target or pairwise length-difference constraint, and carry the actual process-specific bend length through search, refinement, and export when that model is supplied. Use both a length-sensitive MZI and an unconstrained connection as acceptance cases. [Authored length workflow](../docs/user/fabrication.md#preserve-length-sensitive-paths)
## 32. Infer a launch S-bend before a final quarter turn — Medium
@@ -260,9 +260,7 @@ Use the position before a supported terminal quarter turn to propose useful S-be
The pinned QFoundry feedline defines a 15.5 µm signal trace with a 7 µm gap on each side. Replay two parallel, 200 µm straight connections on a 1 nm grid using `NetSpec.width=15500` and `clearance=3000`. At a 32 µm pitch Inire verifies both center conductors. Converting the paths to the negative lithography layer leaves a 2.5 µm ground strip between the two gap envelopes. The QFoundry deck reports one aluminum width violation. At 28 µm pitch the two envelopes merge and the center ground strip disappears. The deck reports no width violation because the intended strip no longer exists. Replaying the same paths at the 29.5 µm envelope width with 3 µm clearance rejects both pitches. A 36 µm control verifies the envelopes, leaves a 6.5 µm strip, and passes the deck. [RF routing scope](../README.md) · [QFoundry waveguide dimensions and layers](https://github.com/tii-qfoundry/PDK_QFoundry/blob/9c31db1d6879c96bd98460ee134181a865481d75/qfoundry/tech/waveguides.xml#L21-L48) · [QFoundry fabrication checks](https://github.com/tii-qfoundry/PDK_QFoundry/blob/9c31db1d6879c96bd98460ee134181a865481d75/qfoundry/tech/drc/drc.lydrc)
-Add an RF example that routes against the gap envelope and reuses the verified centerline to emit the strip and gaps on the required process layers. Explain how to preserve the separate ground-clearance envelope and verify ground connectivity, since a width check cannot find an absent strip. At the 15 µm minimum flux-line bend radius, replay builds the 15.5 µm core and the 29.5 µm gap envelope, but rejects the 49.5 µm ground-clearance width because it exceeds the bend diameter. Build this wider exclusion as an offset of the local footprint that fills the inside of the bend. Keep the single-polygon optical workflow available. Check the three pitches and a bend using the published dimensions and process rules. [Geometry export](../docs/user/route-a-layout.md#export-verified-geometry)
-
-Preserve intentional breaks during import and export. In the 5-by-3 mm reference chip, declare one connection on each side of the coupling capacitor, using the effective metal after applying the etch layer. Use the reconstructed mask as the passing control and deliberately omit the coupling mask to check that the independent connectivity test detects the short. [Published CPW chip](https://github.com/paulggin/klayout-cpw-design/blob/a38dc34cf6785ba0af41b27f43b6137fd2b69cc7/layouts/cpw_full_layout.gds)
+Route against the gap envelope and replay the verified placement at the signal width. At the 15 µm minimum flux-line bend radius, the router accepts the 15.5 µm signal and the 29.5 µm gap envelope. The 49.5 µm width exceeds the bend diameter. Check the three pitches using the published dimensions and process rules. [CPW envelope routing](../docs/user/fabrication.md#route-a-coplanar-waveguide-envelope)
## 34. Apply the bend rules for each geometry class on a mixed layout — Medium
@@ -290,13 +288,13 @@ Check terminal positions and the required physical end faces against the board a
## 38. Distinguish zero clearance from a short between different nets — Medium
-On a 1 nm grid, replay two 8 µm straights with 500 nm width and y coordinates 2000 and 2500. At `clearance=0`, both routes verify without dynamic collisions. Their polygons share an 8 µm edge. After writing and reading the common silicon layer, KLayout merges them into one connected polygon. The published EBeam width and spacing deck produces no marker because it sees a single conductor. At positive clearance, Inire detects the contact. A control with 70 nm of actual gap verifies in both tools and retains two connected components. [Exact clearance predicate](../inire/geometry/collision.py#L48) · [Geometry export](../docs/user/route-a-layout.md#export-verified-geometry) · [Pinned EBeam deck](https://github.com/SiEPIC/SiEPIC_EBeam_PDK/blob/363fbb52eefa8669100499ab531d3fe7befc4867/klayout/EBeam/drc/SiEPIC_EBeam.drc)
+On a 1 nm grid, replay two 8 µm straights with 500 nm width and y coordinates 2000 and 2500. At `clearance=0`, both routes verify without dynamic collisions. Their polygons share an 8 µm edge. After writing and reading the common silicon layer, KLayout merges them into one connected polygon. The published EBeam width and spacing deck produces no marker because it sees a single conductor. At positive clearance, Inire detects the contact. A control with 70 nm of actual gap verifies in both tools and retains two connected components. [Exact clearance predicate](../inire/geometry/collision.py#L48) · [Placement workflow](../docs/user/route-a-layout.md#save-a-placement-recipe) · [Pinned EBeam deck](https://github.com/SiEPIC/SiEPIC_EBeam_PDK/blob/363fbb52eefa8669100499ab531d3fe7befc4867/klayout/EBeam/drc/SiEPIC_EBeam.drc)
Define and document whether distinct nets may share edges or vertices at zero clearance. For independent same-layer connections, report shared edges as shorts or require an explicit policy for intentional contact. Preserve normal adjacent moves of the same net and process boundaries represented as keepouts. Check a shared edge, an endpoint contact, a valid zero-clearance boundary, and separate exported conductors.
## 39. Verify clearance on the coordinates written to the layout file — Medium
-On a 1 nm grid, replay concentric counterclockwise quarter turns about `(3000, 6070)`. The inner net is 490 nm wide with radius 2500 nm, from `(3000, 3570, 0)` to `(5500, 6070, 90)`. The outer is 509.94 nm wide with radius 3070 nm, from `(3000, 3000, 0)` to `(6070, 6070, 90)`. At clearance 70 nm both verify, with a minimum floating-point separation of 70.0208 nm. Rounding their polygon vertices to the original 1 nm grid reduces the gap to 68.9420 nm. KLayout reports 12 EBeam `Si_space` markers in the written OASIS file. A 0.1 nm export of the same polygons produces zero markers. The 1 nm control with a 3072 nm outer radius, the same widths, and corresponding endpoints also produces zero markers. [Public export workflow](../docs/user/route-a-layout.md#export-verified-geometry) · [Arc polygon coordinates](../inire/geometry/components.py#L235) · [Pinned EBeam spacing rule](https://github.com/SiEPIC/SiEPIC_EBeam_PDK/blob/363fbb52eefa8669100499ab531d3fe7befc4867/klayout/EBeam/drc/SiEPIC_EBeam.drc)
+On a 1 nm grid, replay concentric counterclockwise quarter turns about `(3000, 6070)`. The inner net is 490 nm wide with radius 2500 nm, from `(3000, 3570, 0)` to `(5500, 6070, 90)`. The outer is 509.94 nm wide with radius 3070 nm, from `(3000, 3000, 0)` to `(6070, 6070, 90)`. At clearance 70 nm both verify, with a minimum floating-point separation of 70.0208 nm. Rounding their polygon vertices to the original 1 nm grid reduces the gap to 68.9420 nm. KLayout reports 12 EBeam `Si_space` markers in the written OASIS file. A 0.1 nm export of the same polygons produces zero markers. The 1 nm control with a 3072 nm outer radius, the same widths, and corresponding endpoints also produces zero markers. [Placement workflow](../docs/user/route-a-layout.md#save-a-placement-recipe) · [Arc polygon coordinates](../inire/geometry/components.py#L235) · [Pinned EBeam spacing rule](https://github.com/SiEPIC/SiEPIC_EBeam_PDK/blob/363fbb52eefa8669100499ab531d3fe7befc4867/klayout/EBeam/drc/SiEPIC_EBeam.drc)
Document that snapping ports leaves bend polygons with fractional vertex coordinates. In a fabrication export adapter, verify the actual quantized geometries or allow an intentional clearance margin tied to the export grid. Test rounded bends near minimum clearance and check that the selected rounding policy preserves port faces and accepted joins.