21inline std::size_t
z(
int i) {
return static_cast<std::size_t
>(i); }
38 std::array<std::vector<Shape>, 2>
cy;
46 std::array<std::vector<Shape>, 2>
cy_in;
57inline std::uint8_t
with_turn(
int state,
int r) {
return static_cast<std::uint8_t
>((state &
kFlipBit) | (r & 3)); }
77 std::array<PartGeom, kStates>
geom;
89 std::array<Point, kStates>
off;
The board model (design doc 02 §3): every object TraceMaker reads from a .kicad_pcb,...
std::int32_t NetId
0 = no net
std::uint64_t LayerMask
bit i = copper layer i in stack order (0 = F.Cu, last = B.Cu)
model::LayerMask flip_layers(model::LayerMask m, int n)
Copper layer mask of the other side: bit i <-> bit n−1−i for n copper layers (KiCad FlipLayerMask).
Shape mirrored(const Shape &s)
Mirror in y about the origin (polygon winding kept).
constexpr int kSignalWeight
Net weights are small integers so every cost is an exact integer (CLAUDE.md rule 2).
constexpr Coord kEdgeTolerance
courtyard may extend this far past the board edge
constexpr std::uint8_t kFlipBit
bool ground_like_name(const std::string &name)
constexpr int kStates
Orientation state of a part (Placement::rot): bits 0–1 = quarter turns r, bit 2 = flipped to the othe...
Shape translated(const Shape &s, Point d)
Geometry helpers.
constexpr int kPowerWeight
std::uint8_t with_turn(int state, int r)
State with the same side as state and r quarter turns.
Shape inset_convex(const Shape &s, Coord t)
Inner parallel polygon of a convex polygon at distance t; a point at the centroid if it is thinner th...
Problem extract(const model::Board &b, const model::DesignRules &rules, const std::string &board_path, const ExtractOptions &opt={})
Builds the problem. rules and board_path give the courtyard clearance (custom rules or ....
bool power_like_name(const std::string &name)
std::uint8_t swap_state(int b_state, int dk)
Exchanging two interchangeable parts a and b (same footprint and input side; angle0_b − angle0_a = 90...
std::vector< Point > convex_hull(std::vector< Point > pts)
Point rot90(Point p, int r)
KiCad rotation by r * 90 degrees.
std::int64_t Coord
Engine coordinate: signed 64-bit nanometres.
Design rules as KiCad defines them (design doc 08 §3–4): board minimums and net classes from the ....
Exact integer geometry for clearance checks (design doc 03 §1).
A piece of copper with what KiCad's clearance check needs: layers, net and the clearance it asks for ...
model::NetId net
board net id (0 = no net)
An objective-only pull of a part toward the board outline (doc 15 CONN-01, opt-in): the body point ne...
std::string name
"~CONN-01 J3 edge"
std::vector< Point > body
absolute candidate points (courtyard outline, else pad corners)
bool affinity
Design-intent pseudo-net (decoupling capacitor to its IC's supply pin): part of the objective only,...
bool signal
counted for airwire crossings
bool has_ax
Fixed coordinates inside the net's bounding box (an edge pull, doc 15 CONN-01): a one-pin net with an...
A design-intent pseudo-net between two board pads (doc 15 P1): pad_a belongs to the part that should ...
int pad_b
board pad indices
std::string name
"~XTAL-01 Y1-U1"
std::array< std::vector< Shape >, 2 > cy_in
Courtyards shrunk by kEdgeTolerance: what must stay inside the board outline.
std::vector< Shape > pads
pad copper (for the copper-to-edge clearance)
std::array< std::vector< Shape >, 2 > cy
< one rotation of a part, offsets from the footprint origin
Box copper_box
bounding box of copper
Box edge_box
bounding box of the inset courtyards and pads inflated by the edge clearance
Box body
bounding box of courtyards, through obstacles and copper
std::vector< CopperShape > copper
pads, footprint copper graphics/text, NPTH holes (copper clearance)
std::vector< Shape > through
drilled holes and plated-through pad copper (obstacles on both sides)
bool flippable
May move to the other side (states 4–7): movable, surface mount only (no holes), the board has two co...
Coord area
courtyard box area incl. clearance (nm², saturating), for spreading
std::vector< int > pins
indices into Problem::pins
Point pos0
original origin
std::uint64_t shape_key
equal keys = interchangeable footprints (swap moves)
int fp
footprint index in the board
std::string fixed_reason
why a part is fixed (locked, mounting hole, ...)
double angle_of(int state) const
double angle0
original absolute orientation (degrees); see kStates for state angles
bool copper_only
ExtractOptions::copper_only: only its copper and holes are tested against other parts.
int side
0 front, 1 back: the footprint's side in the input
std::array< PartGeom, kStates > geom
per state (states 4–7 only filled for flippable parts)
int side_in(int state) const
std::string flip_reason
why a movable part may not flip (empty when it may, or when flipping is off)
bool one_side
a surface-mount pad: on the part's side only (via estimate when sides differ)
int net
index into Problem::nets
std::array< Point, kStates > off
offset from the part origin per state
Box region
where parts may go (outline bbox)
int movable_count() const
Coord max_need
largest copper clearance any item asks for
std::vector< std::vector< Point > > cutouts
other closed Edge.Cuts loops
std::vector< Part > parts
std::vector< CopperShape > fixed_copper
board copper that never moves: tracks, vias, copper graphics and text
bool clearance_is_default
not from a board rule or the command line
Coord clearance
courtyard-to-courtyard clearance
std::vector< Shape > edges
every Edge.Cuts piece as segments (r = 0)
std::vector< Point > outline
largest Edge.Cuts loop (empty if none could be assembled)
Coord edge_clearance
pad copper to board edge
int flippable_count() const
std::vector< Keepout > keepouts
std::vector< std::string > notes
extraction decisions worth reporting