TraceMaker
C++ API of the engine
Loading...
Searching...
No Matches
tmk::drc::RuleEngine Class Reference

#include <drc/rule_engine.hpp>

Public Member Functions

 RuleEngine (const model::Board &b, const model::DesignRules &r)
 ~RuleEngine ()
Coord clearance (const CopperItem &a, const CopperItem &b, int layer) const
 Required copper-to-copper clearance between two items on a copper layer.
Coord hole_clearance (const CopperItem *hole_owner, const CopperItem &other, int layer) const
 Required clearance between a hole and a copper item.
Coord hole_to_hole (const CopperItem *a, const CopperItem *b) const
Coord edge_clearance (const CopperItem &a, int layer) const
std::pair< Coord, Coord > track_width (const CopperItem &t, int layer) const
 Minimum and maximum track width (max = 0: none).
std::string track_width_severity (const CopperItem &t, int layer) const
 The severity of the last rule with a track_width constraint that matches the track ("" when none matches or it sets none): in KiCad that rule decides the track's width check, so an ignored rule hides the board minimum too (tuning profiles, doc 05 §58).
Coord via_diameter_min (const CopperItem &v) const
Coord annular_width_min (const CopperItem &v) const
Coord hole_size_min (const CopperItem *owner) const
Coord max_clearance () const
 Largest clearance any pair could need (for spatial-index inflation).
void use_zone_clearance_overrides ()
 KiCad applies a copper zone's own clearance to its fill (ZONE::GetLocalClearance): the larger of it and the net-class clearance, unless a pad override or custom rule decides.
const model::NetClass & netclass (const CopperItem &it) const
bool coupled_diff_pair (model::NetId a, model::NetId b) const
 True if the two nets are the P/N (or +/-) halves of one differential pair.
std::pair< std::optional< Coord >, std::optional< Coord > > length_constraint (model::NetId net) const
 Length constraint (min, max) of the last custom rule whose condition matches a track of net, if any.
std::optional< Coord > skew_constraint (model::NetId net) const
 Maximum skew of the last custom rule with a skew constraint matching a track of net, if any.
std::optional< model::Constraint > net_constraint (model::NetId net, const std::string &type) const
 Last custom constraint of type (e.g. diff_pair_gap, diff_pair_uncoupled) whose rule matches a track of net.
int last_rule_with (const CopperItem &it, int layer, const std::string &type) const
 KiCad's matched-length check groups items by the rule that gives them a constraint (DRC_ENGINE::EvalRules' parent rule; doc 05 §59): the position in rule order of the last rule with a type constraint matching it on layer, or -1.
const model::CustomRule & rule (int i) const
int net_rule_with (model::NetId net, const std::string &type) const
 The same for a net as a whole (a track of net on any layer), as length_constraint and net_constraint see it.
model::NetId dp_partner (model::NetId net) const
 The other half of net's differential pair (KiCad's DpCoupledNet), or 0.
bool dp_positive (model::NetId net) const
 True when net is the positive half of a pair (P or +, match_dp_suffix); only meaningful when dp_partner(net) is set.
std::optional< std::string > disallowed (const CopperItem &it, int layer) const
 Name of the last rule disallowing it on layer, if any (KiCad: items_not_allowed).
bool track_allowed (model::NetId net, int layer) const
 Router fast paths for a new track or via of net, from rules whose conditions do not depend on the item's position, size or footprint (per-net layer and via-type masks).
bool via_allowed (model::NetId net, model::ViaType type=model::ViaType::Through) const
 Blind router probes have no span yet, so either blind/buried keyword conservatively forbids them.
bool positional_disallow () const
 A disallow rule on tracks or vias depends on position, size or footprint: the router asks probe_disallowed.
