Expand description
Deriving a route’s edge geometry from its ordered corner list.
Under the explicit-path model a route is fully described by its ordered
corner sequence [start_pos, waypoint…, end_pos] — waypoint insertion order
is the polyline order. These helpers extract the canonical corner set from
a raw polyline and read a route’s ordered corner points; the straight-or-route
reconstruction (which turns those corners back into edges, invoking the
router only for blocked/non-colinear legs) builds on them.
Structs§
- Endpoints
- A route’s resolved (snapped) endpoints for one solve or reconstruction pass.
- Laid
- A wire laid through a lattice: the corner list its geometry implies, and whether every leg found a path. One that did not is its fallback L, which is still what the wire settles on — the corners are the L’s.
- LegRules
- What a leg is judged by: the obstacles, and what a straight leg running through one of them means to the pass.
- Obstacles
- The obstacle rectangles of a block, for the cheap “does a straight wire cross
a block?” test that decides whether a leg can stay straight. Mirrors exactly
the rects
build_closed_router_for_blockfeeds to the router as blocks, so a straight leg judged clear here is the same one the router would leave alone — but without paying to build the routing graph (the point of the fast load path).
Enums§
- Blocked
Leg 🔒 - What a straight leg that runs through a block means to a pass.
- Reconstruction 🔒
- What reconstructing one wire came to.
Functions§
- axis_
aligned 🔒 - collinear 🔒
- Whether
blies on the straight line throughaandc(zero cross product). For the axis-aligned corners we deal with, this meansa,b,cshare a row or column. - corner_
positions 🔒 - A route’s authored corners in the presentation layer’s grid vocabulary — the one conversion the reconstruction pass makes, so the leg walk below speaks a single coordinate type.
- corners_
of - Reduce a polyline to its corners: drop adjacent duplicate points and any point collinear with its neighbours (a redundant interior point on a straight run). Keeps the first and last points and only the true direction-change vertices — the canonical corner set the model stores as waypoints. Idempotent.
- edges_
of 🔒 - The polyline’s segments as presentation edges.
- geometry_
corners - The canonical corner polyline of solved geometry, endpoints included.
- interior_
waypoints 🔒 - The corners a canonical polyline
[start, corners…, end]implies as waypoints, in path order,lockediff one already sat there. - locked_
corners 🔒 - Where the user pinned a corner, so a rebuild can keep it pinned.
- promote_
corners_ to_ waypoints - Every corner of the wire’s polyline as a waypoint, in path order — the
invariant the explicit-path model relies on. Derives the list from the
route’s current edge geometry: each interior bend becomes a waypoint,
preserving the
lockedflag of any existing waypoint already at that position (so user-pinned corners stay pinned) and marking the rest structural (locked: false). The endpoints are never waypoints. The returned list is what the gesture’s commit stores; the geometry is rebuilt in place. - reconstruct_
corners_ direct - Rebuild a wire’s edges from its corner list (start + corners + end) as axis-aligned segments WITHOUT the router: a straight leg is one edge; a diagonal leg (its two endpoints share no row or column) becomes an L via a single bend. It never consults obstacles and never promotes bends to waypoints, so dragging a segment or corner repositions the wire directly and never triggers an autoroute — the segment goes exactly where the user puts it. The corner list is a read, so per-frame recomputation stays accumulation-free and the route editor’s drag keeps owning it.
- reconstruct_
legs 🔒 - Rebuild the edge geometry of a wire whose authored corners are
stored, keeping every straight (axis-aligned, unblocked) leg as a single edge and routing ONLY the legs that are non-colinear or blocked.start/endare the resolved grid endpoints. Straight legs never touch the router, so an unaffected route (all legs straight) is reconstructed byte-identically with zero pathfinding. - reconstruct_
route - Reconstruct a wire through
lattice, which is occupied by the wires around it. A leg the lattice holds no path for falls back to an L that ignores it, and theLaid::resolutionsays so. - straighten_
route - Reconstruct a wire without a lattice: the corner list its geometry implies,
or
None— with nothing written — when a leg needsreconstruct_route: one that is non-colinear, or hugs a block, or (under the rider’srules) runs through one. - write_
geometry 🔒 - Overwrite the solved geometry from the canonical corner polyline
path([start, corners…, end]) and return the waypoint list that polyline promotes: interior corners in path order,lockediff they coincide with a previously locked corner. The list is the caller’s to push as an op — the solver writes geometry, never the document.