Add item hierarchy, BasicBoard, and DSN->board construction

Ports the data model of the board Item hierarchy (Item base, Pin,
ObstacleArea/ConductionArea, Via, Trace) and BasicBoard (layers, nets,
clearance, bounding box, items with query helpers), then build_board:
the load-bearing integration that constructs a BasicBoard from a parsed
DsnBoard.

build_board maps layers -> LayerStructure, resolution -> transform,
default clearance rule -> ClearanceMatrix, nets -> Nets plus a
(component,pin)->net map, padstacks x placement -> Pin items, and
keepouts -> ObstacleArea items. Rectangle pads become exact IntBoxes,
convex polygon pads exact Simplexes, circle pads their bounding box
(documented approximation); every pad is centred on its pin location so
it contains that location by construction. Trace/Via are router-produced
and lightweight here (an imported unrouted board has none).

Validated on a real KiCad export (kicad_routable.dsn): layer/net/pin
counts match the parsed DSN, every pin's pad shape contains its origin,
every pin reports a valid net, and pin locations lie in the board
bounding box. An oracle-gated test cross-checks that every net the
reference FreeRouting JAR routes exists on the constructed board.
This commit is contained in:
2026-07-12 08:29:43 -06:00
parent dd40aaba5d
commit 4220fe0cd6
5 changed files with 623 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
"""Board data model for freeroute.
The data model a parsed DSN produces and the (future) router operates on:
layers, units, coordinate transform, nets, clearance matrix, the item hierarchy,
and the :class:`BasicBoard` container. :func:`build_board` constructs a board
from a :class:`~freeroute.dsn.model.DsnBoard`.
The routing operations (``RoutingBoard``) and the spatial ``ShapeSearchTree``
belong to the router phase.
"""
from __future__ import annotations
from .board import BasicBoard
from .build import build_board
from .clearance import ClearanceMatrix
from .items import ConductionArea, Item, ObstacleArea, Pin, Trace, Via
from .layer import Layer, LayerStructure
from .net import Net, Nets
from .transform import CoordinateTransform
from .unit import Unit
__all__ = [
"Unit",
"Layer",
"LayerStructure",
"CoordinateTransform",
"Net",
"Nets",
"ClearanceMatrix",
"Item",
"Pin",
"ObstacleArea",
"ConductionArea",
"Via",
"Trace",
"BasicBoard",
"build_board",
]