TraceMaker
C++ API of the engine
Loading...
Searching...
No Matches
rule_geometry.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2#pragma once
3// Positional custom-rule predicates. Shapes are tested as rounded cores, not boxes.
4#include <array>
5#include <string>
6#include <vector>
7
8#include "drc/copper.hpp"
9
10namespace tmk::drc {
11
12// Requires a common copper layer. Outline rings use even/odd filling (holes and
13// disjoint contours); enclosed requires every copper shape to be wholly inside.
14// The caller selects/caches zones; insideArea and intersectsArea both pass false.
15bool area_matches(const CopperItem& item, const model::Zone& area, bool enclosed);
17 // The courtyard is the union of the parts. The rings of one part use even/odd filling (a ring inside another
18 // is a hole); outlines that overlap or touch are parts of their own, as KiCad merges them.
19 std::vector<std::vector<std::vector<geom::Point>>> parts;
21 // The side has courtyard graphics, but they are not closed, simple outlines (or use a Bezier curve): no
22 // parts, and the rule engine warns that courtyard conditions cannot match this footprint.
23 bool unreadable = false;
24};
26 std::string reference, lib_id;
27 bool back = false; // footprint flipped to the bottom side
28 std::array<CourtyardRegion, 2> sides; // physical F.CrtYd, B.CrtYd
29};
31 std::vector<CourtyardEntry> entries;
32};
33
34// Build once per board; invalid/unclosed contours leave the corresponding side empty and marked unreadable.
36
37// KiCad's footprint selector (testFootprintSelector): a reference wildcard, or, when the selector contains ':',
38// a library-id wildcard. Case-sensitive, like wxString::Matches.
39bool footprint_selected(const std::string& selector, const std::string& reference, const std::string& lib_id);
40
41// Function is intersectsCourtyard/intersectsFrontCourtyard/intersectsBackCourtyard. Front and back are the
42// footprint's own sides (KiCad: GetCourtyard(fp->IsFlipped() ? B_Cu : F_Cu)): the front courtyard of a flipped
43// footprint is its B.CrtYd outline. The item's copper side does not matter.
44// This overload matches the selector against every footprint for each query: the reference path.
45bool courtyard_matches(const CopperItem& item, const CourtyardCache& courtyards,
46 const std::string& selector, const std::string& function);
47// The entries a footprint selector picks, in entry order, and the same test against them. The rule engine
48// resolves each selector once when the rules are compiled (Condition::bind): a rule is evaluated for every pair
49// of items the DRC compares and for every lattice point the router visits, and matching the selector against
50// every footprint each time made a courtyard clearance rule dominate the DRC of a large board.
51std::vector<int> courtyard_entries(const CourtyardCache& courtyards, const std::string& selector);
52bool courtyard_matches(const CopperItem& item, const CourtyardCache& courtyards,
53 const std::vector<int>& entries, const std::string& function);
54} // namespace tmk::drc
Copper items with exact shapes, built from the board model, for DRC and routing obstacles.
bool area_matches(const CopperItem &item, const model::Zone &area, bool enclosed)
Requires a common copper layer.
std::vector< int > courtyard_entries(const CourtyardCache &courtyards, const std::string &selector)
The entries a footprint selector picks, in entry order, and the same test against them.
bool courtyard_matches(const CopperItem &item, const CourtyardCache &courtyards, const std::string &selector, const std::string &function)
Function is intersectsCourtyard/intersectsFrontCourtyard/intersectsBackCourtyard.
bool footprint_selected(const std::string &selector, const std::string &reference, const std::string &lib_id)
KiCad's footprint selector (testFootprintSelector): a reference wildcard, or, when the selector conta...
CourtyardCache build_courtyards(const model::Board &board)
Build once per board; invalid/unclosed contours leave the corresponding side empty and marked unreada...
std::vector< CourtyardEntry > entries
bool back
footprint flipped to the bottom side
std::array< CourtyardRegion, 2 > sides
physical F.CrtYd, B.CrtYd
bool unreadable
The side has courtyard graphics, but they are not closed, simple outlines (or use a Bezier curve): no...
std::vector< std::vector< std::vector< geom::Point > > > parts
The courtyard is the union of the parts.