bool probe_disallowed (const CopperItem &it, model::ViaType type=model::ViaType::Through) const
 A new track or via (index -1, actual shape, width and layers; a via's layers are its span, which tells blind from buried) is disallowed on one of its layers, every custom rule applied in order as in disallowed().
Coord physical_hole_clearance (const CopperItem *hole_owner, const CopperItem &other, int layer) const
 Hole-to-copper clearance on layer, any net; -1 when no rule matches (KiCad: hole_clearance).
bool any_physical_hole_clearance () const
bool via_hole_rule_hits_own_tracks (model::NetId net) const
 True when a physical_hole_clearance rule holds between a via of net and a track of the same net: the tracks that end in a via touch its hole, so every via of that net would break the rule.
Coord max_physical_hole_clearance () const
Coord router_hole_clearance () const
 Hole-to-copper clearance the router keeps between a hole and other nets' copper: the board minimum raised to every applied custom hole_clearance rule.
bool needs_exact_routing () const
 Custom rules that the per-class obstacle cache cannot represent require exact per-point checks.
const std::vector< std::string > & warnings () const

Friends

class Condition

Detailed Description

Definition at line 32 of file rule_engine.hpp.

Constructor & Destructor Documentation

◆ RuleEngine()

tmk::drc::RuleEngine::RuleEngine ( const model::Board & b,
const model::DesignRules & r )

◆ ~RuleEngine()

tmk::drc::RuleEngine::~RuleEngine ( )

Member Function Documentation

◆ annular_width_min()

Coord tmk::drc::RuleEngine::annular_width_min ( const CopperItem & v) const

◆ any_physical_hole_clearance()

bool tmk::drc::RuleEngine::any_physical_hole_clearance ( ) const
inline

Definition at line 98 of file rule_engine.hpp.

◆ clearance()

Coord tmk::drc::RuleEngine::clearance ( const CopperItem & a,
const CopperItem & b,
int layer ) const

Required copper-to-copper clearance between two items on a copper layer.

◆ coupled_diff_pair()

bool tmk::drc::RuleEngine::coupled_diff_pair ( model::NetId a,
model::NetId b ) const

True if the two nets are the P/N (or +/-) halves of one differential pair.

◆ disallowed()

std::optional< std::string > tmk::drc::RuleEngine::disallowed ( const CopperItem & it,
int layer ) const

Name of the last rule disallowing it on layer, if any (KiCad: items_not_allowed).

◆ dp_partner()

model::NetId tmk::drc::RuleEngine::dp_partner ( model::NetId net) const
inline

The other half of net's differential pair (KiCad's DpCoupledNet), or 0.

Definition at line 75 of file rule_engine.hpp.

◆ dp_positive()

bool tmk::drc::RuleEngine::dp_positive ( model::NetId net) const
inline

True when net is the positive half of a pair (P or +, match_dp_suffix); only meaningful when dp_partner(net) is set.

Definition at line 79 of file rule_engine.hpp.

◆ edge_clearance()

Coord tmk::drc::RuleEngine::edge_clearance ( const CopperItem & a,
int layer ) const

◆ hole_clearance()

Coord tmk::drc::RuleEngine::hole_clearance ( const CopperItem * hole_owner,
const CopperItem & other,
int layer ) const

Required clearance between a hole and a copper item.

◆ hole_size_min()

Coord tmk::drc::RuleEngine::hole_size_min ( const CopperItem * owner) const

◆ hole_to_hole()

Coord tmk::drc::RuleEngine::hole_to_hole ( const CopperItem * a,
const CopperItem * b ) const

◆ last_rule_with()

int tmk::drc::RuleEngine::last_rule_with ( const CopperItem & it,
int layer,
const std::string & type ) const

KiCad's matched-length check groups items by the rule that gives them a constraint (DRC_ENGINE::EvalRules' parent rule; doc 05 §59): the position in rule order of the last rule with a type constraint matching it on layer, or -1.

rule(i) is that rule.

◆ length_constraint()

std::pair< std::optional< Coord >, std::optional< Coord > > tmk::drc::RuleEngine::length_constraint ( model::NetId net) const

Length constraint (min, max) of the last custom rule whose condition matches a track of net, if any.

◆ max_clearance()

Coord tmk::drc::RuleEngine::max_clearance ( ) const
inline

Largest clearance any pair could need (for spatial-index inflation).

Definition at line 52 of file rule_engine.hpp.

◆ max_physical_hole_clearance()

Coord tmk::drc::RuleEngine::max_physical_hole_clearance ( ) const
inline

Definition at line 102 of file rule_engine.hpp.

◆ needs_exact_routing()

bool tmk::drc::RuleEngine::needs_exact_routing ( ) const
inline

Custom rules that the per-class obstacle cache cannot represent require exact per-point checks.

Definition at line 109 of file rule_engine.hpp.

◆ net_constraint()

std::optional< model::Constraint > tmk::drc::RuleEngine::net_constraint ( model::NetId net,
const std::string & type ) const

