TraceMaker
C++ API of the engine
Loading...
Searching...
No Matches
legalize.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2#pragma once
3// (D) Legalisation (design doc 04 §3 D): Tetris-style greedy, largest parts first, each part moved to the
4// nearest legal position (minimum Euclidean displacement over a lattice searched in rings) from its target.
5// Candidates are screened with the conservative occupancy raster and always confirmed by the exact test.
6#include <string>
7
8#include "place/legality.hpp"
9
10namespace tmk::place {
11
13 int placed = 0; // parts that were (re)placed
14 int kept = 0; // parts already legal and left untouched (only_illegal mode)
15 int failed = 0; // parts with no legal position found (left at their original position)
16 double max_disp_mm = 0, mean_disp_mm = 0;
18 long evictions = 0;
19 long lookahead_rejects = 0; // spots refused because they left no room for a waiting big part // rip-up-and-re-place steps (full mode)
20 long raster_disagree = 0; // raster said free but the exact test failed (must stay 0: the raster is conservative)
21 std::vector<std::string> failures;
22 std::vector<int> failed_parts;
23};
24
25// `only_illegal`: parts that are already legal (inside the board, conflict-free) stay where they are and only
26// the others are re-placed (refine mode). `cell` is the raster cell (0 = automatic, 0.05–0.1 mm).
27// `first`: parts to place before all others (e.g. the failures of an earlier attempt).
28LegaliseStats legalise(const Problem& p, Placement& pl, bool only_illegal, Coord cell = 0, const std::vector<int>* first = nullptr);
29
30} // namespace tmk::place
Placement legality (design doc 04 §3 D/E): exact integer tests of courtyards, through-hole obstacles,...
LegaliseStats legalise(const Problem &p, Placement &pl, bool only_illegal, Coord cell=0, const std::vector< int > *first=nullptr)
only_illegal: parts that are already legal (inside the board, conflict-free) stay where they are and ...
std::int64_t Coord
Engine coordinate: signed 64-bit nanometres.
Definition units.hpp:12
std::vector< int > failed_parts
Definition legalize.hpp:22
std::vector< std::string > failures
Definition legalize.hpp:21
int placed
parts that were (re)placed
Definition legalize.hpp:13
int failed
parts with no legal position found (left at their original position)
Definition legalize.hpp:15
long raster_disagree
raster said free but the exact test failed (must stay 0: the raster is conservative)
Definition legalize.hpp:20
long lookahead_rejects
spots refused because they left no room for a waiting big part // rip-up-and-re-place steps (full mod...
Definition legalize.hpp:19
int kept
parts already legal and left untouched (only_illegal mode)
Definition legalize.hpp:14