Skip to main content

Module reconstruct

Module reconstruct 

Source
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_block feeds 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§

BlockedLeg 🔒
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 b lies on the straight line through a and c (zero cross product). For the axis-aligned corners we deal with, this means a, b, c share 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, locked iff 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 locked flag 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/end are 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 the Laid::resolution says so.
straighten_route
Reconstruct a wire without a lattice: the corner list its geometry implies, or None — with nothing written — when a leg needs reconstruct_route: one that is non-colinear, or hugs a block, or (under the rider’s rules) 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, locked iff 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.