TraceMaker
C++ API of the engine
Loading...
Searching...
No Matches
copper.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2#pragma once
3// Copper items with exact shapes, built from the board model, for DRC and routing obstacles.
4#include <vector>
5
6#include "geom/shape.hpp"
7#include "model/board.hpp"
8
9namespace tmk::drc {
10
11enum class ItemKind : std::uint8_t { Pad, Track, Arc, Via, Zone, Graphic };
12const char* kind_name(ItemKind k); // KiCad expression type names: Pad, Track, Arc, Via, Zone, Graphic
13
14struct CopperItem {
16 int index = -1; // index in the board's pads/tracks/arcs/vias/zones/graphics vector
17 int sub = 0; // zone fill polygon index
19 model::LayerMask layers = 0; // copper layers the shape is on
20 std::vector<geom::Shape> shapes; // copper shape (identical on every layer in `layers`)
22 int footprint = -1;
23 model::Point pos; // reporting position
24 Coord width = 0; // tracks/arcs: width; vias: diameter
25 int owner = -1; // router connection that created this item (-1 = fixed copper)
26 bool removed = false; // ripped up (router working model only)
27 bool free_via = false; // via marked (free yes): its net is fixed for KiCad's net propagation
28};
29
30struct Hole {
32 int item = -1; // copper item owning the hole (-1 for NPTH pads without copper)
33 int pad = -1, via = -1;
34 bool plated = true;
37 Coord clearance = -1; // local clearance of the owning pad/footprint (applies as hole clearance), -1 = none
38 bool removed = false;
39};
40
42 std::vector<CopperItem> items;
43 std::vector<Hole> holes;
44 std::vector<geom::Shape> edges; // Edge.Cuts outline pieces (open polylines, r = 0)
45 // Margin-layer graphics: KiCad's copper_edge_clearance treats them like the board edge
46 // (drc_test_provider_edge_clearance collects Edge.Cuts and Margin), but they are no part of the outline.
47 std::vector<geom::Shape> margins;
48};
49
50// Pad copper shape in absolute coordinates.
51std::vector<geom::Shape> pad_shapes(const model::Pad& pad);
52
54
55// Closed loops chained from Edge.Cuts pieces whose ends meet within `tol`; pieces that close no loop are dropped
56// (`all_closed`, if given, tells whether any was).
57std::vector<std::vector<model::Point>> edge_loops(const std::vector<geom::Shape>& edges, Coord tol = 2'000, bool* all_closed = nullptr);
58
59} // namespace tmk::drc
The board model (design doc 02 §3): every object TraceMaker reads from a .kicad_pcb,...
CopperModel build_copper(const model::Board &b)
std::vector< geom::Shape > pad_shapes(const model::Pad &pad)
Pad copper shape in absolute coordinates.
std::vector< std::vector< model::Point > > edge_loops(const std::vector< geom::Shape > &edges, Coord tol=2 '000, bool *all_closed=nullptr)
Closed loops chained from Edge.Cuts pieces whose ends meet within tol; pieces that close no loop are ...
const char * kind_name(ItemKind k)
KiCad expression type names: Pad, Track, Arc, Via, Zone, Graphic.
std::int32_t NetId
0 = no net
Definition board.hpp:21
std::uint64_t LayerMask
bit i = copper layer i in stack order (0 = F.Cu, last = B.Cu)
Definition board.hpp:22
std::int64_t Coord
Engine coordinate: signed 64-bit nanometres.
Definition units.hpp:12
Exact integer geometry for clearance checks (design doc 03 §1).
bool free_via
via marked (free yes): its net is fixed for KiCad's net propagation
Definition copper.hpp:27
model::Point pos
reporting position
Definition copper.hpp:23
int owner
router connection that created this item (-1 = fixed copper)
Definition copper.hpp:25
model::NetId net
Definition copper.hpp:18
bool removed
ripped up (router working model only)
Definition copper.hpp:26
Coord width
tracks/arcs: width; vias: diameter
Definition copper.hpp:24
int index
index in the board's pads/tracks/arcs/vias/zones/graphics vector
Definition copper.hpp:16
std::vector< geom::Shape > shapes
copper shape (identical on every layer in layers)
Definition copper.hpp:20
model::LayerMask layers
copper layers the shape is on
Definition copper.hpp:19
int sub
zone fill polygon index
Definition copper.hpp:17
std::vector< Hole > holes
Definition copper.hpp:43
std::vector< CopperItem > items
Definition copper.hpp:42
std::vector< geom::Shape > edges
Edge.Cuts outline pieces (open polylines, r = 0).
Definition copper.hpp:44
std::vector< geom::Shape > margins
Margin-layer graphics: KiCad's copper_edge_clearance treats them like the board edge (drc_test_provid...
Definition copper.hpp:47
int item
copper item owning the hole (-1 for NPTH pads without copper)
Definition copper.hpp:32
model::Point pos
Definition copper.hpp:36
model::NetId net
Definition copper.hpp:35
geom::Shape shape
Definition copper.hpp:31
Coord clearance
local clearance of the owning pad/footprint (applies as hole clearance), -1 = none
Definition copper.hpp:37