@tscircuit/capacity-autorouter 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +65 -30
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -4287,6 +4287,66 @@ var NetToPointPairsSolver = class extends BaseSolver {
|
|
|
4287
4287
|
}
|
|
4288
4288
|
};
|
|
4289
4289
|
|
|
4290
|
+
// lib/utils/convertHdRouteToSimplifiedRoute.ts
|
|
4291
|
+
var convertHdRouteToSimplifiedRoute = (hdRoute, layerCount) => {
|
|
4292
|
+
const result = [];
|
|
4293
|
+
if (hdRoute.route.length === 0) return result;
|
|
4294
|
+
const mapZToLayerName = (z) => {
|
|
4295
|
+
if (z < 0 || z >= layerCount) {
|
|
4296
|
+
throw new Error(`Invalid z "${z}" for layer count: ${layerCount}`);
|
|
4297
|
+
}
|
|
4298
|
+
if (z === 0) return "top";
|
|
4299
|
+
if (z === layerCount - 1) return "bottom";
|
|
4300
|
+
return `inner${z}`;
|
|
4301
|
+
};
|
|
4302
|
+
let currentLayerPoints = [];
|
|
4303
|
+
let currentZ = hdRoute.route[0].z;
|
|
4304
|
+
for (let i = 0; i < hdRoute.route.length; i++) {
|
|
4305
|
+
const point = hdRoute.route[i];
|
|
4306
|
+
if (point.z !== currentZ) {
|
|
4307
|
+
const layerName2 = mapZToLayerName(currentZ);
|
|
4308
|
+
for (const layerPoint of currentLayerPoints) {
|
|
4309
|
+
result.push({
|
|
4310
|
+
route_type: "wire",
|
|
4311
|
+
x: layerPoint.x,
|
|
4312
|
+
y: layerPoint.y,
|
|
4313
|
+
width: hdRoute.traceThickness,
|
|
4314
|
+
layer: layerName2
|
|
4315
|
+
});
|
|
4316
|
+
}
|
|
4317
|
+
const viaExists = hdRoute.vias.some(
|
|
4318
|
+
(via) => Math.abs(via.x - point.x) < 1e-3 && Math.abs(via.y - point.y) < 1e-3
|
|
4319
|
+
);
|
|
4320
|
+
if (viaExists) {
|
|
4321
|
+
const fromLayer = mapZToLayerName(point.z);
|
|
4322
|
+
const toLayer = mapZToLayerName(point.z);
|
|
4323
|
+
result.push({
|
|
4324
|
+
route_type: "via",
|
|
4325
|
+
x: point.x,
|
|
4326
|
+
y: point.y,
|
|
4327
|
+
from_layer: fromLayer,
|
|
4328
|
+
to_layer: toLayer
|
|
4329
|
+
});
|
|
4330
|
+
}
|
|
4331
|
+
currentLayerPoints = [point];
|
|
4332
|
+
currentZ = point.z;
|
|
4333
|
+
} else {
|
|
4334
|
+
currentLayerPoints.push(point);
|
|
4335
|
+
}
|
|
4336
|
+
}
|
|
4337
|
+
const layerName = mapZToLayerName(currentZ);
|
|
4338
|
+
for (const layerPoint of currentLayerPoints) {
|
|
4339
|
+
result.push({
|
|
4340
|
+
route_type: "wire",
|
|
4341
|
+
x: layerPoint.x,
|
|
4342
|
+
y: layerPoint.y,
|
|
4343
|
+
width: hdRoute.traceThickness,
|
|
4344
|
+
layer: layerName
|
|
4345
|
+
});
|
|
4346
|
+
}
|
|
4347
|
+
return result;
|
|
4348
|
+
};
|
|
4349
|
+
|
|
4290
4350
|
// lib/solvers/CapacityMeshSolver/CapacityMeshSolver.ts
|
|
4291
4351
|
var CapacityMeshSolver = class extends BaseSolver {
|
|
4292
4352
|
constructor(srj, opts = {}) {
|
|
@@ -4509,39 +4569,14 @@ var CapacityMeshSolver = class extends BaseSolver {
|
|
|
4509
4569
|
throw new Error("Cannot get output before solving is complete");
|
|
4510
4570
|
}
|
|
4511
4571
|
const traces = [];
|
|
4512
|
-
for (const
|
|
4513
|
-
const
|
|
4514
|
-
const originalConnectionName = this.getOriginalConnectionName(
|
|
4515
|
-
route.connectionName
|
|
4516
|
-
);
|
|
4572
|
+
for (const hdRoute of this.highDensityRouteSolver.routes) {
|
|
4573
|
+
const pointPairConnName = hdRoute.connectionName;
|
|
4517
4574
|
const trace = {
|
|
4518
4575
|
type: "pcb_trace",
|
|
4519
|
-
pcb_trace_id:
|
|
4520
|
-
connection_name:
|
|
4521
|
-
route:
|
|
4576
|
+
pcb_trace_id: pointPairConnName,
|
|
4577
|
+
connection_name: this.getOriginalConnectionName(pointPairConnName),
|
|
4578
|
+
route: convertHdRouteToSimplifiedRoute(hdRoute, 2)
|
|
4522
4579
|
};
|
|
4523
|
-
let currentLayer = simplifiedRoute[0]?.z.toString() || "0";
|
|
4524
|
-
for (let i = 0; i < simplifiedRoute.length; i++) {
|
|
4525
|
-
const point = simplifiedRoute[i];
|
|
4526
|
-
const nextLayerStr = point.z.toString();
|
|
4527
|
-
if (nextLayerStr !== currentLayer) {
|
|
4528
|
-
trace.route.push({
|
|
4529
|
-
route_type: "via",
|
|
4530
|
-
x: point.x,
|
|
4531
|
-
y: point.y,
|
|
4532
|
-
from_layer: this.mapLayer(currentLayer),
|
|
4533
|
-
to_layer: this.mapLayer(nextLayerStr)
|
|
4534
|
-
});
|
|
4535
|
-
currentLayer = nextLayerStr;
|
|
4536
|
-
}
|
|
4537
|
-
trace.route.push({
|
|
4538
|
-
route_type: "wire",
|
|
4539
|
-
x: point.x,
|
|
4540
|
-
y: point.y,
|
|
4541
|
-
width: route.traceThickness || this.highDensityRouteSolver.defaultTraceThickness,
|
|
4542
|
-
layer: this.mapLayer(currentLayer)
|
|
4543
|
-
});
|
|
4544
|
-
}
|
|
4545
4580
|
traces.push(trace);
|
|
4546
4581
|
}
|
|
4547
4582
|
return {
|