TraceMaker
C++ API of the engine
Loading...
Searching...
No Matches
drc.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2#pragma once
3// Design-rule checker equivalent to KiCad's for routing-relevant rules (design doc 03 §6). Violation type
4// names are KiCad's, so reports compare 1:1 with `kicad-cli pcb drc --format json`.
5#include <map>
6#include <string>
7#include <vector>
8
9#include "model/board.hpp"
10#include "model/rules.hpp"
11
12namespace tmk::drc {
13
15 std::string description;
17};
18
19struct Violation {
20 std::string type;
21 std::string severity = "error";
22 std::string description;
23 std::vector<ViolationItem> items;
24 Coord actual = -1, required = -1;
25 int layer = -1;
26};
27
28struct DrcOptions {
29 Coord epsilon = 500; // KiCad's DRC epsilon (0.0005 mm): gaps below required - epsilon are violations
30 bool dangling = true; // report dangling tracks and vias (warnings)
31 bool propagate_nets = true; // check with the nets KiCad assigns on load (drc/connectivity.hpp propagate_nets)
32 bool linear_zone_tests = false; // reference path: test items against every edge of a zone fill (no edge index)
33 bool connectivity_only = false; // only unconnected items (and dangling ends if `dangling`): no clearance or rule checks
34};
35
36struct DrcReport {
37 std::vector<Violation> violations;
38 std::vector<Violation> unconnected;
39 std::vector<std::string> warnings;
40 std::map<std::string, int> counts() const;
41};
42
43DrcReport run_drc(const model::Board& b, const model::DesignRules& r, const DrcOptions& opt = {});
44
45// Writes the report in kicad-cli's JSON layout (violations, unconnected_items; positions in mm).
46void write_drc_json(const DrcReport& rep, const std::string& path);
47
48} // namespace tmk::drc
The board model (design doc 02 §3): every object TraceMaker reads from a .kicad_pcb,...
void write_drc_json(const DrcReport &rep, const std::string &path)
Writes the report in kicad-cli's JSON layout (violations, unconnected_items; positions in mm).
DrcReport run_drc(const model::Board &b, const model::DesignRules &r, const DrcOptions &opt={})
std::int64_t Coord
Engine coordinate: signed 64-bit nanometres.
Definition units.hpp:12
Design rules as KiCad defines them (design doc 08 §3–4): board minimums and net classes from the ....
Coord epsilon
KiCad's DRC epsilon (0.0005 mm): gaps below required - epsilon are violations.
Definition drc.hpp:29
bool propagate_nets
check with the nets KiCad assigns on load (drc/connectivity.hpp propagate_nets)
Definition drc.hpp:31
bool dangling
report dangling tracks and vias (warnings)
Definition drc.hpp:30
bool linear_zone_tests
reference path: test items against every edge of a zone fill (no edge index)
Definition drc.hpp:32
bool connectivity_only
only unconnected items (and dangling ends if dangling): no clearance or rule checks
Definition drc.hpp:33
std::vector< Violation > unconnected
Definition drc.hpp:38
std::vector< Violation > violations
Definition drc.hpp:37
std::vector< std::string > warnings
Definition drc.hpp:39
std::map< std::string, int > counts() const
model::Point pos
Definition drc.hpp:16
std::string description
Definition drc.hpp:15
std::vector< ViolationItem > items
Definition drc.hpp:23
std::string severity
Definition drc.hpp:21
std::string type
Definition drc.hpp:20
std::string description
Definition drc.hpp:22