Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@
*
* Crossings (middle-to-middle intersections) are handled by computeCrossings()
* and are not included as junctions here.
*
* Optional network-awareness: callers may provide `opts.shouldConnect(traceIdA, traceIdB, atPoint)`
* to veto junction creation between traces that are not electrically connected (e.g. different nets).
* When omitted, all geometric T/endpoint junctions are produced as before.
*/
export function computeJunctions(
traces: TraceEdges[],
Expand All @@ -142,22 +146,25 @@
const result: Record<string, Array<{ x: number; y: number }>> = {}
for (const t of traces) result[t.source_trace_id] = []

// Precompute endpoints for each trace
const endpointsByTrace = traces.map((t) => {
const pts: Array<{ x: number; y: number }> = []
for (const e of t.edges) {
pts.push(e.from, e.to)
}
return dedupePoints(pts, tol)
})

for (let i = 0; i < traces.length; i++) {
const A = traces[i]
const AEnds = endpointsByTrace[i]
const AEnds = dedupePoints(
A.edges.flatMap((e) => [e.from, e.to]),
tol,
)
for (let j = i + 1; j < traces.length; j++) {
const B = traces[j]
const BEnds = endpointsByTrace[j]

Check failure on line 157 in lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/compute-junctions.ts

View workflow job for this annotation

GitHub Actions / test

ReferenceError: endpointsByTrace is not defined

at computeJunctions (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/compute-junctions.ts:157:21) at applyTracesFromSolverOutput (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/applyTracesFromSolverOutput.ts:95:25) at Group_doInitialSchematicTraceRender (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/Group_doInitialSchematicTraceRender.ts:57:3) at doInitialSchematicTraceRender (/home/runner/work/core/core/lib/components/primitive-components/Group/Group.ts:643:5) at runRenderPhase (/home/runner/work/core/core/lib/components/base-components/Renderable.ts:329:34) at runRenderCycle (/home/runner/work/core/core/lib/components/base-components/Renderable.ts:271:12) at render (/home/runner/work/core/core/lib/RootCircuit.ts:137:16) at <anonymous> (/home/runner/work/core/core/tests/examples/example5-simple-circuit.test.tsx:48:11) at <anonymous> (/home/runner/work/core/core/tests/examples/example5-simple-circuit.test.tsx:4:76)

Check failure on line 157 in lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/compute-junctions.ts

View workflow job for this annotation

GitHub Actions / test

ReferenceError: endpointsByTrace is not defined

at computeJunctions (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/compute-junctions.ts:157:21) at applyTracesFromSolverOutput (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/applyTracesFromSolverOutput.ts:95:25) at Group_doInitialSchematicTraceRender (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/Group_doInitialSchematicTraceRender.ts:57:3) at doInitialSchematicTraceRender (/home/runner/work/core/core/lib/components/primitive-components/Group/Group.ts:643:5) at runRenderPhase (/home/runner/work/core/core/lib/components/base-components/Renderable.ts:329:34) at runRenderCycle (/home/runner/work/core/core/lib/components/base-components/Renderable.ts:271:12) at render (/home/runner/work/core/core/lib/RootCircuit.ts:137:16) at renderUntilSettled (/home/runner/work/core/core/lib/RootCircuit.ts:150:10) at renderUntilSettled (/home/runner/work/core/core/lib/RootCircuit.ts:141:45) at <anonymous> (/home/runner/work/core/core/tests/examples/example29-copper-pour.test.tsx:48:17)

Check failure on line 157 in lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/compute-junctions.ts

View workflow job for this annotation

GitHub Actions / test

ReferenceError: endpointsByTrace is not defined

at computeJunctions (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/compute-junctions.ts:157:21) at applyTracesFromSolverOutput (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/applyTracesFromSolverOutput.ts:95:25) at Group_doInitialSchematicTraceRender (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/Group_doInitialSchematicTraceRender.ts:57:3) at doInitialSchematicTraceRender (/home/runner/work/core/core/lib/components/primitive-components/Group/Group.ts:643:5) at runRenderPhase (/home/runner/work/core/core/lib/components/base-components/Renderable.ts:329:34) at runRenderCycle (/home/runner/work/core/core/lib/components/base-components/Renderable.ts:271:12) at render (/home/runner/work/core/core/lib/RootCircuit.ts:137:16) at <anonymous> (/home/runner/work/core/core/tests/examples/example28-elbow.test.tsx:53:11)

Check failure on line 157 in lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/compute-junctions.ts

View workflow job for this annotation

GitHub Actions / test

ReferenceError: endpointsByTrace is not defined

at computeJunctions (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/compute-junctions.ts:157:21) at applyTracesFromSolverOutput (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/applyTracesFromSolverOutput.ts:95:25) at Group_doInitialSchematicTraceRender (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/Group_doInitialSchematicTraceRender.ts:57:3) at doInitialSchematicTraceRender (/home/runner/work/core/core/lib/components/primitive-components/Group/Group.ts:643:5) at runRenderPhase (/home/runner/work/core/core/lib/components/base-components/Renderable.ts:329:34) at runRenderCycle (/home/runner/work/core/core/lib/components/base-components/Renderable.ts:271:12) at render (/home/runner/work/core/core/lib/RootCircuit.ts:137:16) at renderUntilSettled (/home/runner/work/core/core/lib/RootCircuit.ts:150:10) at renderUntilSettled (/home/runner/work/core/core/lib/RootCircuit.ts:141:45) at <anonymous> (/home/runner/work/core/core/tests/examples/example33-3d-pinheader-jumper.test.tsx:17:17)

Check failure on line 157 in lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/compute-junctions.ts

View workflow job for this annotation

GitHub Actions / test

ReferenceError: endpointsByTrace is not defined

at computeJunctions (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/compute-junctions.ts:157:21) at applyTracesFromSolverOutput (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/applyTracesFromSolverOutput.ts:95:25) at Group_doInitialSchematicTraceRender (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/Group_doInitialSchematicTraceRender.ts:57:3) at doInitialSchematicTraceRender (/home/runner/work/core/core/lib/components/primitive-components/Group/Group.ts:643:5) at runRenderPhase (/home/runner/work/core/core/lib/components/base-components/Renderable.ts:329:34) at runRenderCycle (/home/runner/work/core/core/lib/components/base-components/Renderable.ts:271:12) at render (/home/runner/work/core/core/lib/RootCircuit.ts:137:16) at <anonymous> (/home/runner/work/core/core/tests/examples/example22-trace-out-of-board-error-with-outline.test.tsx:40:17) at <anonymous> (/home/runner/work/core/core/tests/examples/example22-trace-out-of-board-error-with-outline.test.tsx:3:57)

Check failure on line 157 in lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/compute-junctions.ts

View workflow job for this annotation

GitHub Actions / test

ReferenceError: endpointsByTrace is not defined

at computeJunctions (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/compute-junctions.ts:157:21) at applyTracesFromSolverOutput (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/applyTracesFromSolverOutput.ts:95:25) at Group_doInitialSchematicTraceRender (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/Group_doInitialSchematicTraceRender.ts:57:3) at doInitialSchematicTraceRender (/home/runner/work/core/core/lib/components/primitive-components/Group/Group.ts:643:5) at runRenderPhase (/home/runner/work/core/core/lib/components/base-components/Renderable.ts:329:34) at runRenderCycle (/home/runner/work/core/core/lib/components/base-components/Renderable.ts:271:12) at render (/home/runner/work/core/core/lib/RootCircuit.ts:137:16) at renderUntilSettled (/home/runner/work/core/core/lib/RootCircuit.ts:150:10) at renderUntilSettled (/home/runner/work/core/core/lib/RootCircuit.ts:141:45) at <anonymous> (/home/runner/work/core/core/tests/examples/example29-pcb_component_outside_board_error.test.tsx:30:17)

Check failure on line 157 in lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/compute-junctions.ts

View workflow job for this annotation

GitHub Actions / test

ReferenceError: endpointsByTrace is not defined

at computeJunctions (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/compute-junctions.ts:157:21) at applyTracesFromSolverOutput (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/applyTracesFromSolverOutput.ts:95:25) at Group_doInitialSchematicTraceRender (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/Group_doInitialSchematicTraceRender.ts:57:3) at doInitialSchematicTraceRender (/home/runner/work/core/core/lib/components/primitive-components/Group/Group.ts:643:5) at runRenderPhase (/home/runner/work/core/core/lib/components/base-components/Renderable.ts:329:34) at runRenderCycle (/home/runner/work/core/core/lib/components/base-components/Renderable.ts:271:12) at render (/home/runner/work/core/core/lib/RootCircuit.ts:137:16) at <anonymous> (/home/runner/work/core/core/tests/examples/example10-schDisplayLabel.test.tsx:59:11) at <anonymous> (/home/runner/work/core/core/tests/examples/example10-schDisplayLabel.test.tsx:4:52)

Check failure on line 157 in lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/compute-junctions.ts

View workflow job for this annotation

GitHub Actions / test

ReferenceError: endpointsByTrace is not defined

at computeJunctions (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/compute-junctions.ts:157:21) at applyTracesFromSolverOutput (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/applyTracesFromSolverOutput.ts:95:25) at Group_doInitialSchematicTraceRender (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/Group_doInitialSchematicTraceRender.ts:57:3) at doInitialSchematicTraceRender (/home/runner/work/core/core/lib/components/primitive-components/Group/Group.ts:643:5) at runRenderPhase (/home/runner/work/core/core/lib/components/base-components/Renderable.ts:329:34) at runRenderCycle (/home/runner/work/core/core/lib/components/base-components/Renderable.ts:271:12) at render (/home/runner/work/core/core/lib/RootCircuit.ts:137:16) at <anonymous> (/home/runner/work/core/core/tests/examples/example1.test.tsx:49:11) at <anonymous> (/home/runner/work/core/core/tests/examples/example1.test.tsx:4:18)

Check failure on line 157 in lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/compute-junctions.ts

View workflow job for this annotation

GitHub Actions / test

ReferenceError: endpointsByTrace is not defined

at computeJunctions (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/compute-junctions.ts:157:21) at applyTracesFromSolverOutput (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/applyTracesFromSolverOutput.ts:95:25) at Group_doInitialSchematicTraceRender (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/Group_doInitialSchematicTraceRender.ts:57:3) at doInitialSchematicTraceRender (/home/runner/work/core/core/lib/components/primitive-components/Group/Group.ts:643:5) at runRenderPhase (/home/runner/work/core/core/lib/components/base-components/Renderable.ts:329:34) at runRenderCycle (/home/runner/work/core/core/lib/components/base-components/Renderable.ts:271:12) at render (/home/runner/work/core/core/lib/RootCircuit.ts:137:16) at <anonymous> (/home/runner/work/core/core/tests/examples/example11-net-symbol.test.tsx:99:11)

Check failure on line 157 in lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/compute-junctions.ts

View workflow job for this annotation

GitHub Actions / test

ReferenceError: endpointsByTrace is not defined

at computeJunctions (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/compute-junctions.ts:157:21) at applyTracesFromSolverOutput (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/applyTracesFromSolverOutput.ts:95:25) at Group_doInitialSchematicTraceRender (/home/runner/work/core/core/lib/components/primitive-components/Group/Group_doInitialSchematicTraceRender/Group_doInitialSchematicTraceRender.ts:57:3) at doInitialSchematicTraceRender (/home/runner/work/core/core/lib/components/primitive-components/Group/Group.ts:643:5) at runRenderPhase (/home/runner/work/core/core/lib/components/base-components/Renderable.ts:329:34) at runRenderCycle (/home/runner/work/core/core/lib/components/base-components/Renderable.ts:271:12) at render (/home/runner/work/core/core/lib/RootCircuit.ts:137:16) at getCircuitJson (/home/runner/work/core/core/lib/RootCircuit.ts:170:45) at <anonymous> (/home/runner/work/core/core/tests/examples/example3-3x3-keyboard.test.tsx:185:31)

// Opt-in net-aware junctions: applies only when either trace has the flag enabled
const netAware =
(A as any).__netAwareJunctions || (B as any).__netAwareJunctions
if (netAware) {
const netA = (A as any).subcircuit_connectivity_map_key
const netB = (B as any).subcircuit_connectivity_map_key
if (netA == null || netB == null || netA !== netB) continue
}

// Endpoint-to-endpoint junctions (only when forming a corner)
for (const pa of AEnds) {
for (const pb of BEnds) {
Expand Down
24 changes: 12 additions & 12 deletions tests/repros/__snapshots__/repro48-555-timer-schematic.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions tests/repros/repro48-555-timer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ test("repro48: 555 timer circuit", () => {

circuit.render()

const schematic = (circuit as any).schematic
const traces = schematic?.traces ?? []

for (const trace of traces) {
;(trace as any).__netAwareJunctions = true
}

expect(circuit).toMatchSchematicSnapshot(import.meta.path)
expect(circuit).toMatchPcbSnapshot(import.meta.path)
})
Loading