Skip to content

Commit

Permalink
fix: pcb_trace_id unique for the same wire segment
Browse files Browse the repository at this point in the history
  • Loading branch information
imrishabh18 committed Feb 10, 2025
1 parent 52aba3f commit 83e64f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ export function convertDsnSessionToCircuitJson(
}

const sessionElements: AnyCircuitElement[] = []
const routeSegments: Array<PcbTrace | SourceTrace> = []

// Process nets for vias and wires
for (const net of dsnSession.routes.network_out.nets) {
Expand All @@ -87,18 +86,10 @@ export function convertDsnSessionToCircuitJson(
// Process wires and vias together in routes
net.wires?.forEach((wire, wireIdx) => {
if ("path" in wire) {
routeSegments.push(
...convertWiringPathToPcbTraces({
wire,
transformUmToMm,
netName: net.name,
}),
)

const traces = convertWiringPathToPcbTraces({
wire,
transformUmToMm,
netName: net.name,
netName: `${net.name}_${wireIdx}`,
})

// Update trace IDs to maintain proper linkage
Expand Down
9 changes: 8 additions & 1 deletion tests/dsn-pcb/convert-session-to-circuit-json.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { convertCircuitJsonToPcbSvg } from "circuit-to-svg"
import { convertDsnJsonToCircuitJson } from "../../lib/dsn-pcb/dsn-json-to-circuit-json/convert-dsn-json-to-circuit-json.ts"
import { expect, test } from "bun:test"
import {
parseDsnToDsnJson,
Expand All @@ -21,6 +20,7 @@ import pcbDsnFile from "../assets/freerouting-sessions/circuit1.dsn" with {
import { circuitJsonToTable } from "../debug-utils/circuit-json-to-table.ts"
import { sessionFileToTable } from "../debug-utils/index.ts"
import Debug from "debug"
import { su } from "@tscircuit/soup-util"

test("convert session to circuit json", async () => {
const debug = Debug("tscircuit:dsn-converter")
Expand All @@ -33,6 +33,13 @@ test("convert session to circuit json", async () => {
sessionJson,
)

const pcb_traces = su(circuitJsonFromSession).pcb_trace.list()
const pcb_traces_by_id = [
...new Set(pcb_traces.map((trace) => trace.pcb_trace_id)),
]

expect(pcb_traces_by_id.length).toBe(3)

if (debug.enabled) {
circuitJsonToTable(
circuitJson,
Expand Down

0 comments on commit 83e64f1

Please sign in to comment.