Last custom constraint of type (e.g. diff_pair_gap, diff_pair_uncoupled) whose rule matches a track of net.

◆ net_rule_with()

int tmk::drc::RuleEngine::net_rule_with ( model::NetId net,
const std::string & type ) const

The same for a net as a whole (a track of net on any layer), as length_constraint and net_constraint see it.

◆ netclass()

const model::NetClass & tmk::drc::RuleEngine::netclass ( const CopperItem & it) const

◆ physical_hole_clearance()

Coord tmk::drc::RuleEngine::physical_hole_clearance ( const CopperItem * hole_owner,
const CopperItem & other,
int layer ) const

Hole-to-copper clearance on layer, any net; -1 when no rule matches (KiCad: hole_clearance).

◆ positional_disallow()

bool tmk::drc::RuleEngine::positional_disallow ( ) const
inline

A disallow rule on tracks or vias depends on position, size or footprint: the router asks probe_disallowed.

Definition at line 92 of file rule_engine.hpp.

◆ probe_disallowed()

bool tmk::drc::RuleEngine::probe_disallowed ( const CopperItem & it,
model::ViaType type = model::ViaType::Through ) const

A new track or via (index -1, actual shape, width and layers; a via's layers are its span, which tells blind from buried) is disallowed on one of its layers, every custom rule applied in order as in disallowed().

◆ router_hole_clearance()

Coord tmk::drc::RuleEngine::router_hole_clearance ( ) const
inline

Hole-to-copper clearance the router keeps between a hole and other nets' copper: the board minimum raised to every applied custom hole_clearance rule.

The router's checks and caches have no per-pair hole rule, so a rule with a condition or a layer is kept everywhere (conservative, rule 6; a warning says so). The DRC stays exact (hole_clearance above).

Definition at line 107 of file rule_engine.hpp.

◆ rule()

const model::CustomRule & tmk::drc::RuleEngine::rule ( int i) const
inline

Definition at line 71 of file rule_engine.hpp.

◆ skew_constraint()

std::optional< Coord > tmk::drc::RuleEngine::skew_constraint ( model::NetId net) const

Maximum skew of the last custom rule with a skew constraint matching a track of net, if any.

◆ track_allowed()

bool tmk::drc::RuleEngine::track_allowed ( model::NetId net,
int layer ) const

Router fast paths for a new track or via of net, from rules whose conditions do not depend on the item's position, size or footprint (per-net layer and via-type masks).

◆ track_width()

std::pair< Coord, Coord > tmk::drc::RuleEngine::track_width ( const CopperItem & t,
int layer ) const

Minimum and maximum track width (max = 0: none).

◆ track_width_severity()

std::string tmk::drc::RuleEngine::track_width_severity ( const CopperItem & t,
int layer ) const

The severity of the last rule with a track_width constraint that matches the track ("" when none matches or it sets none): in KiCad that rule decides the track's width check, so an ignored rule hides the board minimum too (tuning profiles, doc 05 §58).

◆ use_zone_clearance_overrides()

void tmk::drc::RuleEngine::use_zone_clearance_overrides ( )

KiCad applies a copper zone's own clearance to its fill (ZONE::GetLocalClearance): the larger of it and the net-class clearance, unless a pad override or custom rule decides.

The DRC enables it; the router does not yet (D51: changing it needs a routing benchmark run).

◆ via_allowed()

bool tmk::drc::RuleEngine::via_allowed ( model::NetId net,
model::ViaType type = model::ViaType::Through ) const

Blind router probes have no span yet, so either blind/buried keyword conservatively forbids them.

Board items are distinguished exactly by whether their span touches an outer copper layer.

◆ via_diameter_min()

Coord tmk::drc::RuleEngine::via_diameter_min ( const CopperItem & v) const

◆ via_hole_rule_hits_own_tracks()

bool tmk::drc::RuleEngine::via_hole_rule_hits_own_tracks ( model::NetId net) const

True when a physical_hole_clearance rule holds between a via of net and a track of the same net: the tracks that end in a via touch its hole, so every via of that net would break the rule.

◆ warnings()

const std::vector< std::string > & tmk::drc::RuleEngine::warnings ( ) const
inline

Definition at line 110 of file rule_engine.hpp.

◆ Condition

friend class Condition
friend

Definition at line 154 of file rule_engine.hpp.


The documentation for this class was generated from the following file: