TraceMaker
C++ API of the engine
Loading...
Searching...
No Matches
problem.hpp File Reference

Placement problem extracted from a board (design doc 04 §2): parts with courtyards, holes and pins per rotation, weighted nets, the board outline, keepouts and spacing rules. More...

#include <array>
#include <cstdint>
#include <string>
#include <vector>
#include "geom/shape.hpp"
#include "model/board.hpp"
#include "model/rules.hpp"

Go to the source code of this file.

Classes

struct  tmk::place::CopperShape
 A piece of copper with what KiCad's clearance check needs: layers, net and the clearance it asks for (its net class, local overrides and board minimum; pair clearance = max of the two). More...
struct  tmk::place::PartGeom
struct  tmk::place::Part
struct  tmk::place::Pin
struct  tmk::place::PNet
struct  tmk::place::Keepout
struct  tmk::place::Problem
struct  tmk::place::PadAffinity
 A design-intent pseudo-net between two board pads (doc 15 P1): pad_a belongs to the part that should sit near pad_b (an ESD part near its connector, a crystal near its IC's oscillator pins, ...). More...
struct  tmk::place::EdgePull
 An objective-only pull of a part toward the board outline (doc 15 CONN-01, opt-in): the body point nearest to the outline in the input becomes a one-pin pseudo-net anchored on the nearest outline segment's axis (x for a mostly vertical segment, y for a mostly horizontal one), so the pull is exact in the annealer's integer cost and rotating the part away from the edge costs too. More...
struct  tmk::place::ExtractOptions
struct  tmk::place::Box
struct  tmk::place::Point
struct  tmk::place::Shape

Namespaces

namespace  tmk
namespace  tmk::place

Functions

std::size_t tmk::place::z (int i)
bool tmk::place::flipped (int state)
std::uint8_t tmk::place::with_turn (int state, int r)
 State with the same side as state and r quarter turns.
Point tmk::place::mirror_y (Point p)
std::uint8_t tmk::place::swap_state (int b_state, int dk)
 Exchanging two interchangeable parts a and b (same footprint and input side; angle0_b − angle0_a = 90° dk): the state that gives a the absolute pose b has in b_state.
Problem tmk::place::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 .kicad_pro).
Shape tmk::place::translated (const Shape &s, Point d)
 Geometry helpers.
Shape tmk::place::mirrored (const Shape &s)
 Mirror in y about the origin (polygon winding kept).
model::LayerMask tmk::place::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).
Point tmk::place::rot90 (Point p, int r)
 KiCad rotation by r * 90 degrees.
std::vector< Point > tmk::place::convex_hull (std::vector< Point > pts)
Shape tmk::place::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 than 2t.
bool tmk::place::power_like_name (const std::string &name)
bool tmk::place::ground_like_name (const std::string &name)

Variables

constexpr int tmk::place::kSignalWeight = 10
 Net weights are small integers so every cost is an exact integer (CLAUDE.md rule 2).
constexpr int tmk::place::kPowerWeight = 1
constexpr Coord tmk::place::kEdgeTolerance = 250'000
 courtyard may extend this far past the board edge
constexpr int tmk::place::kStates = 8
 Orientation state of a part (Placement::rot): bits 0–1 = quarter turns r, bit 2 = flipped to the other side.
constexpr std::uint8_t tmk::place::kFlipBit = 4

Detailed Description

Placement problem extracted from a board (design doc 04 §2): parts with courtyards, holes and pins per rotation, weighted nets, the board outline, keepouts and spacing rules.

Everything is in integer nm; a part's geometry is stored as offsets from its footprint origin for each of the four 90° rotations.

Definition in file problem.hpp.