Skip to main content

Module wire_harness

Module wire_harness 

Source
Expand description

Wire-harness routing: the document’s wireHarness block, the sided port graph, per-connection routes and the bundle solids — solved at the tail of every run like assembly (see wire_harness.rs). Wire harness — the document’s wireHarness block, the SIDED port graph, per-connection routing, and the bundle solids. Solved at the tail of every history run (like assembly), against the ports and spline segments the run published.

§The wireHarness block

{ connections: [{ id, name, from, to, diameter }], idCounter, buildBundles, cutMargin } on the history request, round-tripped through the saved document. from / to are PORT FEATURE IDS (references are ids, never labels — the panel shows the ports’ portNames and stores their ids). idCounter mints wire-N ids monotonically, like the feature counter. buildBundles (default true) switches the bundle solids off while keeping the routing. cutMargin (default 0, omitted at 0) is the amount the BOM adds to every wire’s routed length to give its cut length; the router never reads it.

§The network

  • A port is a PORT feature’s PortRecord: a point and a unit direction. Every port has two SIDES: A along the direction, B against it. A wire that enters a port on one side must leave it on the other — that is the whole routing rule, and what makes a waypoint a pass-through rather than a junction box.
  • A segment is a SPLINE feature whose first and last anchors attach to two DIFFERENT ports. The kernel builds the curve from the ports’ live placements (features/spline.rs), so the segment’s geometry is authoritative: the PHYSICAL side a segment occupies at each port is read off the curve’s end tangent — sign(t_out · dir) at the first port, sign(−t_in · dir) at the last (the wire ARRIVES from the opposite half-space, so an anchor attached on side A at the end of a spline sits on the port’s side B). The stored attachment side is how the spline was authored; the tangent is where the wire actually is.
  • Segment weight = the chain’s arc length.

§The sided digraph (the retired sided_ab_graphs builder, kept exactly)

Nodes are {port}/A and {port}/B. A segment joining P/X to Q/Y adds two directed edges: P/X → Q/inv(Y) and Q/Y → P/inv(X), with inv(A) = B. Reading an edge as “leave P through X, arrive at Q on Y, and you are now poised to leave Q through inv(Y)” is what encodes the pass- through rule. A connection routes from {from}/A or {from}/B to {to}/A or {to}/B (four Dijkstra queries, the shortest wins). A route that visits the same port twice is refused and the constrained best-first search (state = node + visited-port set) runs instead; if that finds nothing either the connection stays unrouted with the port-reuse status. Endpoints must be terminations (a waypoint is a pass-through, never a cable end).

§Bundles

Every routed connection contributes its diameter to each segment it crosses. A segment’s bundle diameter is sqrt(Σ d² / 0.75) · 1.1 (a 75 % packing efficiency and a 10 % safety factor — the established formula), and its solid is a circle of that diameter swept along the spline’s exact chain (sweep_profile_along_chain_with_stations), named WireHarness:{spline} with faces …:Wall0, …:Wall1, …:Start, …:End. The bundle solids ride an extra FeatureResult (id WIRE_HARNESS_FEATURE_ID, type WIRE_HARNESS_FEATURE_TYPE) appended to the run’s results, so the display pipeline shows them through the standard solid path (rendering requirement R31). A bundle that fails to build reports its error on the bundle row and never halts the run.

§Caching

The tail caches its last outcome per thread against a fingerprint of the block + the network (port records + segment chains): an unchanged harness replays (reused, the same resident handles) instead of re-sweeping — which keeps the main-thread execute_history replays the engine makes for consumed-name / assembly sync cheap. A changed fingerprint frees the old bundle handles before building; clear_history_cache frees them too.

Structs§

Attachment
A spline anchor’s port attachment: { portRef, side } under the anchor’s attachment key. side defaults to A when absent.
RouteResult
One connection’s route.
WireHarnessBundle
One segment’s bundle.
WireHarnessConnection
One wire: its id, display name, endpoint PORT ids and diameter.
WireHarnessEndpoint
A connection point as an endpoint choice.
WireHarnessReport
The routing outcome of one run.
WireHarnessSegment
A network segment: the spline id, its two ports with the PHYSICAL side the wire occupies at each, and its length.
WireHarnessState
The document’s wireHarness block.

Enums§

BundleStatus
Why a segment’s bundle solid is or is not there.
PortSide
A port side: A along the port direction, B against it.
RouteStatus
Why a connection is or is not routed.

Constants§

BUNDLE_SOLID_PREFIX
The prefix of every bundle solid name (WireHarness:{spline id}).
WIRE_HARNESS_FEATURE_ID
The id of the appended tail result (and the creator the display pipeline records for every bundle solid). Never a history feature.
WIRE_HARNESS_FEATURE_TYPE
The type of the appended tail result.

Functions§

bundle_diameter
The bundle diameter for a set of wire diameters: sqrt(Σ d² / 0.75) · 1.1 — 75 % packing efficiency and a 10 % safety factor. Zero for no wires.
clear_cache
Free the cached bundle solids (a document switch, or a rebuild).