fix: use the copper outline of hole_with_polygon_pad plated holes in clearance checks - #261
Open
mvennarini wants to merge 1 commit into
Open
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #260
Summary
getPolygonPointsForPad,getPolygonShape,getPadBoundsandgetCollidableBoundsonly recognised rect-pad plated holes, so ahole_with_polygon_padplated hole was reduced to its drill (or to a zero-size box for oval/pill drills, wherehole_diameteris undefined). A different-net via, SMT pad or trace on the polygon copper away from the drill passedcheckViasInPads,checkPadPadClearance,checkViaPadClearanceandcheckPadTraceClearancewith no errors.getPolygonPadHolePoints/isPolygonPadHole:pad_outlineis relative to the hole position and rotated byccw_rotation, the same conventioncheckCopperToBoardEdgeClearanceand core'sPlatedHolealready usegetPolygonPointsForPadreturns those points, so every clearance check that goes throughgetPadToPadGap/getTraceObstacleClearancesees the real coppergetPadBoundsandgetCollidableBoundsderive the spatial-index bounds from the outline instead ofgetBoundsOfPcbElements(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.tscovers, for a 4mm x 4mm polygon pad with a 0.8mm drill:checkViasInPadsreports itcheckViaPadClearancereports itcheckPadPadClearancereports itcheckPadTraceClearancereportsactual_clearance0.05mmccw_rotation: 90: a via at (0, 2.5) is reported, a via at (2.5, 0) is notAll five fail on
main(0 errors) and pass with this change.Verification
bun test(246 pass)bunx tsc --noEmitbunx biome format lib tests🤖 Generated with Claude Code
https://claude.ai/code/session_012Tbs6mJUsouNVBTYJndPuf