73 namespace fs = std::filesystem;
75 fs::path tmpDir = fs::temp_directory_path() /
"kicad_drc_length_chain";
76 fs::create_directories( tmpDir );
78 fs::path pcbPath = tmpDir /
"len_chain.kicad_pcb";
79 fs::path druPath = tmpDir /
"len_chain.kicad_dru";
82 std::ofstream pcbOut( pcbPath );
87 std::ofstream druOut( druPath );
92 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
93 plugin.
LoadBoard( pcbPath.string(), board.get() );
94 board->BuildConnectivity();
97 NETINFO_ITEM* chainNet = board->FindNet( wxS(
"/CHAIN_NET" ) );
101 NETINFO_ITEM* plainNet = board->FindNet( wxS(
"/PLAIN_NET" ) );
107 auto drcEngine = std::make_shared<DRC_ENGINE>( board.get(), &bds );
108 wxFileName ruleFile( druPath.string() );
109 drcEngine->InitEngine( ruleFile );
120 std::vector<DRC_ITEM> lengthViolations;
122 drcEngine->SetViolationHandler(
123 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I&,
int,
127 lengthViolations.push_back( *aItem );
135 "Expected per-net length violations on both chain and plain nets, got "
136 << lengthViolations.size() );
138 bool chainNetFlagged =
false;
139 bool plainNetFlagged =
false;
141 for(
const DRC_ITEM& item : lengthViolations )
143 for(
const KIID&
id : item.GetIDs() )
152 if( bci->GetNetCode() == chainNet->
GetNetCode() )
153 chainNetFlagged =
true;
155 if( bci->GetNetCode() == plainNet->
GetNetCode() )
156 plainNetFlagged =
true;
165 fs::remove( pcbPath, ec );
166 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 ...