hrithik18k/metal-touch-panel
A PCB autorouting wrapper that corrects footprint-trace obstacle dimensions, solves routes with a preloaded trace-graph solver, and reports completed traces or routing errors.
- Version
- 1.0.0
- License
- unset
- Stars
- 0
evidence/recheck-2026-09-30/latest-packages/replay-via.mjs
import fs from 'node:fs';
import {AutoroutingPipelineSolver9_PreloadedTraceGraph} from '@tscircuit/capacity-autorouter';
const input=JSON.parse(fs.readFileSync('via-input.json','utf8'));
// Same correction as the original board's adapter, not a solver patch.
for(const o of input.obstacles)if(o.connectedTo?.some(id=>/^pcb_trace_[0-3]$/.test(id))){
if(o.width===0.1){o.width=0.2;o.height+=0.2}
else if(o.height===0.1){o.height=0.2;o.width+=0.2}
}
fs.writeFileSync('via-corrected-input.json',JSON.stringify(input,null,2));
const solver=new AutoroutingPipelineSolver9_PreloadedTraceGraph(input);
const start=Date.now();
while(!solver.solved&&!solver.failed&&Date.now()-start<90000)solver.step();
const result={solved:solver.solved,failed:solver.failed,error:solver.error,elapsedMs:Date.now()-start,violations:[]};
if(solver.solved){
const out=solver.getOutputSimpleRouteJson();
fs.writeFileSync('via-new-output.json',JSON.stringify(out,null,2));
// Check the exact foreign-net GND pad used by the saved failure.
const old=JSON.parse(fs.readFileSync('via-old-result.json','utf8'));
const ground=old.find(e=>e.type==='pcb_smtpad'&&e.pcb_smtpad_id==='pcb_smtpad_9');
result.groundPad=ground;
for(const t of out.traces??[])if(t.connection_name==='source_net_1'||t.pcb_trace_id?.startsWith('source_net_1_')){
for(const p of t.route)if(p.route_type==='via'){
const dx=Math.max(Math.abs(p.x-ground.x)-ground.width/2,0);
const dy=Math.max(Math.abs(p.y-ground.y)-ground.height/2,0);
const gap=Math.hypot(dx,dy)-(p.via_diameter??input.minViaPadDiameter)/2;
if(gap<0.1-1e-6)result.violations.push({trace:t.pcb_trace_id,via:p,gap});
}
}
}
fs.writeFileSync('via-replay-result.json',JSON.stringify(result,null,2));console.log(JSON.stringify(result,null,2));
