28 std::vector<int>* owners =
nullptr)
const;
30 std::vector<int>* owners =
nullptr)
const;
35 std::vector<int>* owners =
nullptr)
const;
37 return disk_state(p, layer, hw, net, margin,
false) == 0;
43 return via_state(p, d, drill, net, margin,
false) == 0;
69 bool via_hole =
false,
Coord hole_r = 0)
const;
76 return coupling_on_ && net > 0 &&
static_cast<std::size_t
>(net) < net_tracks_.size() && re_->dp_partner(net) > 0;
85 const std::vector<std::pair<int, geom::Shape>>&
copper_texts()
const {
return texts_; }
90 const std::vector<geom::Point>&
outline()
const {
return outline_; }
121 int copper_state(
const geom::Shape& s,
const drc::CopperItem& probe,
int layer,
bool ignore_routed, std::vector<int>* owners)
const;
126 std::vector<int>* owners)
const;
130 std::vector<int>* owners)
const;
131 int physical_hole_state(
const geom::Shape& hole,
model::NetId net,
int layer,
bool fixed,
bool routed,
bool soft, std::vector<int>* owners)
const;
135 int routed_hole_to_hole_part(
const geom::Shape& hole,
bool soft, std::vector<int>* owners)
const;
137 void setup_coupling();
139 std::optional<Coord> min, max;
142 bool coupling_on_ =
false;
143 std::vector<GapBounds> gap_bounds_;
144 std::vector<std::vector<int>> net_tracks_;
149 std::unique_ptr<drc::RuleEngine> re_;
150 std::unique_ptr<drc::ZoneFills> fills_;
151 bool linear_zone_tests_ =
false;
152 std::unique_ptr<index::UniformGrid> grid_;
153 std::unique_ptr<index::UniformGrid> rgrid_;
154 std::unique_ptr<index::UniformGrid> hgrid_;
155 std::unique_ptr<index::UniformGrid> egrid_;
156 std::vector<geom::Shape> edge_segs_;
159 std::vector<geom::Point> outline_;
160 std::vector<std::vector<geom::Point>> cutouts_;
162 std::vector<std::uint8_t> inside_raster_;
163 int ir_w_ = 0, ir_h_ = 0;
164 Coord ir_cell_ = 250'000;
168 std::vector<std::uint32_t> start;
169 std::vector<std::uint32_t> edges;
171 std::vector<LoopBands> loop_bands_;
173 bool soft_zones_ =
false;
174 bool soft_mask_graphics_ =
false;
175 bool soft_copper_graphics_ =
false;
179 bool vias_off_pads_ =
false;
180 Coord vias_off_pads_max_ = 2'000'000;
181 mutable bool pad_via_exempt_ =
false;
182 bool via_keeps_off(
const drc::CopperItem& it)
const;
183 std::vector<std::pair<geom::Shape, const model::Zone*>> keepouts_;
184 std::vector<geom::Shape> mask_open_[2];
186 std::vector<geom::Shape> shapes;
191 std::vector<Aperture> apertures_[2];
192 std::unique_ptr<index::UniformGrid> agrid_[2];
193 std::vector<std::pair<int, geom::Shape>> texts_;
195 Coord max_hole_local_ = 0;
197 void aperture_codes(
const geom::Shape& s,
int layer,
bool via_probe,
const std::function<
void(
model::NetId)>& hit)
const;
The board model (design doc 02 §3): every object TraceMaker reads from a .kicad_pcb,...
void set_soft_zones(bool on)
Zone fills are ignored as obstacles (they are refilled after routing); they remain connection targets...
bool via_disallowed(geom::Point p, Coord d, model::NetId net, int l0, int l1, model::ViaType type) const
void set_soft_copper_graphics(bool on)
Net-less copper drawn as BOARD graphics (an EasyEDA import's pours as polygons on a copper layer) is ...
bool positional_rules() const
Custom disallow rules that depend on position, size or footprint (doc 05 §34), for new copper of net:...
int add_via(int index, int owner)
bool needs_exact_routing() const
Rules outside the per-class cache require exact per-point checks.
bool coupling_net(model::NetId net) const
std::int32_t fixed_via_code(geom::Point p, Coord d, Coord drill, Coord margin, model::NetId probe_net) const
static constexpr std::int32_t kFree
Fixed-obstacle code of a disk (fixed copper, fixed holes, edges, keepouts, outline),...
int add_track(int index, int owner)
Registers committed copper (the board copy must already contain the track/via at index).
void set_vias_off_pads(bool on, Coord max_pad)
Vias keep clear of SMD pads narrower than max_pad (any net, net-class clearance), as if they were ano...
std::int32_t fixed_via_code_reference(geom::Point p, Coord d, Coord drill, Coord margin, model::NetId probe_net) const
Per-layer reference for fixed_via_code.
int routed_state(const geom::Shape &s, int layer, model::NetId net, drc::ItemKind kind, bool soft, std::vector< int > *owners, bool via_hole=false, Coord hole_r=0) const
Routed (rippable) copper only: 0 free, 1 conflicts (owners appended), 2 blocked when !...
void set_linear_zone_tests(bool on)
Reference path: test probes against every edge of a zone fill instead of the fill's edge index (the a...
const std::vector< std::pair< int, geom::Shape > > & copper_texts() const
Copper text as the model holds it: one estimated rectangle per line (copper index,...
const std::vector< geom::Point > & outline() const
Board outline polygon (largest Edge.Cuts loop) when it could be assembled; empty otherwise.
static constexpr std::int32_t kBlocked
Obstacles(model::Board &board, const model::DesignRules &rules)
board is the router's working copy; items added later must also be appended to it.
void set_pad_via_exempt(bool on) const
bool track_disallowed(const geom::Shape &s, int layer, Coord width, model::NetId net) const
bool disk_ok(geom::Point p, int layer, Coord hw, model::NetId net, Coord margin) const
int coupling_state(geom::Point a, geom::Point b, int layer, Coord width, model::NetId net, bool ignore_routed, std::vector< int > *owners) const
KiCad's diff-pair coupling for a new track of a pair net with a bounded gap (doc 05 §59): 0,...
bool via_ok(geom::Point p, Coord d, Coord drill, model::NetId net, Coord margin) const
void routed_items_in(const geom::Box &box, std::vector< int > &out) const
Ids of live routed items whose box meets box.
int disk_state(geom::Point p, int layer, Coord hw, model::NetId net, Coord margin, bool ignore_routed, std::vector< int > *owners=nullptr) const
Legality of a probe shape.
int segment_state(geom::Point a, geom::Point b, int layer, Coord width, model::NetId net, bool ignore_routed, std::vector< int > *owners=nullptr) const
Coord via_mask() const
Solder-mask expansion the checks give untented vias (0 when the board tents them).
void set_soft_mask_graphics(bool on)
Net-less solder-mask openings drawn as footprint graphics (a solder-jumper's bridge,...
bool segment_ok(geom::Point a, geom::Point b, int layer, Coord width, model::NetId net) const
index::UniformGrid & grid()
void set_via_mask(Coord m)
const drc::RuleEngine & rules() const
int via_state(geom::Point p, Coord d, Coord drill, model::NetId net, Coord margin, bool ignore_routed, std::vector< int > *owners=nullptr) const
int routed_via_state(const geom::Shape &s, model::LayerMask layers, model::NetId net, bool soft, Coord hole_r) const
Maximum routed_state over layers for a via and its hole; layer-independent hole checks run once.
void remove_item(int item)
Rips up a routed item (by copper item index).
bool inside_board(geom::Point p, Coord margin) const
bool inside_exact_linear(geom::Point p) const
std::int32_t fixed_code(geom::Point p, int layer, Coord hw, Coord margin, model::NetId probe_net, bool via_probe=false) const
long rej_outside
Rejection counters (diagnostics): outside board, copper, holes/edges/keepouts.
int via_state_span(geom::Point p, Coord d, Coord drill, model::NetId net, Coord margin, bool ignore_routed, std::vector< int > *owners, int l0, int l1, model::ViaType type=model::ViaType::Blind) const
A via on copper layers [l0, l1] only (blind or buried via, or a micro via with type); via_state cover...
const drc::CopperModel & copper() const
bool inside_exact(geom::Point p) const
Exact inside test against the outline and cut-outs: by the edges of the point's raster row,...
Copper connectivity with KiCad's semantics, shared by the DRC (unconnected/dangling checks) and the r...
Copper items with exact shapes, built from the board model, for DRC and routing obstacles.
std::int32_t NetId
0 = no net
std::uint64_t LayerMask
bit i = copper layer i in stack order (0 = F.Cu, last = B.Cu)
constexpr long double kPlaneTargetArea
With soft zones a fill of at least this area that no pad touches is its net's plane: a connection tar...
long double zone_fill_area(const drc::CopperModel &cm, const std::vector< int > &items)
Filled area of zone fill items (nm^2), shoelace over each item's outline.
std::int64_t Coord
Engine coordinate: signed 64-bit nanometres.
Resolves KiCad constraints for pairs of copper items (design doc 03 §6): net-class clearances,...
Design rules as KiCad defines them (design doc 08 §3–4): board minimums and net classes from the ....