@tscircuit/autorouting-cache-engine
Advanced tools
Comparing version
@@ -6,9 +6,8 @@ // lib/convertCircuitJsonToNormalizedAutoroutingJson.ts | ||
var getBoundsOfRegionOfInterest = (circuitJson) => { | ||
const allPoints = circuitJson.filter((el) => el.type === "source_trace").flatMap( | ||
(trace) => trace.connected_source_port_ids.flatMap( | ||
(portId) => circuitJson.filter( | ||
(el) => el.type === "pcb_port" && el.source_port_id === portId | ||
) | ||
) | ||
).map((port) => ({ x: port.x, y: port.y })); | ||
const allPoints = circuitJson.flatMap((el) => { | ||
if (el.type === "pcb_port") { | ||
return [{ x: el.x, y: el.y }]; | ||
} | ||
return []; | ||
}); | ||
const minX = Math.min(...allPoints.map((p) => p.x)); | ||
@@ -15,0 +14,0 @@ const maxX = Math.max(...allPoints.map((p) => p.x)); |
@@ -13,13 +13,8 @@ import type { CircuitJson } from "circuit-json" | ||
} => { | ||
// Collect all trace points from source traces and their connected ports | ||
const allPoints = circuitJson | ||
.filter((el) => el.type === "source_trace") | ||
.flatMap((trace) => | ||
trace.connected_source_port_ids.flatMap((portId) => | ||
circuitJson.filter( | ||
(el) => el.type === "pcb_port" && el.source_port_id === portId, | ||
), | ||
), | ||
) | ||
.map((port: any) => ({ x: port.x, y: port.y })) | ||
const allPoints = circuitJson.flatMap((el) => { | ||
if (el.type === "pcb_port") { | ||
return [{ x: el.x, y: el.y }] | ||
} | ||
return [] | ||
}) | ||
@@ -26,0 +21,0 @@ // Calculate bounds |
{ | ||
"name": "@tscircuit/autorouting-cache-engine", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"repository": "https://github.com/tscircuit/autorouting-cache-engine", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -16,3 +16,3 @@ import { test, expect } from "bun:test" | ||
expect(cacheKey1).toMatchInlineSnapshot(`"3af4d29e4d3a95accf5706cdde360628"`) | ||
expect(cacheKey1).toMatchInlineSnapshot(`"8aa5ab39715209b8f79a1c70216f6522"`) | ||
@@ -22,4 +22,4 @@ expect(cacheKey1).toEqual(cacheKey2) | ||
expect(longString1).toMatchInlineSnapshot( | ||
`"{"allowed_layers":1,"nets_to_route":[1],"sorted_normalized_objects":[{"height":"0.60","layers":["top"],"net":null,"type":"rect_pad","width":"0.60","x":"-2.00","y":"0.00"},{"height":"0.60","layers":["top"],"net":1,"type":"rect_pad","width":"0.60","x":"-3.00","y":"0.00"},{"height":"0.60","layers":["top"],"net":1,"type":"rect_pad","width":"0.60","x":"3.00","y":"0.00"},{"height":"0.60","layers":["top"],"net":null,"type":"rect_pad","width":"0.60","x":"4.00","y":"0.00"},{"net":1,"route_segments":[{"layer":"top","x1":"-0.70","x2":"-0.70","y1":"0.00","y2":"1.30"},{"layer":"top","x1":"-0.70","x2":"-3.00","y1":"1.30","y2":"1.30"},{"layer":"top","x1":"-3.00","x2":"-3.00","y1":"1.30","y2":"0.00"},{"layer":"top","x1":"3.00","x2":"-0.70","y1":"0.00","y2":"0.00"}],"type":"trace","vias":[]}]}"`, | ||
`"{"allowed_layers":1,"nets_to_route":[1],"sorted_normalized_objects":[{"height":"0.60","layers":["top"],"net":null,"type":"rect_pad","width":"0.60","x":"-2.50","y":"0.00"},{"height":"0.60","layers":["top"],"net":1,"type":"rect_pad","width":"0.60","x":"-3.50","y":"0.00"},{"height":"0.60","layers":["top"],"net":1,"type":"rect_pad","width":"0.60","x":"2.50","y":"0.00"},{"height":"0.60","layers":["top"],"net":null,"type":"rect_pad","width":"0.60","x":"3.50","y":"0.00"},{"net":1,"route_segments":[{"layer":"top","x1":"-1.20","x2":"-1.20","y1":"0.00","y2":"1.30"},{"layer":"top","x1":"-1.20","x2":"-3.50","y1":"1.30","y2":"1.30"},{"layer":"top","x1":"-3.50","x2":"-3.50","y1":"1.30","y2":"0.00"},{"layer":"top","x1":"2.50","x2":"-1.20","y1":"0.00","y2":"0.00"}],"type":"trace","vias":[]}]}"`, | ||
) | ||
}) |
@@ -28,3 +28,3 @@ import { test, expect } from "bun:test" | ||
"width": "0.60", | ||
"x": "-2.00", | ||
"x": "-2.50", | ||
"y": "0.00", | ||
@@ -40,3 +40,3 @@ }, | ||
"width": "0.60", | ||
"x": "-3.00", | ||
"x": "-3.50", | ||
"y": "0.00", | ||
@@ -52,3 +52,3 @@ }, | ||
"width": "0.60", | ||
"x": "3.00", | ||
"x": "2.50", | ||
"y": "0.00", | ||
@@ -64,3 +64,3 @@ }, | ||
"width": "0.60", | ||
"x": "4.00", | ||
"x": "3.50", | ||
"y": "0.00", | ||
@@ -73,4 +73,4 @@ }, | ||
"layer": "top", | ||
"x1": "-0.70", | ||
"x2": "-0.70", | ||
"x1": "-1.20", | ||
"x2": "-1.20", | ||
"y1": "0.00", | ||
@@ -81,4 +81,4 @@ "y2": "1.30", | ||
"layer": "top", | ||
"x1": "-0.70", | ||
"x2": "-3.00", | ||
"x1": "-1.20", | ||
"x2": "-3.50", | ||
"y1": "1.30", | ||
@@ -89,4 +89,4 @@ "y2": "1.30", | ||
"layer": "top", | ||
"x1": "-3.00", | ||
"x2": "-3.00", | ||
"x1": "-3.50", | ||
"x2": "-3.50", | ||
"y1": "1.30", | ||
@@ -97,4 +97,4 @@ "y2": "0.00", | ||
"layer": "top", | ||
"x1": "3.00", | ||
"x2": "-0.70", | ||
"x1": "2.50", | ||
"x2": "-1.20", | ||
"y1": "0.00", | ||
@@ -101,0 +101,0 @@ "y2": "0.00", |
@@ -83,49 +83,49 @@ import { test, expect } from "bun:test" | ||
expect(circuit1SpaceTraces).toMatchInlineSnapshot(` | ||
[ | ||
{ | ||
"pcb_trace_id": "pcb_trace_0", | ||
"route": [ | ||
[ | ||
{ | ||
"layer": "top", | ||
"route_type": "wire", | ||
"start_pcb_port_id": "pcb_port_0", | ||
"width": 0.16, | ||
"x": 5.5, | ||
"y": 0, | ||
"pcb_trace_id": "pcb_trace_0", | ||
"route": [ | ||
{ | ||
"layer": "top", | ||
"route_type": "wire", | ||
"start_pcb_port_id": "pcb_port_0", | ||
"width": 0.16, | ||
"x": 5.5, | ||
"y": 0, | ||
}, | ||
{ | ||
"layer": "top", | ||
"route_type": "wire", | ||
"width": 0.16, | ||
"x": 1.7999999999999998, | ||
"y": 0, | ||
}, | ||
{ | ||
"layer": "top", | ||
"route_type": "wire", | ||
"width": 0.16, | ||
"x": 1.7999999999999998, | ||
"y": 1.3, | ||
}, | ||
{ | ||
"layer": "top", | ||
"route_type": "wire", | ||
"width": 0.16, | ||
"x": -0.5, | ||
"y": 1.3, | ||
}, | ||
{ | ||
"end_pcb_port_id": "pcb_port_2", | ||
"layer": "top", | ||
"route_type": "wire", | ||
"width": 0.16, | ||
"x": -0.5, | ||
"y": 0, | ||
}, | ||
], | ||
"source_trace_id": "source_trace_0", | ||
"type": "pcb_trace", | ||
}, | ||
{ | ||
"layer": "top", | ||
"route_type": "wire", | ||
"width": 0.16, | ||
"x": 1.7999999999999998, | ||
"y": 0, | ||
}, | ||
{ | ||
"layer": "top", | ||
"route_type": "wire", | ||
"width": 0.16, | ||
"x": 1.7999999999999998, | ||
"y": 1.3, | ||
}, | ||
{ | ||
"layer": "top", | ||
"route_type": "wire", | ||
"width": 0.16, | ||
"x": -0.5, | ||
"y": 1.3, | ||
}, | ||
{ | ||
"end_pcb_port_id": "pcb_port_2", | ||
"layer": "top", | ||
"route_type": "wire", | ||
"width": 0.16, | ||
"x": -0.5, | ||
"y": 0, | ||
}, | ||
], | ||
"source_trace_id": "source_trace_0", | ||
"type": "pcb_trace", | ||
}, | ||
] | ||
`) | ||
] | ||
`) | ||
@@ -132,0 +132,0 @@ expect(circuit1SpaceTraces).toEqual( |
Sorry, the diff of this file is not supported yet
639296
1.76%44
4.76%19992
2.09%