Skip to content

fix: use the copper outline of hole_with_polygon_pad plated holes in clearance checks - #261

Open
mvennarini wants to merge 1 commit into
tscircuit:mainfrom
mvennarini:fix/polygon-pad-plated-hole-clearance
Open

fix: use the copper outline of hole_with_polygon_pad plated holes in clearance checks#261
mvennarini wants to merge 1 commit into
tscircuit:mainfrom
mvennarini:fix/polygon-pad-plated-hole-clearance

Conversation

@mvennarini

Copy link
Copy Markdown

Fixes #260

Summary

getPolygonPointsForPad, getPolygonShape, getPadBounds and getCollidableBounds only recognised rect-pad plated holes, so a hole_with_polygon_pad plated hole was reduced to its drill (or to a zero-size box for oval/pill drills, where hole_diameter is undefined). A different-net via, SMT pad or trace on the polygon copper away from the drill passed checkViasInPads, checkPadPadClearance, checkViaPadClearance and checkPadTraceClearance with no errors.

  • add getPolygonPadHolePoints / isPolygonPadHole: pad_outline is relative to the hole position and rotated by ccw_rotation, the same convention checkCopperToBoardEdgeClearance and core's PlatedHole already use
  • getPolygonPointsForPad returns those points, so every clearance check that goes through getPadToPadGap / getTraceObstacleClearance sees the real copper
  • getPadBounds and getCollidableBounds derive the spatial-index bounds from the outline instead of getBoundsOfPcbElements (which only knows the drill for this shape; a matching fix for the util is in tscircuit/circuit-json-util, but this PR does not depend on it)

Rect-pad, pill, circle and SMT pad paths are unchanged.

Tests

tests/lib/check-polygon-pad-plated-hole.test.ts covers, for a 4mm x 4mm polygon pad with a 0.8mm drill:

  • via fully inside the copper, 1.5mm from the drill: checkViasInPads reports it
  • via 0.05mm outside the outline: checkViaPadClearance reports it
  • SMT pad on the copper: checkPadPadClearance reports it
  • 0.2mm trace 0.05mm from the outline: checkPadTraceClearance reports actual_clearance 0.05mm
  • 6mm x 1mm bar with ccw_rotation: 90: a via at (0, 2.5) is reported, a via at (2.5, 0) is not

All five fail on main (0 errors) and pass with this change.

Verification

  • bun test (246 pass)
  • bunx tsc --noEmit
  • bunx biome format lib tests

🤖 Generated with Claude Code

https://claude.ai/code/session_012Tbs6mJUsouNVBTYJndPuf

…clearance checks

getPolygonPointsForPad, getPolygonShape, getPadBounds and getCollidableBounds
only recognised rect-pad plated holes, so a hole_with_polygon_pad was reduced
to its drill (or to a zero-size box for oval drills). Vias, pads and traces on
the polygon copper away from the drill passed checkViasInPads,
checkPadPadClearance, checkViaPadClearance and checkPadTraceClearance.

The pad_outline is relative to the hole position and rotated by ccw_rotation,
matching checkCopperToBoardEdgeClearance and core's PlatedHole.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012Tbs6mJUsouNVBTYJndPuf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DRC checks ignore the copper of hole_with_polygon_pad plated holes (via-in-pad, pad-pad, via-pad and pad-trace clearance)

1 participant