74 namespace fs = std::filesystem;
76 fs::path tmpDir = fs::temp_directory_path() /
"kicad_drc_length_chain";
77 fs::create_directories( tmpDir );
79 fs::path pcbPath = tmpDir /
"len_chain.kicad_pcb";
80 fs::path druPath = tmpDir /
"len_chain.kicad_dru";
83 std::ofstream pcbOut( pcbPath );
88 std::ofstream druOut( druPath );
93 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
94 plugin.
LoadBoard( pcbPath.string(), board.get() );
95 board->BuildConnectivity();
98 NETINFO_ITEM* chainNet = board->FindNet( wxS(
"/CHAIN_NET" ) );
102 NETINFO_ITEM* plainNet = board->FindNet( wxS(
"/PLAIN_NET" ) );
108 auto drcEngine = std::make_shared<DRC_ENGINE>( board.get(), &bds );
109 wxFileName ruleFile( druPath.string() );
110 drcEngine->InitEngine( ruleFile );
121 std::vector<DRC_ITEM> lengthViolations;
123 drcEngine->SetViolationHandler(
124 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I&,
int,
128 lengthViolations.push_back( *aItem );
136 "Expected per-net length violations on both chain and plain nets, got "
137 << lengthViolations.size() );
139 bool chainNetFlagged =
false;
140 bool plainNetFlagged =
false;
142 for(
const DRC_ITEM& item : lengthViolations )
144 for(
const KIID&
id : item.GetIDs() )
153 if( bci->GetNetCode() == chainNet->
GetNetCode() )
154 chainNetFlagged =
true;
156 if( bci->GetNetCode() == plainNet->
GetNetCode() )
157 plainNetFlagged =
true;
166 fs::remove( pcbPath, ec );
167 fs::remove( druPath, ec );
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr) override
Load information from some input file format that this PCB_IO implementation knows about into either ...