14 std::vector<Point>
pos;
15 std::vector<std::uint8_t>
rot;
47 bool present(
int part)
const {
return present_[
z(part)] != 0; }
52 bool legal(
int part,
Point pos,
int rot,
int skip1 = -1,
int skip2 = -1)
const {
59 void cells_of(
const Box& b,
int& cx0,
int& cy0,
int& cx1,
int& cy1)
const;
61 Coord cell_ = 2'000'000;
62 Coord ox_ = 0, oy_ = 0;
64 std::vector<std::vector<int>> cells_;
65 std::vector<Point> pos_;
66 std::vector<std::uint8_t> rot_, present_;
67 mutable std::vector<std::uint32_t> stamp_;
68 mutable std::uint32_t epoch_ = 0;
70 std::vector<Shape> segs_;
71 std::vector<std::vector<int>> seg_cells_;
72 std::vector<std::vector<int>> fixed_cells_;
81 void add(
int part,
Point pos,
int rot,
int delta);
89 bool range(
const Box& b,
int& x0,
int& y0,
int& x1,
int& y1)
const;
90 bool any(
const std::vector<std::uint16_t>& g,
const Box& b)
const;
91 bool any_sat(
const std::vector<std::int32_t>& sat,
const Box& b)
const;
92 void build_sat(
const std::vector<std::uint16_t>& g, std::vector<std::int32_t>& sat)
const;
93 bool free_impl(
int part,
Point pos,
int rot,
bool sat)
const;
94 void bump(std::vector<std::uint16_t>& g,
const Box& b,
int delta);
97 Coord ox_ = 0, oy_ = 0;
99 std::vector<std::uint16_t> blocked_[2];
100 std::vector<std::uint16_t> keep_[2];
101 std::vector<std::uint16_t> occ_[2];
102 std::vector<std::uint16_t> fixed_[2];
103 std::vector<std::int32_t> sat_blocked_[2], sat_keep_[2], sat_fixed_[2];
104 mutable std::vector<std::int32_t> sat_occ_[2];
105 mutable bool occ_dirty_ =
true;
114 std::vector<std::pair<int, int>>
pairs;
void conflicts(int part, Point pos, int rot, std::vector< int > &out) const
Every placed part that conflicts (sorted).
Legality(const Problem &p)
int find_conflict(int part, Point pos, int rot, int skip1=-1, int skip2=-1) const
First placed part that conflicts with part at (pos, rot), skipping part itself and skip1/skip2; -1 if...
void insert(int part, Point pos, int rot)
bool inside_ok(int part, Point pos, int rot, bool lenient=false) const
Board test (outline, cut-outs, keepouts, pad-to-edge clearance); independent of other parts.
bool present(int part) const
void reset(const Placement &pl)
Index of placed parts (all parts present after reset).
void neighbours(const Box &box, std::vector< int > &out) const
Placed parts whose bodies are within margin of the box.
bool pair_conflict(int a, Point pa, int ra, int b, Point pb, int rb) const
Exact test of two parts.
bool legal(int part, Point pos, int rot, int skip1=-1, int skip2=-1) const
bool free_reference(int part, Point pos, int rot) const
cell scan (reference path for tests)
double inside_fraction(int side) const
Fraction of cells inside the board on side s (for diagnostics).
void add(int part, Point pos, int rot, int delta)
delta = +1 insert, -1 remove
bool free(int part, Point pos, int rot) const
summed-area tables: O(shapes) per call
Raster(const Problem &p, Coord cell)
bool copper_conflict(const CopperShape &a, Point pa, const CopperShape &b, Point pb)
Copper clearance violation between two copper shapes (different nets, shared layer,...
Violations check_all(const Problem &p, const Placement &pl)
constexpr Coord kThroughMargin
through obstacle vs courtyard on the other side
constexpr Coord kThroughThrough
through obstacle vs through obstacle
bool closer(const Shape &a, Point da, const Shape &b, Point db, Coord clearance)
Exact test with translation (no copies): same semantics as geom::closer_than(a + da,...
std::int64_t Coord
Engine coordinate: signed 64-bit nanometres.
Placement problem extracted from a board (design doc 04 §2): parts with courtyards,...
A piece of copper with what KiCad's clearance check needs: layers, net and the clearance it asks for ...
std::array< Point, kStates > off
offset from the part origin per state
static Placement initial(const Problem &p)
every part where the board has it
std::vector< std::uint8_t > rot
rotation index per part (angle0 + 90° * rot)
Point pin(const Problem &p, int pin_index) const
std::vector< Point > pos
footprint origin per part
Every conflict in a placement (for the final report and tests): movable-involved pairs and parts outs...
std::vector< std::pair< int, int > > pairs
std::vector< int > outside_parts
int outside
movable parts failing inside_ok
int fixed_overlaps
pairs of fixed parts (pre-existing, not ours)
int overlaps
conflicting pairs with at least one movable part