TraceMaker
C++ API of the engine
Loading...
Searching...
No Matches
ref_map.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2#pragma once
3// Where a track is over a void of its reference plane (issue #24, docs/05-routing.md §44, D117).
4//
5// A fast signal wants solid copper under it on the adjacent layer: where the plane has a split, a slot, a cut-out or an antipad field the return
6// current has to go round (docs/05 §42 measures the detour after the route). Here the same question is asked before the route, for every cell of the
7// router's lattice: on each copper layer that has a plane next to it (an adjacent layer whose zone fills cover a good part of the board), is the cell's
8// centre over the plane's copper? The router charges critical nets for the cells where it is not.
9//
10// The map is a cost, not a rule: the exact check of every commit is unchanged. Vias a route adds make antipads the fills in the file do not have yet; the
11// audit after the route (analysis/return_path.hpp, on a refilled board) sees those.
12#include <cstddef>
13#include <cstdint>
14#include <vector>
15
16#include "geom/clip.hpp"
17#include "geom/point.hpp"
18#include "model/board.hpp"
19
20namespace tmk::route {
21
23 // Per lattice cell, in the router's layout ((layer * ny + y) * nx + x): 1 = the cell is over a void of the layer's reference plane. Empty when no
24 // layer has a reference plane.
25 std::vector<std::uint8_t> over_void;
26 std::vector<int> reference_layer; // per copper layer: the adjacent layer taken as its reference plane, -1 = none (a plane layer with none counts its own gaps)
27 std::vector<double> coverage; // per copper layer: share of the board's bounding box that its zone fills cover
28 bool any() const { return !over_void.empty(); }
29};
30
31// `lat` is the lattice box (cell (x, y) is at lat.x0 + x * pitch, lat.y0 + y * pitch), `nx` x `ny` its size. The board's zones must carry their
32// fills (refill first if they do not). A layer is a reference plane when its fills cover at least `min_coverage` of the board's bounding box.
33ReferenceMap build_reference_map(const model::Board& b, const geom::Box& lat, Coord pitch, int nx, int ny, double min_coverage = 0.3);
34
35// Rasterises a region (rings under the non-zero rule, holes included): 1 where the cell centre is inside. Exposed for the tests, which compare it with a
36// point-in-region scan.
37std::vector<std::uint8_t> rasterise(const geom::Rings& region, const geom::Box& lat, Coord pitch, int nx, int ny);
38
39} // namespace tmk::route
The board model (design doc 02 §3): every object TraceMaker reads from a .kicad_pcb,...
Polygon booleans and offsets on integer nanometres, a thin wrapper over Clipper2 (Angus Johnson,...
std::vector< Ring > Rings
a region under the non-zero fill rule: outer rings and holes
Definition clip.hpp:14
std::vector< std::uint8_t > rasterise(const geom::Rings &region, const geom::Box &lat, Coord pitch, int nx, int ny)
Rasterises a region (rings under the non-zero rule, holes included): 1 where the cell centre is insid...
ReferenceMap build_reference_map(const model::Board &b, const geom::Box &lat, Coord pitch, int nx, int ny, double min_coverage=0.3)
lat is the lattice box (cell (x, y) is at lat.x0 + x * pitch, lat.y0 + y * pitch),...
std::int64_t Coord
Engine coordinate: signed 64-bit nanometres.
Definition units.hpp:12
Integer-nanometre points and KiCad-compatible rotation.
std::vector< int > reference_layer
per copper layer: the adjacent layer taken as its reference plane, -1 = none (a plane layer with none...
Definition ref_map.hpp:26
std::vector< double > coverage
per copper layer: share of the board's bounding box that its zone fills cover
Definition ref_map.hpp:27
std::vector< std::uint8_t > over_void
Per lattice cell, in the router's layout ((layer * ny + y) * nx + x): 1 = the cell is over a void of ...
Definition ref_map.hpp:25