Model pads and vias as KiCad places them

Measured against KiCad's own pads on the TerraHawk rc4 power stage:

- Back-side parts kept their pads on F.Cu (32 pads). Mirror the copper
  layer for a back-side part.
- Pad outlines were copied unrotated (29 pads on rotated parts). Place the
  outline through the same chain as the pin: pin rotation, back-side
  mirror, part rotation. Oval pads, a path with a width, came out as a
  zero-height sliver; pad them out by the aperture.
- Multi-shape padstacks used the first shape; use the largest.
- Footprint-level keepouts were parsed but never placed. KiCad exports a
  mounting hole's plated ring that way, so the router could not see it.
- Vias were sized like a trace (0.25 mm square for a 0.6 mm via), and every
  remaining short and clearance error was a via. Read the size from the
  DSN's via padstack and use it in all three engines; the grid engine now
  reserves the cells a via's copper reaches.

With these the exact and room engines route that board with no shorts,
clearance or other DRC errors. Pins now carry their component reference.
This commit is contained in:
2026-09-27 06:40:34 -06:00
parent 3ad5c983f5
commit f1df60fc31
7 changed files with 245 additions and 34 deletions
+13 -4
View File
@@ -63,11 +63,20 @@ def test_pin_count_matches_placement(dsn, board):
def test_obstacle_count_matches_keepouts(dsn, board):
# each keepout expands to one obstacle per applicable layer; with no keepouts
# in this fixture the count is zero
assert len(board.get_obstacle_areas()) >= len(dsn.keepouts)
# Board-level keepouts plus every placed instance of a footprint-level one.
# This fixture has none of the first and six plated mounting holes, whose
# copper KiCad exports as a keepout on each layer.
images = {img.name: img for img in dsn.images}
placed = 0
for placement in dsn.placements:
image = images.get(placement.lib_name)
if image is None:
continue
per_part = len(image.keepouts) + len(image.via_keepouts) + len(image.wire_keepouts)
placed += per_part * sum(p.x is not None for p in placement.places)
assert len(dsn.keepouts) == 0
assert board.get_obstacle_areas() == []
assert placed == 12
assert len(board.get_obstacle_areas()) == placed
# --- per-item invariants ----------------------------------------------------