From 40d5f45bed8cae1f0ca6b7c2124ce419adda21ef Mon Sep 17 00:00:00 2001 From: mohan-bee Date: Wed, 5 Aug 2026 05:04:17 +0530 Subject: [PATCH 1/3] up --- .../ParallelAlignedPassiveSolver.ts | 6 ++++++ tests/offsetCollinearConnections.test.ts | 13 +++++++++++++ .../polarized-capacitor-auto-layout.snap.svg | 4 ++-- .../repro-bq24074-right-resistors.snap.svg | 2 +- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/solvers/PackInnerPartitionsSolver/ParallelAlignedPassiveSolver.ts b/lib/solvers/PackInnerPartitionsSolver/ParallelAlignedPassiveSolver.ts index 0e4bf715..43fc7f22 100644 --- a/lib/solvers/PackInnerPartitionsSolver/ParallelAlignedPassiveSolver.ts +++ b/lib/solvers/PackInnerPartitionsSolver/ParallelAlignedPassiveSolver.ts @@ -41,6 +41,7 @@ import { getBoundsCenter, getBoundsFromPoints, } from "@tscircuit/math-utils" +import { applyDirectPassiveTraceClearance } from "../../utils/offsetCollinearConnections" const CLEARANCE_EPSILON = 1e-6 const MAX_RESOLVE_ITERATIONS = 16 @@ -111,6 +112,11 @@ export class ParallelAlignedPassiveSolver extends BaseSolver { )) { this.reflowPassiveGroup(placements, passiveGroup) } + applyDirectPassiveTraceClearance({ + inputProblem: this.partitionInputProblem, + connectedPinsByPinId: this.pinIdToStronglyConnectedPins, + chipPlacements: placements, + }) return { chipPlacements: placements, groupPlacements: base.groupPlacements } } diff --git a/tests/offsetCollinearConnections.test.ts b/tests/offsetCollinearConnections.test.ts index 4e51c199..c69956c2 100644 --- a/tests/offsetCollinearConnections.test.ts +++ b/tests/offsetCollinearConnections.test.ts @@ -6,6 +6,7 @@ import { rotatePinOffset } from "../lib/utils/rotatePinOffset" import chipPortInput from "./assets/chip-port-without-portarrangement.input.json" import repro44Input from "./assets/repro44-e2e-pack-and-schematic.input.json" import bootResetInput from "./assets/schematic-section-rp2040-boot-reset.input.json" +import polarizedCapacitorInput from "./assets/polarized-capacitor-auto-layout.input.json" const getAbsolutePinPosition = ( inputProblem: InputProblem, @@ -68,3 +69,15 @@ test("keeps a standalone rail-to-ground chain in one line", () => { expect(resistorPin.x).toBeCloseTo(switchPin.x) }) + +test("preserves direct trace clearance after reflowing a passive row", () => { + const inputProblem = polarizedCapacitorInput as InputProblem + const outputLayout = solve(inputProblem) + const mainPin = getAbsolutePinPosition(inputProblem, outputLayout, "U1.1") + const c1Pin = getAbsolutePinPosition(inputProblem, outputLayout, "C1.1") + const c2Pin = getAbsolutePinPosition(inputProblem, outputLayout, "C2.1") + + expect(c1Pin.y - mainPin.y).toBeCloseTo(-0.2) + expect(c2Pin.y - mainPin.y).toBeCloseTo(-0.2) + expect(c1Pin.y).toBeCloseTo(c2Pin.y) +}) diff --git a/tests/repros/__snapshots__/polarized-capacitor-auto-layout.snap.svg b/tests/repros/__snapshots__/polarized-capacitor-auto-layout.snap.svg index eb8b6439..6c06c814 100644 --- a/tests/repros/__snapshots__/polarized-capacitor-auto-layout.snap.svg +++ b/tests/repros/__snapshots__/polarized-capacitor-auto-layout.snap.svg @@ -1,4 +1,4 @@ -C1C2U1 + ]]> \ No newline at end of file diff --git a/tests/repros/__snapshots__/repro-bq24074-right-resistors.snap.svg b/tests/repros/__snapshots__/repro-bq24074-right-resistors.snap.svg index ce68ae0e..39a84d48 100644 --- a/tests/repros/__snapshots__/repro-bq24074-right-resistors.snap.svg +++ b/tests/repros/__snapshots__/repro-bq24074-right-resistors.snap.svg @@ -1,4 +1,4 @@ -U1 [fixed]R1R2R3