60 namespace fs = std::filesystem;
62 fs::path tmpDir = fs::temp_directory_path() /
"kicad_drc_length_chain";
63 fs::create_directories( tmpDir );
65 fs::path druPath = tmpDir /
"len_chain.kicad_dru";
68 std::ofstream druOut( druPath );
73 std::unique_ptr<BOARD> board = std::make_unique<BOARD>();
75 board->BuildConnectivity();
78 NETINFO_ITEM* chainNet = board->FindNet( wxS(
"/CHAIN_NET" ) );
82 NETINFO_ITEM* plainNet = board->FindNet( wxS(
"/PLAIN_NET" ) );
88 auto drcEngine = std::make_shared<DRC_ENGINE>( board.get(), &bds );
89 wxFileName ruleFile( druPath.string() );
90 drcEngine->InitEngine( ruleFile );
101 std::vector<DRC_ITEM> lengthViolations;
103 drcEngine->SetViolationHandler(
104 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2I&,
int,
108 lengthViolations.push_back( *aItem );
115 BOOST_CHECK_MESSAGE( lengthViolations.size() >= 2,
116 "Expected per-net length violations on both chain and plain nets, got "
117 << lengthViolations.size() );
119 bool chainNetFlagged =
false;
120 bool plainNetFlagged =
false;
122 for(
const DRC_ITEM& item : lengthViolations )
124 for(
const KIID&
id : item.GetIDs() )
133 if( bci->GetNetCode() == chainNet->
GetNetCode() )
134 chainNetFlagged =
true;
136 if( bci->GetNetCode() == plainNet->
GetNetCode() )
137 plainNetFlagged =
true;
142 BOOST_CHECK_MESSAGE( chainNetFlagged,
"Length violation missing for chain-bearing net" );
143 BOOST_CHECK_MESSAGE( plainNetFlagged,
"Length violation missing for non-chain net" );
146 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 ...