Skip to content

fix: detect overlapping polygon and pill courtyards - #186

Open
zkasuran wants to merge 1 commit into
tscircuit:mainfrom
zkasuran:fix/courtyard-overlap-polygon-pill
Open

fix: detect overlapping polygon and pill courtyards#186
zkasuran wants to merge 1 commit into
tscircuit:mainfrom
zkasuran:fix/courtyard-overlap-polygon-pill

Conversation

@zkasuran

@zkasuran zkasuran commented Aug 8, 2026

Copy link
Copy Markdown

Closes #185

What

checkCourtyardOverlap only collected pcb_courtyard_rect, pcb_courtyard_circle and pcb_courtyard_outline. pcb_courtyard_polygon and pcb_courtyard_pill were dropped by the filter, so two components whose polygon or pill courtyards overlap on the same layer passed the check with no error.

Why it matters

pcb_courtyard_polygon is emitted by real inputs. kicad-component-converter produces it when importing footprints and @tscircuit/eval carries it, so a KiCad footprint whose courtyard is a polygon was never checked for overlap. checkPcbComponentOverlap already treats pcb_courtyard_polygon as a courtyard, so the two overlap checks disagreed on what a courtyard is.

Change

  • Add pcb_courtyard_polygon and pcb_courtyard_pill to the courtyard filter and the CourtyardElement type.
  • getCourtyardPolygon returns the polygon points directly for pcb_courtyard_polygon and approximates a pill as a stadium polygon (two semicircular caps sampled the same way the circle courtyard is turned into a 32-gon).
  • The different-layer skip is unchanged, so courtyards on opposite sides are still allowed to overlap.

Tests

New file tests/lib/check-courtyard-overlap/courtyard-polygon-pill-overlap.test.ts:

  • overlapping polygon courtyards report one error, a far third component stays clear
  • polygon courtyards on different layers stay clear
  • overlapping pill courtyards report one error, separated pills stay clear
  • an error-drawn SVG snapshot of the overlapping polygon courtyards

The three assertion tests fail before this change (0 errors) and pass after.

Verified locally before submitting

  • bun test: 145 pass, 0 fail
  • bunx tsc --noEmit: clean
  • bunx biome format .: clean

AI assistance (Claude, Anthropic) was used in developing this change. The design, review and verification were done by the author. Verified locally before submitting: bun test (145 pass, 0 fail), bunx tsc --noEmit clean, biome format clean.

checkCourtyardOverlap dropped pcb_courtyard_polygon and pcb_courtyard_pill from
its filter, so components whose polygon or pill courtyards overlapped on the same
layer passed with no error. Collect both types and turn a pill into a stadium
polygon (two semicircle caps, sampled like the circle courtyard's 32-gon).
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.

checkCourtyardOverlap silently ignores polygon and pill courtyards

1 participant