81 std::unique_ptr<BOARD> board = LoadAllegroBoard(
"TRS80_POWER/TRS80_POWER.brd" );
85 int emptyRefDesCount = 0;
86 int validRefDesCount = 0;
88 for(
FOOTPRINT* fp : board->Footprints() )
90 wxString refdes = fp->GetReference();
92 if( refdes.IsEmpty() )
98 BOOST_TEST_MESSAGE(
"Valid RefDes: " << validRefDesCount <<
", Empty: " << emptyRefDesCount );
101 BOOST_CHECK_GT( validRefDesCount, emptyRefDesCount );
110 std::unique_ptr<BOARD> board = LoadAllegroBoard(
"TRS80_POWER/TRS80_POWER.brd" );
114 int unreferenced = 0;
116 for(
FOOTPRINT* fp : board->Footprints() )
118 if( !fp->GetReference().IsEmpty() )
125 BOOST_CHECK_GT( unreferenced, 0 );
134 std::unique_ptr<BOARD> board = LoadAllegroBoard(
"TRS80_POWER/TRS80_POWER.brd" );
140 for(
FOOTPRINT* fp : board->Footprints() )
142 BOOST_TEST_MESSAGE( fp->GetReference() <<
" -> " << fp->GetFPID().GetLibItemName().wx_str() );
144 if( !fp->GetReference().IsEmpty() && fp->GetFPID().GetLibItemName().empty() )
147 BOOST_CHECK( fp->GetFPID().GetLibNickname().empty() );
159 std::unique_ptr<BOARD> board = LoadAllegroBoard(
"EVK_BaseBoard/EVK_BaseBoard.brd" );
165 for(
FOOTPRINT* fp : board->Footprints() )
167 for(
PAD*
pad : fp->Pads() )
169 pad->Padstack().ForEachUniqueLayer(
172 if(
pad->GetSize( layer ).x <= 0 ||
pad->GetSize( layer ).y <= 0 )
187 const char* corpusEnv = std::getenv(
"KICAD_ORCAD_CORPUS" );
189 if( !corpusEnv || !*corpusEnv )
192 std::filesystem::path brd;
194 for(
const std::filesystem::directory_entry& entry : std::filesystem::recursive_directory_iterator( corpusEnv ) )
196 if( entry.is_regular_file() && entry.path().filename() ==
"EDA-02862-V1-0.brd" )
203 std::unique_ptr<BOARD> board = m_allegroPlugin.LoadBoard( brd.string() );
207 for(
FOOTPRINT* fp : board->Footprints() )
209 std::unique_ptr<FOOTPRINT>
copy(
static_cast<FOOTPRINT*
>( fp->Clone() ) );
220 const char* corpusEnv = std::getenv(
"KICAD_ORCAD_CORPUS" );
222 if( !corpusEnv || !*corpusEnv )
225 std::filesystem::path brd;
227 for(
const std::filesystem::directory_entry& entry : std::filesystem::recursive_directory_iterator( corpusEnv ) )
229 if( entry.is_regular_file() && entry.path().filename() ==
"EDA-02152-V1-0.brd" )
236 std::unique_ptr<BOARD> board = m_allegroPlugin.LoadBoard( brd.string() );
248 std::unique_ptr<BOARD> board = LoadAllegroBoard(
"EVK_BaseBoard/EVK_BaseBoard.brd" );
270 const char* corpusEnv = std::getenv(
"KICAD_ORCAD_CORPUS" );
272 if( !corpusEnv || !*corpusEnv )
275 std::filesystem::path brd;
277 for(
const std::filesystem::directory_entry& entry : std::filesystem::recursive_directory_iterator( corpusEnv ) )
279 if( entry.is_regular_file() && entry.path().filename() ==
"EDA-02152-V1-0.brd" )
286 std::unique_ptr<BOARD> board = m_allegroPlugin.LoadBoard( brd.string() );
310 const char* corpusEnv = std::getenv(
"KICAD_ORCAD_CORPUS" );
312 if( !corpusEnv || !*corpusEnv )
315 std::filesystem::path brd;
317 for(
const std::filesystem::directory_entry& entry : std::filesystem::recursive_directory_iterator( corpusEnv ) )
319 if( entry.is_regular_file() && entry.path().filename() ==
"USB-PD w QC3_0.brd" )
326 std::unique_ptr<BOARD> board = m_allegroPlugin.LoadBoard( brd.string() );
330 FOOTPRINT* tie = board->FindFootprintByReference( wxS(
"NT1" ) );
343 const char* corpusEnv = std::getenv(
"KICAD_ORCAD_CORPUS" );
345 if( !corpusEnv || !*corpusEnv )
350 const std::map<std::string, std::pair<int, int>>
expected = { {
"EDA-02016-V8-0.brd", { 43, 4 } },
351 {
"EDA-03470-V1-0.brd", { 138, 0 } } };
353 std::map<std::string, std::filesystem::path> boards;
355 for(
const std::filesystem::directory_entry& entry : std::filesystem::recursive_directory_iterator( corpusEnv ) )
357 if( entry.is_regular_file() &&
expected.count( entry.path().filename().string() ) )
358 boards[entry.path().filename().string()] = entry.path();
361 for(
const auto& [
name, brd] : boards )
365 std::unique_ptr<BOARD> board = m_allegroPlugin.LoadBoard( brd.string() );
372 for(
FOOTPRINT* fp : board->Footprints() )
374 for(
PAD*
pad : fp->Pads() )
379 const LSET layers =
pad->GetLayerSet();
401 const char* corpusEnv = std::getenv(
"KICAD_ORCAD_CORPUS" );
403 if( !corpusEnv || !*corpusEnv )
406 std::filesystem::path brd;
408 for(
const std::filesystem::directory_entry& entry : std::filesystem::recursive_directory_iterator( corpusEnv ) )
410 if( entry.is_regular_file() && entry.path().filename() ==
"600-20192-01_CYW920822M2P4XXI040_REV1.0.brd" )
417 std::unique_ptr<BOARD> board = m_allegroPlugin.LoadBoard( brd.string() );
421 FOOTPRINT* edge = board->FindFootprintByReference( wxS(
"J1" ) );
440 const char* corpusEnv = std::getenv(
"KICAD_ORCAD_CORPUS" );
442 if( !corpusEnv || !*corpusEnv )
445 std::filesystem::path brd;
447 for(
const std::filesystem::directory_entry& entry : std::filesystem::recursive_directory_iterator( corpusEnv ) )
449 if( entry.is_regular_file() && entry.path().filename() ==
"EDA-02067-V1-0.brd" )
456 std::unique_ptr<BOARD> board = m_allegroPlugin.LoadBoard( brd.string() );
480 const char* corpusEnv = std::getenv(
"KICAD_ORCAD_CORPUS" );
482 if( !corpusEnv || !*corpusEnv )
485 std::filesystem::path brd;
487 for(
const std::filesystem::directory_entry& entry : std::filesystem::recursive_directory_iterator( corpusEnv ) )
489 if( entry.is_regular_file() && entry.path().filename() ==
"EDA-02153-V1-0.brd" )
496 std::unique_ptr<BOARD> board = m_allegroPlugin.LoadBoard( brd.string() );
500 int planePolygons = 0;
512 for(
ZONE* zone : board->Zones() )
514 if( !zone->GetIsRuleArea() &&
IsInnerCopperLayer( zone->GetFirstLayer() ) && zone->GetNetCode() > 0 )
519 BOOST_CHECK( zone->GetLocalClearance().has_value() );
526 BOOST_CHECK_GT( planeZones, 0 );
530 int filledPlanes = 0;
533 for(
ZONE* zone : board->Zones() )
537 if( !zone->GetIsRuleArea() &&
IsInnerCopperLayer( layer ) && zone->HasFilledPolysForLayer( layer )
538 && !zone->GetFilledPolysList( layer )->IsEmpty() )
544 for(
PCB_TRACK* track : board->Tracks() )
549 for(
ZONE* zone : board->Zones() )
553 if( zone->GetIsRuleArea() || zone->GetNetCode() == track->GetNetCode() || !
IsInnerCopperLayer( layer )
554 || !track->IsOnLayer( layer ) || !zone->HasFilledPolysForLayer( layer ) )
559 if( zone->GetFilledPolysList( layer )->Collide( track->GetEffectiveShape( layer ).get() ) )
564 BOOST_CHECK_GT( filledPlanes, 0 );
574 std::unique_ptr<BOARD> board = LoadAllegroBoard(
"EVK_BaseBoard/EVK_BaseBoard.brd" );
578 std::vector<ZONE*> voids;
580 for(
ZONE* zone : board->Zones() )
582 if( zone->GetIsRuleArea() && zone->GetZoneName() == wxS(
"Plane void" ) )
583 voids.push_back( zone );
589 for(
ZONE* area : voids )
596 for(
ZONE* area : voids )
600 for(
ZONE* zone : board->Zones() )
602 if( zone->GetIsRuleArea() || !zone->IsOnLayer( layer ) || !zone->HasFilledPolysForLayer( layer ) )
607 overlap += common.
Area();
612 BOOST_CHECK_LT( overlap, 1e10 );
621 for(
const char*
name : {
"EVK_BaseBoard/EVK_BaseBoard.brd",
"EVK_SOM/EVK_SOM.brd",
622 "BeagleBone-AI/BeagleBone-AI.brd",
"CutiePi_V2_3_v166/CutiePi_V2_3.brd",
623 "mainBoard/mainBoard.brd",
"ABX00162_UNOQ/20250806_UNOQ.brd" } )
625 std::unique_ptr<BOARD> board = LoadAllegroBoard(
name );
631 for(
FOOTPRINT* fp : board->Footprints() )
633 for(
PAD*
pad : fp->Pads() )
640 if(
pad->GetEffectivePolygon( layer )->OutlineCount() != 1 )
656 std::unique_ptr<BOARD> board = LoadAllegroBoard(
"TRS80_POWER/TRS80_POWER.brd" );
660 int validPadCount = 0;
661 int zeroPadCount = 0;
662 int hugePadCount = 0;
664 for(
FOOTPRINT* fp : board->Footprints() )
666 for(
PAD*
pad : fp->Pads() )
670 if( size.
x == 0 || size.
y == 0 )
674 <<
pad->GetNumber() );
676 else if( size.
x > 50000000 || size.
y > 50000000 )
680 <<
": " << size.
x / 1000000.0 <<
"mm x "
681 << size.
y / 1000000.0 <<
"mm" );
691 <<
", Huge: " << hugePadCount );
703 std::unique_ptr<BOARD> board = LoadAllegroBoard(
"TRS80_POWER/TRS80_POWER.brd" );
707 int validViaCount = 0;
708 int suspiciousViaCount = 0;
711 const int HARDCODED_SIZE = 1000000;
713 for(
PCB_TRACK* track : board->Tracks() )
718 int width =
via->GetWidth(
F_Cu );
720 if( width == HARDCODED_SIZE )
722 suspiciousViaCount++;
724 else if( width > 0 && width < 10000000 )
731 BOOST_TEST_MESSAGE(
"Valid vias: " << validViaCount <<
", Hardcoded-size vias: " << suspiciousViaCount );
734 if( suspiciousViaCount > 0 )
736 BOOST_WARN_MESSAGE(
false,
"Found " << suspiciousViaCount <<
" vias with hardcoded 1mm size" );
746 std::unique_ptr<BOARD> board = LoadAllegroBoard(
"TRS80_POWER/TRS80_POWER.brd" );
750 int validTrackCount = 0;
751 int zeroTrackCount = 0;
753 for(
PCB_TRACK* track : board->Tracks() )
757 int width = track->GetWidth();
761 else if( width > 0 && width < 10000000 )
766 BOOST_TEST_MESSAGE(
"Valid tracks: " << validTrackCount <<
", Zero-width: " << zeroTrackCount );
777 std::unique_ptr<BOARD> board = LoadAllegroBoard(
"TRS80_POWER/TRS80_POWER.brd" );
781 int numberedPads = 0;
782 int unnumberedPads = 0;
784 for(
FOOTPRINT* fp : board->Footprints() )
786 for(
PAD*
pad : fp->Pads() )
788 if(
pad->GetNumber().IsEmpty() )
795 BOOST_TEST_MESSAGE(
"Numbered pads: " << numberedPads <<
", Unnumbered: " << unnumberedPads );
799 if( unnumberedPads > 0 )
801 BOOST_WARN_MESSAGE(
false,
"Found " << unnumberedPads <<
" pads without numbers" );
823 std::vector<SEG> outlineSegs;
847 outlineSegs.push_back( seg );
855 for(
size_t i = 0; i < polyPoints.size() - 1; i++ )
858 VECTOR2I end = polyPoints[( i + 1 ) % polyPoints.size()];
859 outlineSegs.emplace_back( start,
end );
869 false,
"Unexpected shape type in board outline: " <<
static_cast<int>( shape->
GetShape() ) );
874 if( !outlineSegs.empty() )
878 int connectedCount = 0;
880 for(
const SEG& seg : outlineSegs )
882 for(
const SEG& other : outlineSegs )
888 if( seg.A == other.A || seg.A == other.B )
892 if( seg.B == other.A || seg.B == other.B )
900 BOOST_CHECK_GE( connectedCount, outlineSegs.size() * 2 );
910 std::unique_ptr<BOARD> board = LoadAllegroBoard(
"TRS80_POWER/TRS80_POWER.brd" );
920 BOOST_CHECK_GE( outlineSegmentCount, 1 );
931 std::unique_ptr<BOARD> board = LoadAllegroBoard(
"TRS80_POWER/TRS80_POWER.brd" );
937 bool hasBbox =
false;
945 boardBbox = item->GetBoundingBox();
950 boardBbox.
Merge( item->GetBoundingBox() );
961 BOX2I testBbox = boardBbox;
964 for(
FOOTPRINT* fp : board->Footprints() )
966 for(
PAD*
pad : fp->Pads() )
970 if( testBbox.
Contains( padCenter ) )
978 <<
pad->GetNumber() <<
" at ("
979 << padCenter.
x / 1000000.0 <<
", "
980 << padCenter.
y / 1000000.0 <<
") mm" );
985 BOOST_TEST_MESSAGE(
"Pads inside outline: " << padsInside <<
", outside: " << padsOutside );
989 if( padsOutside > 0 )
991 BOOST_WARN_MESSAGE(
false,
"Found " << padsOutside <<
" pads outside board outline" );
995 BOOST_CHECK_GT( padsInside, padsOutside );
1005 BOOST_CHECK_EXCEPTION(
1006 LoadAllegroBoard(
"v13_header/v13_header.brd" ),
IO_ERROR,
1009 wxString msg = e.
What();
1011 return msg.Contains( wxS(
"predates Allegro 16.0" ) )
1012 && msg.Contains( wxS(
"Allegro PCB Design" ) );
1024 std::unique_ptr<BOARD> board = LoadAllegroBoard(
"rects/rects.brd" );
1030 ZONE* zone = board->Zones().front();
1036 int copperPolyCount = 0;
1037 int copperPolyWithNet = 0;
1050 copperPolyWithNet++;
1065 std::unique_ptr<BOARD> board = LoadAllegroBoard(
"copper_text/copper_text.brd" );
1068 int copperTextCount = 0;
1069 bool foundTestingText =
false;
1081 if(
text->GetText() == wxS(
"TESTING" ) )
1083 foundTestingText =
true;
1090 BOOST_CHECK_MESSAGE( foundTestingText,
"Board should contain 'TESTING' text on F.Cu" );
1099 std::unique_ptr<BOARD> board = LoadAllegroBoard(
"TRS80_POWER/TRS80_POWER.brd" );
1101 const auto netOf = [](
const BOARD_ITEM* aItem )
1109 if( aFirst->
Type() != aSecond->Type() || aFirst->
GetLayer() != aSecond->GetLayer()
1110 || netOf( aFirst ) != netOf( aSecond ) )
1117 return static_cast<const PCB_SHAPE*
>( aFirst )->Compare(
1118 static_cast<const PCB_SHAPE*
>( aSecond ) ) == 0;
1123 return static_cast<const PCB_TEXT*
>( aFirst )->Compare(
1124 static_cast<const PCB_TEXT*
>( aSecond ) ) == 0;
1130 const auto countCoincident = [&](
const DRAWINGS& aItems )
1134 for(
size_t ii = 0; ii < aItems.size(); ++ii )
1136 for(
size_t jj = ii + 1; jj < aItems.size(); ++jj )
1138 if( coincident( aItems[ii], aItems[jj] ) )
1151 for(
FOOTPRINT* footprint : board->Footprints() )
1161 const auto collectIds = [](
const BOARD& aBoard )
1163 std::vector<wxString> ids;
1165 std::function<void(
const BOARD_ITEM* )> walk =
1168 ids.push_back( aItem->m_Uuid.AsString() );
1174 aItem->RunOnChildren(
1182 for(
const BOARD_ITEM* item :
const_cast<BOARD&
>( aBoard ).GetItemSet() )
1185 std::sort( ids.begin(), ids.end() );
1189 std::unique_ptr<BOARD> first = LoadAllegroBoard(
"ProiectBoard/ProiectBoard.brd" );
1190 std::unique_ptr<BOARD> second = LoadAllegroBoard(
"ProiectBoard/ProiectBoard.brd" );
1192 const std::vector<wxString> firstIds = collectIds( *first );
1193 const std::vector<wxString> secondIds = collectIds( *second );
1199 BOOST_CHECK( std::adjacent_find( firstIds.begin(), firstIds.end() ) == firstIds.end() );
1207 std::unique_ptr<BOARD> board = LoadAllegroBoard(
"led_youtube/led_youtube.brd" );
1210 std::map<wxString, FP_3DMODEL> models;
1212 for(
FOOTPRINT* fp : board->Footprints() )
1215 models.emplace( fp->Models().front().m_Filename, fp->Models().front() );
1224 const FP_3DMODEL& conn = models.at( wxS(
"22272021.stp" ) );
1226 BOOST_CHECK_CLOSE( conn.
m_Offset.
x, 0.02, 1e-6 );
1227 BOOST_CHECK_CLOSE( conn.
m_Offset.
y, -1.27, 1e-6 );
1228 BOOST_CHECK_CLOSE( conn.
m_Offset.
z, 1.580007, 1e-6 );
1229 BOOST_CHECK_CLOSE( conn.
m_Rotation.
x, -90.0, 1e-6 );
1231 BOOST_CHECK_CLOSE( conn.
m_Rotation.
z, -90.0, 1e-6 );
1241 std::unique_ptr<BOARD> board = LoadAllegroBoard(
"issue25654/MIPI_Camera_Sub.brd" );
1245 std::shared_ptr<NET_SETTINGS> netSettings = board->GetDesignSettings().m_NetSettings;
1247 BOOST_REQUIRE( netSettings->HasNetclass( wxS(
"DP_CSI_A_CLK" ) ) );
1248 BOOST_CHECK_EQUAL( netSettings->GetNetclasses().at( wxS(
"DP_CSI_A_CLK" ) )->GetClearance(), 177800 );
1252 if( net->GetNetCode() > 0 )
1293 std::vector<std::string> boards;
1299 for(
const auto& boardDir : std::filesystem::directory_iterator( dataPath ) )
1301 if( !boardDir.is_directory() )
1304 for(
const auto& entry : std::filesystem::directory_iterator( boardDir ) )
1306 if( entry.is_regular_file() && entry.path().extension() ==
".brd" && entry.file_size() > 0 )
1308 std::string
name = entry.path().filename().string();
1311 if(
name !=
"v13_header.brd" )
1313 boards.push_back( boardDir.path().string() +
"/" +
name );
1319 catch(
const std::filesystem::filesystem_error& e )
1324 std::sort( boards.begin(), boards.end() );
1343 BOARD* board = GetCachedBoard( dataPath );
1346 const std::vector<wxString> expectedLayers = { wxS(
"TOP" ), wxS(
"LYR2_GND" ),
1347 wxS(
"LYR5_PWR" ), wxS(
"BOTTOM" ) };
1349 for(
const wxString& layerName : expectedLayers )
1356 "Layer " << layerName <<
" should exist" );
1358 const ZONE* largest =
nullptr;
1359 double largestArea = 0;
1361 for(
const ZONE* zone : board->
Zones() )
1363 if( zone->GetIsRuleArea() )
1366 if( zone->GetNetCode() == 0 )
1369 if( !zone->GetLayerSet().Contains( layerId ) )
1372 BOX2I bbox = zone->GetBoundingBox();
1373 double area =
static_cast<double>( bbox.
GetWidth() )
1374 *
static_cast<double>( bbox.
GetHeight() );
1376 if( area > largestArea )
1384 "Should find a netted copper zone on " << layerName );
1396 std::vector<std::string> boards = GetAllBoardFiles();
1398 for(
const std::string& boardPath : boards )
1400 std::string boardName = std::filesystem::path( boardPath ).filename().string();
1401 BOARD* board = GetCachedBoard( boardPath );
1408 int negativePadCount = 0;
1412 for(
PAD*
pad : fp->Pads() )
1416 if( size.
x < 0 || size.
y < 0 )
1420 <<
" pad " <<
pad->GetNumber() <<
": " << size.
x <<
" x "
1438 std::vector<std::string> boards = GetAllBoardFiles();
1440 for(
const std::string& boardPath : boards )
1442 std::string boardName = std::filesystem::path( boardPath ).filename().string();
1443 BOARD* board = GetCachedBoard( boardPath );
1450 int invalidViaCount = 0;
1457 int drill =
via->GetDrill();
1458 int width =
via->GetWidth(
F_Cu );
1464 <<
via->GetPosition().x / 1000000.0 <<
", "
1465 <<
via->GetPosition().y / 1000000.0
1466 <<
") has drill " << drill / 1000000.0
1467 <<
"mm > width " << width / 1000000.0 <<
"mm" );
1484 std::vector<std::string> boards = GetAllBoardFiles();
1486 for(
const std::string& boardPath : boards )
1488 std::string boardName = std::filesystem::path( boardPath ).filename().string();
1489 BOARD* board = GetCachedBoard( boardPath );
1496 int misclassifiedSmdCount = 0;
1497 int correctSmdCount = 0;
1498 int correctThCount = 0;
1502 for(
PAD*
pad : fp->Pads() )
1504 bool hasDrill =
pad->GetDrillSize().x > 0 &&
pad->GetDrillSize().y > 0;
1509 misclassifiedSmdCount++;
1511 <<
"." <<
pad->GetNumber()
1512 <<
" has no drill but is marked as PTH (should be SMD)" );
1526 <<
", Correct TH=" << correctThCount
1527 <<
", Misclassified=" << misclassifiedSmdCount );
1541 std::vector<std::string> boards = GetAllBoardFiles();
1543 for(
const std::string& boardPath : boards )
1545 std::string boardName = std::filesystem::path( boardPath ).filename().string();
1546 BOARD* board = GetCachedBoard( boardPath );
1553 int quadPackageCount = 0;
1554 int packagesWithRotatedPads = 0;
1555 int packagesWithUnrotatedPads = 0;
1559 wxString refdes = fp->GetReference().Upper();
1562 if( !refdes.StartsWith(
"U" ) )
1566 if( fp->Pads().size() < 16 )
1573 for(
PAD*
pad : fp->Pads() )
1584 padBounds.
Merge( pos );
1592 if( width == 0 || height == 0 )
1595 double aspectRatio =
static_cast<double>( std::max( width, height ) ) /
1596 static_cast<double>( std::min( width, height ) );
1598 if( aspectRatio > 2.0 )
1604 std::set<int> uniqueAngles;
1606 for(
PAD*
pad : fp->Pads() )
1610 int degrees =
static_cast<int>( angle.
AsDegrees() + 0.5 ) % 360;
1611 uniqueAngles.insert( degrees );
1616 if( uniqueAngles.size() >= 2 )
1618 packagesWithRotatedPads++;
1620 <<
" has " << uniqueAngles.size() <<
" unique pad orientations" );
1624 packagesWithUnrotatedPads++;
1626 <<
" has only " << uniqueAngles.size()
1627 <<
" unique pad orientation (may be missing rotation)" );
1631 if( quadPackageCount > 0 )
1634 <<
" potential quad packages, "
1635 << packagesWithRotatedPads <<
" with rotated pads, "
1636 << packagesWithUnrotatedPads <<
" without" );
1640 if( packagesWithRotatedPads == 0 && quadPackageCount > 0 )
1642 BOOST_WARN_MESSAGE(
false, boardName <<
" has no packages with rotated pads" );
1659 BOARD* board = GetCachedBoard( dataPath );
1667 if( fp->GetReference() ==
"C78" )
1681 BOOST_CHECK_MESSAGE( fpLayer ==
B_Cu,
"C78 should be on the bottom copper layer (B_Cu), got "
1683 BOOST_CHECK_MESSAGE( c78->
IsFlipped(),
"C78 should be flipped (IsFlipped() == true)" );
1687 int bottomCount = 0;
1691 if( fp->GetLayer() ==
F_Cu )
1693 else if( fp->GetLayer() ==
B_Cu )
1697 BOOST_TEST_MESSAGE(
"Footprints on top: " << topCount <<
", on bottom: " << bottomCount );
1700 BOOST_CHECK_GT( topCount, 0 );
1701 BOOST_CHECK_GT( bottomCount, 0 );
1711 std::vector<std::string> boards = GetAllBoardFiles();
1713 for(
const std::string& boardPath : boards )
1715 std::string boardName = std::filesystem::path( boardPath ).filename().string();
1716 BOARD* board = GetCachedBoard( boardPath );
1724 int disconnectedArcs = 0;
1727 std::map<int, std::vector<VECTOR2I>> netEndpoints;
1731 int netCode = track->GetNetCode();
1735 netEndpoints[netCode].push_back( track->GetStart() );
1736 netEndpoints[netCode].push_back( track->GetEnd() );
1740 netEndpoints[netCode].push_back( track->GetPosition() );
1747 for(
PAD*
pad : fp->Pads() )
1749 int netCode =
pad->GetNetCode();
1752 netEndpoints[netCode].push_back(
pad->GetPosition() );
1770 bool startConnected =
false;
1771 bool endConnected =
false;
1772 const int tolerance = 1000;
1774 for(
const VECTOR2I& pt : netEndpoints[netCode] )
1776 if( ( pt - arcStart ).EuclideanNorm() < tolerance )
1777 startConnected =
true;
1779 if( ( pt - arcEnd ).EuclideanNorm() < tolerance )
1780 endConnected =
true;
1785 if( !startConnected && !endConnected && netEndpoints[netCode].size() > 2 )
1789 << arcStart.
x / 1000000.0 <<
", "
1790 << arcStart.
y / 1000000.0 <<
") to ("
1791 << arcEnd.
x / 1000000.0 <<
", "
1792 << arcEnd.
y / 1000000.0
1793 <<
") appears disconnected from net " << netCode );
1800 << disconnectedArcs <<
" disconnected" );
1807 BOOST_CHECK_LE( disconnectedArcs, arcCount / 5 );
1859 std::vector<wxString> fields;
1862 for(
size_t i = 0; i < aLine.size(); ++i )
1864 if( aLine[i] ==
'!' )
1866 fields.push_back( current );
1871 current += aLine[i];
1875 if( !current.empty() )
1876 fields.push_back( current );
1888 wxString tag = aTag.BeforeFirst(
' ' );
1890 return static_cast<int>( val );
1895 static std::map<std::string, ALG_REFERENCE_DATA> cache;
1897 auto it = cache.find( aPath );
1899 if( it == cache.end() )
1900 it = cache.emplace( aPath,
ParseAlgFile( aPath ) ).first;
1908 std::ifstream file( aPath );
1910 if( !file.is_open() )
1921 SECTION currentSection = SECTION::UNKNOWN;
1927 while( std::getline( file, line ) )
1929 if( line.empty() || line[0] ==
'J' )
1932 if( line[0] ==
'A' )
1934 if( line.find(
"NET_NAME_SORT!NODE_SORT!NET_NAME!REFDES!" ) != std::string::npos )
1935 currentSection = SECTION::NET_NODES;
1936 else if( line.find(
"SYM_TYPE!SYM_NAME!REFDES!SYM_MIRROR!" ) != std::string::npos )
1937 currentSection = SECTION::SYM_PLACEMENT;
1938 else if( line.find(
"CLASS!SUBCLASS!RECORD_TAG!GRAPHIC_DATA_NAME!" ) != std::string::npos )
1939 currentSection = SECTION::GRAPHICS;
1941 currentSection = SECTION::UNKNOWN;
1946 if( line[0] !=
'S' )
1949 auto fields =
SplitAlgLine( wxString::FromUTF8( line ) );
1951 switch( currentSection )
1953 case SECTION::NET_NODES:
1956 if( fields.size() >= 5 )
1958 wxString netName = fields[3];
1959 wxString refdes = fields[4];
1961 if( !netName.empty() )
1965 if( !refdes.empty() )
1972 case SECTION::SYM_PLACEMENT:
1975 if( fields.size() >= 4 )
1977 wxString symType = fields[1];
1978 wxString symName = fields[2];
1979 wxString refdes = fields[3];
1981 if( symType == wxT(
"PACKAGE" ) && !refdes.empty() )
1983 data.
refDes.insert( refdes );
1990 case SECTION::GRAPHICS:
1996 if( fields.size() < 16 || fields[1] != wxT(
"BOUNDARY" ) )
1999 wxString closureType = fields[15];
2001 if( closureType != wxT(
"SHAPE" ) )
2004 wxString layer = fields[2];
2012 if( fields.size() > 23 )
2013 netName = fields[23];
2015 auto key = std::make_pair( layer, recordId );
2016 auto& zone = zoneMap[key];
2018 zone.recordId = recordId;
2020 if( !netName.empty() )
2021 zone.netName = netName;
2023 double x1 = 0, y1 = 0, x2 = 0, y2 = 0;
2025 if( fields.size() > 9 )
2027 fields[6].ToDouble( &x1 );
2028 fields[7].ToDouble( &y1 );
2029 fields[8].ToDouble( &x2 );
2030 fields[9].ToDouble( &y2 );
2031 zone.AddPoint( x1, y1 );
2032 zone.AddPoint( x2, y2 );
2042 for(
auto& [key, zone] : zoneMap )
2064 std::vector<BRD_ALG_PAIR> boardsWithAlg;
2066 for(
const auto& boardDir : std::filesystem::directory_iterator( dataPath ) )
2068 if( !boardDir.is_directory() )
2071 std::filesystem::path boardPath;
2072 std::filesystem::path algPath;
2074 for(
const auto& entry : std::filesystem::directory_iterator( boardDir ) )
2076 if( !entry.is_regular_file() )
2079 if( entry.path().extension() ==
".brd" )
2080 boardPath = entry.path();
2081 else if( entry.path().extension() ==
".alg" )
2082 algPath = entry.path();
2084 if( !boardPath.empty() && !algPath.empty() )
2086 boardsWithAlg.push_back( { boardPath.string(), algPath.string() } );
2092 return boardsWithAlg;
2103 BOOST_REQUIRE_GT( boardsWithAlg.size(), 0u );
2105 for(
const auto& [brdFile, algFile] : boardsWithAlg )
2110 BOOST_REQUIRE_GT( algData.
netNames.size(), 0u );
2112 BOARD* board = GetCachedBoard( brdFile );
2115 std::set<wxString> boardNets;
2119 if( net->GetNetCode() > 0 )
2120 boardNets.insert( net->GetNetname() );
2123 int missingNets = 0;
2125 for(
const wxString& algNet : algData.
netNames )
2127 if( boardNets.find( algNet ) == boardNets.end() )
2131 if( missingNets <= 10 )
2137 << boardNets.size() <<
", missing " << missingNets );
2151 BOOST_REQUIRE_GT( boardsWithAlg.size(), 0u );
2153 for(
const auto& [brdFile, algFile] : boardsWithAlg )
2158 BOOST_REQUIRE_GT( algData.
refDes.size(), 0u );
2160 BOARD* board = GetCachedBoard( brdFile );
2163 std::set<wxString> boardRefDes;
2166 boardRefDes.insert( fp->GetReference() );
2168 int missingRefDes = 0;
2169 int extraRefDes = 0;
2171 for(
const wxString& algRef : algData.
refDes )
2173 if( boardRefDes.find( algRef ) == boardRefDes.end() )
2177 if( missingRefDes <= 10 )
2182 for(
const wxString& boardRef : boardRefDes )
2184 if( algData.
refDes.find( boardRef ) == algData.
refDes.end() )
2188 if( extraRefDes <= 10 )
2194 <<
" components, board has " << boardRefDes.size()
2195 <<
", missing " << missingRefDes
2196 <<
", extra " << extraRefDes );
2208 std::vector<std::string> boards = GetAllBoardFiles();
2210 for(
const std::string& boardPath : boards )
2212 std::string boardName = std::filesystem::path( boardPath ).filename().string();
2213 BOARD* board = GetCachedBoard( boardPath );
2220 int zeroWidthCount = 0;
2229 if( track->GetWidth() <= 0 )
2233 if( zeroWidthCount <= 5 )
2236 << track->GetStart().x / 1000000.0 <<
", "
2237 << track->GetStart().y / 1000000.0 <<
")" );
2277 double minX = std::numeric_limits<double>::max();
2278 double minY = std::numeric_limits<double>::max();
2279 double maxX = std::numeric_limits<double>::lowest();
2280 double maxY = std::numeric_limits<double>::lowest();
2292 static std::map<std::string, ALG_OUTLINE_DATA> cache;
2294 auto it = cache.find( aPath );
2296 if( it == cache.end() )
2305 std::ifstream file( aPath );
2307 if( !file.is_open() )
2312 while( std::getline( file, line ) )
2314 if( line.empty() || line[0] !=
'S' )
2319 if( fields.size() < 10 )
2322 bool isDesignOutline = ( fields[1] == wxT(
"BOARD GEOMETRY" )
2323 && fields[2] == wxT(
"DESIGN_OUTLINE" ) );
2325 bool isOutline = ( fields[1] == wxT(
"BOARD GEOMETRY" )
2326 && fields[2] == wxT(
"OUTLINE" ) );
2328 if( !isDesignOutline && !isOutline )
2331 wxString shapeType = fields[4];
2334 if( shapeType == wxT(
"LINE" ) && fields.size() >= 10 )
2337 fields[6].ToCDouble( &seg.
x1 );
2338 fields[7].ToCDouble( &seg.
y1 );
2339 fields[8].ToCDouble( &seg.
x2 );
2340 fields[9].ToCDouble( &seg.
y2 );
2345 else if( shapeType == wxT(
"ARC" ) && fields.size() >= 15 )
2348 fields[6].ToCDouble( &seg.
x1 );
2349 fields[7].ToCDouble( &seg.
y1 );
2350 fields[8].ToCDouble( &seg.
x2 );
2351 fields[9].ToCDouble( &seg.
y2 );
2352 fields[10].ToCDouble( &seg.
centerX );
2353 fields[11].ToCDouble( &seg.
centerY );
2354 fields[12].ToCDouble( &seg.
radius );
2355 seg.
clockwise = ( fields[14] == wxT(
"CLOCKWISE" ) );
2360 else if( shapeType == wxT(
"RECTANGLE" ) && fields.size() >= 10 )
2363 fields[6].ToCDouble( &seg.
x1 );
2364 fields[7].ToCDouble( &seg.
y1 );
2365 fields[8].ToCDouble( &seg.
x2 );
2366 fields[9].ToCDouble( &seg.
y2 );
2376 if( isDesignOutline )
2420 BOOST_REQUIRE_GT( testBoards.size(), 0u );
2422 for(
const auto& [brdFile, algFile] : testBoards )
2434 BOARD* board = GetCachedBoard( brdFile );
2437 int edgeCutsCount = 0;
2448 <<
" -> expected Edge_Cuts segments: " << expectedCount );
2466 BOOST_REQUIRE_GT( testBoards.size(), 0u );
2469 const double milToNm = 25400.0;
2472 const int toleranceNm =
static_cast<int>( 2.0 * milToNm );
2474 for(
const auto& [brdFile, algFile] : testBoards )
2486 BOARD* board = GetCachedBoard( brdFile );
2490 bool hasBbox =
false;
2498 boardBbox = item->GetBoundingBox();
2503 boardBbox.
Merge( item->GetBoundingBox() );
2511 int algMinXnm =
static_cast<int>( algOutlines.
minX * milToNm );
2512 int algMinYnm =
static_cast<int>( algOutlines.
minY * milToNm );
2513 int algMaxXnm =
static_cast<int>( algOutlines.
maxX * milToNm );
2514 int algMaxYnm =
static_cast<int>( algOutlines.
maxY * milToNm );
2515 int algWidthNm = algMaxXnm - algMinXnm;
2516 int algHeightNm = algMaxYnm - algMinYnm;
2518 int boardWidth = boardBbox.
GetWidth();
2519 int boardHeight = boardBbox.
GetHeight();
2522 << algOutlines.
minX <<
"," << algOutlines.
minY <<
" to "
2523 << algOutlines.
maxX <<
"," << algOutlines.
maxY
2524 <<
" = " << ( algOutlines.
maxX - algOutlines.
minX ) <<
" x "
2525 << ( algOutlines.
maxY - algOutlines.
minY ) );
2527 << boardBbox.
GetLeft() <<
"," << boardBbox.
GetTop() <<
" to "
2529 <<
" = " << boardWidth <<
" x " << boardHeight );
2533 BOOST_CHECK_CLOSE(
static_cast<double>( boardWidth ),
2534 static_cast<double>( algWidthNm ), 3.0 );
2535 BOOST_CHECK_CLOSE(
static_cast<double>( boardHeight ),
2536 static_cast<double>( algHeightNm ), 3.0 );
2553 BOOST_REQUIRE_GT( testBoards.size(), 0u );
2555 const double milToNm = 25400.0;
2556 const int toleranceNm =
static_cast<int>( 2.0 * milToNm );
2558 for(
const auto& [brdFile, algFile] : testBoards )
2568 bool allLines =
true;
2586 BOARD* board = GetCachedBoard( brdFile );
2590 struct ENDPOINT_PAIR
2596 std::vector<ENDPOINT_PAIR> boardSegments;
2606 boardSegments.push_back( { shape->
GetStart(), shape->
GetEnd() } );
2610 std::vector<ENDPOINT_PAIR> algSegments;
2616 VECTOR2I start(
static_cast<int>( seg.x1 * milToNm ),
2617 static_cast<int>( seg.y1 * milToNm ) );
2618 VECTOR2I end(
static_cast<int>( seg.x2 * milToNm ),
2619 static_cast<int>( seg.y2 * milToNm ) );
2620 algSegments.push_back( { start,
end } );
2624 int x1 =
static_cast<int>( seg.x1 * milToNm );
2625 int y1 =
static_cast<int>( seg.y1 * milToNm );
2626 int x2 =
static_cast<int>( seg.x2 * milToNm );
2627 int y2 =
static_cast<int>( seg.y2 * milToNm );
2629 algSegments.push_back( { { x1, y1 }, { x2, y1 } } );
2630 algSegments.push_back( { { x2, y1 }, { x2, y2 } } );
2631 algSegments.push_back( { { x2, y2 }, { x1, y2 } } );
2632 algSegments.push_back( { { x1, y2 }, { x1, y1 } } );
2638 if( boardSegments.size() != algSegments.size() )
2644 int matchedCount = 0;
2646 std::vector<bool> used( boardSegments.size(),
false );
2648 for(
size_t ai = 0; ai < algSegments.size(); ++ai )
2650 const auto& algSeg = algSegments[ai];
2652 int64_t bestDist = std::numeric_limits<int64_t>::max();
2654 for(
size_t bi = 0; bi < boardSegments.size(); ++bi )
2659 const auto& bSeg = boardSegments[bi];
2662 auto dist = [&](
const VECTOR2I& aAlgPt,
const VECTOR2I& aBoardPt ) -> int64_t
2664 int64_t dx =
std::abs(
static_cast<int64_t
>( aAlgPt.
x )
2665 -
static_cast<int64_t
>( aBoardPt.x ) );
2666 int64_t dy =
std::abs(
static_cast<int64_t
>( aAlgPt.
y )
2667 -
static_cast<int64_t
>( aBoardPt.y ) );
2671 int64_t d1 = dist( algSeg.start, bSeg.start ) + dist( algSeg.end, bSeg.end );
2672 int64_t d2 = dist( algSeg.start, bSeg.end ) + dist( algSeg.end, bSeg.start );
2673 int64_t d = std::min( d1, d2 );
2678 bestIdx =
static_cast<int>( bi );
2682 if( bestIdx >= 0 && bestDist < 2LL * toleranceNm )
2684 used[bestIdx] =
true;
2690 << algSeg.start.x / 1000000.0 <<
", "
2691 << algSeg.start.y / 1000000.0 <<
") -> ("
2692 << algSeg.end.x / 1000000.0 <<
", "
2693 << algSeg.end.y / 1000000.0 <<
") mm"
2694 <<
" bestDist=" << bestDist );
2699 <<
" outline segments" );
2713 std::vector<std::string> boards = GetAllBoardFiles();
2715 for(
const std::string& boardPath : boards )
2717 std::string boardName = std::filesystem::path( boardPath ).filename().string();
2718 BOARD* board = GetCachedBoard( boardPath );
2726 int smdWithDrill = 0;
2730 for(
PAD*
pad : fp->Pads() )
2733 bool hasDrill =
pad->GetDrillSize().x > 0;
2739 if( pthNoDrill <= 5 )
2742 << fp->GetReference() <<
"."
2743 <<
pad->GetNumber() );
2751 if( smdWithDrill <= 5 )
2754 << fp->GetReference() <<
"."
2755 <<
pad->GetNumber() );
2775 BOOST_REQUIRE_GT( boardsWithAlg.size(), 0u );
2777 for(
const auto& [brdFile, algFile] : boardsWithAlg )
2783 BOARD* board = GetCachedBoard( brdFile );
2786 size_t boardCopperZoneLayers = 0;
2788 for(
const ZONE* zone : board->
Zones() )
2790 if( !zone->GetIsRuleArea() )
2791 boardCopperZoneLayers += ( zone->GetLayerSet() &
LSET::AllCuMask() ).count();
2797 <<
" zone polygons, board has " << boardCopperZoneLayers
2798 <<
" copper zone-layers" );
2800 BOOST_CHECK_EQUAL(
static_cast<size_t>( boardCopperZoneLayers ), algZoneCount );
2813 BOOST_REQUIRE_GT( boardsWithAlg.size(), 0u );
2815 for(
const auto& [brdFile, algFile] : boardsWithAlg )
2821 BOARD* board = GetCachedBoard( brdFile );
2824 std::map<wxString, int> algLayerCounts;
2827 algLayerCounts[zone.
layer]++;
2829 std::map<wxString, int> boardLayerCounts;
2831 for(
const ZONE* zone : board->
Zones() )
2833 if( zone->GetIsRuleArea() )
2845 for(
const auto& [layer, count] : algLayerCounts )
2847 auto it = boardLayerCounts.find( layer );
2848 int boardCount = ( it != boardLayerCounts.end() ) ? it->second : 0;
2866 BOOST_REQUIRE_GT( boardsWithAlg.size(), 0u );
2868 for(
const auto& [brdFile, algFile] : boardsWithAlg )
2874 BOARD* board = GetCachedBoard( brdFile );
2878 const double milsToNm = 25400.0;
2880 std::map<wxString, std::vector<double>> algAreas;
2884 double w = ( zone.
maxX - zone.
minX ) * milsToNm;
2885 double h = ( zone.
maxY - zone.
minY ) * milsToNm;
2886 algAreas[zone.
layer].push_back( w * h );
2889 std::map<wxString, std::vector<double>> boardAreas;
2891 for(
const ZONE* zone : board->
Zones() )
2893 if( zone->GetIsRuleArea() )
2896 BOX2I bbox = zone->GetBoundingBox();
2897 double area =
static_cast<double>( bbox.
GetWidth() )
2898 *
static_cast<double>( bbox.
GetHeight() );
2903 boardAreas[board->
GetLayerName( layer )].push_back( area );
2910 for(
auto& [layer, algList] : algAreas )
2912 std::sort( algList.begin(), algList.end() );
2913 auto it = boardAreas.find( layer );
2915 if( it == boardAreas.end() || it->second.size() != algList.size() )
2918 std::sort( it->second.begin(), it->second.end() );
2920 for(
size_t i = 0; i < algList.size(); ++i )
2922 double ref = std::max( algList[i], 1.0 );
2923 double err =
std::abs( it->second[i] - algList[i] ) / ref;
2933 if( mismatched <= 5 )
2936 <<
": alg area " << algList[i] / ( milsToNm * milsToNm )
2937 <<
" sq mils vs board area "
2938 << it->second[i] / ( milsToNm * milsToNm )
2946 << mismatched <<
" mismatched" );
2948 int total = matched + mismatched;
2952 BOOST_CHECK_GT( matched, total * 8 / 10 );
2969 BOARD* board = GetCachedBoard( dataPath );
2975 const std::set<wxString> targetRefs = { wxS(
"J1" ), wxS(
"P5" ), wxS(
"U5" ),
2976 wxS(
"U13" ), wxS(
"C78" ) };
2978 int testedCount = 0;
2979 int failedCount = 0;
2983 if( targetRefs.find( fp->GetReference() ) == targetRefs.end() )
2989 bool hasFab =
false;
2991 for(
BOARD_ITEM* item : fp->GraphicalItems() )
2993 if( item->GetLayer() == fabLayer )
2997 fabBbox = item->GetBoundingBox();
3002 fabBbox.
Merge( item->GetBoundingBox() );
3007 if( !hasFab || fp->Pads().empty() )
3012 BOX2I testBbox = fabBbox;
3019 for(
PAD*
pad : fp->Pads() )
3023 if( !testBbox.
Contains( padCenter ) )
3027 <<
" at (" << padCenter.
x / 1e6 <<
", "
3028 << padCenter.
y / 1e6 <<
") mm is outside F.Fab bbox" );
3035 BOOST_CHECK_GE( testedCount, 4 );
3049 BOARD* board = GetCachedBoard( dataPath );
3054 wxString ref = fp->GetReference();
3056 if( ref != wxS(
"P6" ) && ref != wxS(
"P10" ) )
3061 for(
PAD*
pad : fp->Pads() )
3065 if( !
pad->GetNumber().ToLong( &padNum ) )
3069 if( padNum < 1 || padNum > 19 )
3073 BOX2I bbox =
pad->GetBoundingBox();
3078 if( bboxW == bboxH )
3083 BOOST_CHECK_MESSAGE( bboxW > bboxH,
3084 ref <<
" pad " <<
pad->GetNumber()
3085 <<
" should be visually wider than tall: "
3086 << bboxW / 1e6 <<
" x " << bboxH / 1e6 <<
" mm" );
3105 BOARD* board = GetCachedBoard( dataPath );
3108 int oblongCount = 0;
3112 for(
PAD*
pad : fp->Pads() )
3116 if( drillSize.
x <= 0 || drillSize.
y <= 0 )
3119 if( drillSize.
x == drillSize.
y )
3129 <<
" slot: " << drillSize.
x / 1e6 <<
" x "
3130 << drillSize.
y / 1e6 <<
" mm"
3131 <<
" attr=" <<
static_cast<int>(
pad->GetAttribute() ) );
3150 BOARD* board = GetCachedBoard( dataPath );
3158 if( fp->GetReference() == wxT(
"J1" ) )
3169 BOOST_CHECK_CLOSE(
orientation.AsDegrees(), 90.0, 0.1 );
3185 std::unique_ptr<BOARD> board;
3195 catch(
const std::exception& e )
3200 reporter.PrintAllMessages(
"UIImportPath_NullBoard" );
3204 BOOST_CHECK_GT( board->GetNetCount(), 0 );
3205 BOOST_CHECK_GT( board->Footprints().size(), 0 );
3206 BOOST_CHECK_GT( board->Tracks().size(), 0 );
3223 std::vector<std::string> boards = GetAllBoardFiles();
3225 for(
const std::string& boardPath : boards )
3227 std::string boardName = std::filesystem::path( boardPath ).filename().string();
3228 BOARD* board = GetCachedBoard( boardPath );
3235 int inconsistentCount = 0;
3239 const bool onBottom = fp->IsFlipped();
3241 for(
PAD*
pad : fp->Pads() )
3246 LSET layers =
pad->GetLayerSet();
3250 if( onBottom && hasTopCopper && !hasBotCopper )
3252 inconsistentCount++;
3254 <<
pad->GetNumber() <<
" is on bottom footprint but SMD "
3255 <<
"pad has F.Cu without B.Cu" );
3257 else if( !onBottom && hasBotCopper && !hasTopCopper )
3259 inconsistentCount++;
3261 <<
pad->GetNumber() <<
" is on top footprint but SMD "
3262 <<
"pad has B.Cu without F.Cu" );
3285 std::vector<std::string> boards = {
3289 for(
const std::string& boardPath : boards )
3291 std::string boardName = std::filesystem::path( boardPath ).filename().string();
3292 BOARD* board = GetCachedBoard( boardPath );
3298 int inconsistentCount = 0;
3299 int checkedFootprints = 0;
3304 bool hasSmd =
false;
3307 for(
PAD*
pad : fp->Pads() )
3315 if( !hasSmd || hasTH )
3318 checkedFootprints++;
3320 const bool onBottom = fp->IsFlipped();
3322 for(
BOARD_ITEM* item : fp->GraphicalItems() )
3329 bool wrongSide =
false;
3338 inconsistentCount++;
3340 boardName <<
": " << fp->GetReference() <<
" is "
3341 << ( onBottom ?
"bottom" :
"top" ) <<
"-side SMD but has "
3342 << item->GetClass() <<
" on "
3349 <<
" SMD-only footprints for tech layer consistency" );
3366 BOARD* board = GetCachedBoard( dataPath );
3376 std::vector<SLOT_CHECK> checks = {
3377 { wxS(
"P6" ), wxS(
"20" ) },
3378 { wxS(
"P6" ), wxS(
"21" ) },
3379 { wxS(
"P3" ), wxS(
"6" ) },
3380 { wxS(
"P1" ), wxS(
"1" ) },
3381 { wxS(
"P1" ), wxS(
"2" ) },
3382 { wxS(
"P1" ), wxS(
"3" ) },
3385 for(
const auto& check : checks )
3393 if( candidate->GetReference() == check.fpRef )
3404 for(
PAD* candidate : fp->
Pads() )
3406 if( candidate->GetNumber() == check.padNum )
3414 "Pad " << check.padNum <<
" should exist on " << check.fpRef );
3420 <<
": pad=" << padSize.
x <<
"x" << padSize.
y
3421 <<
" drill=" << drillSize.
x <<
"x" << drillSize.
y );
3424 if( drillSize.
x != drillSize.
y )
3426 bool padIsTaller = ( padSize.
y > padSize.
x );
3427 bool drillIsTaller = ( drillSize.
y > drillSize.
x );
3429 BOOST_CHECK_MESSAGE( padIsTaller == drillIsTaller,
3430 "Drill slot should match pad orientation" );
3445 BOARD* board = GetCachedBoard( dataPath );
3448 int filledZoneCount = 0;
3449 int totalCopperZones = 0;
3451 for(
const ZONE* zone : board->
Zones() )
3453 if( zone->GetIsRuleArea() || zone->GetNetCode() == 0 )
3458 if( zone->IsFilled() )
3463 <<
" layers=" << zone->GetLayerSet().count() );
3468 <<
", filled: " << filledZoneCount );
3470 BOOST_CHECK_GT( totalCopperZones, 0 );
3471 BOOST_CHECK_GT( filledZoneCount, 0 );
3483 BOARD* board = GetCachedBoard( dataPath );
3486 int teardropZones = 0;
3488 for(
const ZONE* zone : board->
Zones() )
3490 if( zone->IsTeardropArea() )
3494 BOOST_CHECK_GT( teardropZones, 1000 );
3498 int padsWithTeardrops = 0;
3503 for(
const PAD*
pad : fp->Pads() )
3507 if(
pad->GetTeardropsEnabled() )
3508 padsWithTeardrops++;
3512 BOOST_CHECK_GT( padsWithTeardrops, 0 );
3513 BOOST_TEST_MESSAGE(
"Pads with teardrops enabled: " << padsWithTeardrops <<
" / " << totalPads );
3515 int viasWithTeardrops = 0;
3525 if(
static_cast<const PCB_VIA*
>( track )->GetTeardropsEnabled() )
3526 viasWithTeardrops++;
3529 BOOST_CHECK_GT( viasWithTeardrops, 0 );
3530 BOOST_TEST_MESSAGE(
"Vias with teardrops enabled: " << viasWithTeardrops <<
" / " << totalVias );
3538 BOARD* board = GetCachedBoard( dataPath );
3543 for(
const ZONE* zone : board->
Zones() )
3545 if( !zone->IsTeardropArea() )
3550 if( !zone->HasFilledPolysForLayer( layer ) )
3553 const std::shared_ptr<SHAPE_POLY_SET> fill = zone->GetFilledPolysList( layer );
3555 for(
int i = 0; i < fill->OutlineCount(); ++i )
3557 if( fill->COutline( i ).ArcCount() > 0 )
3575 BOARD* board = GetCachedBoard( dataPath );
3578 int teardropZones = 0;
3580 for(
const ZONE* zone : board->
Zones() )
3582 if( zone->IsTeardropArea() )
3588 int padsWithTeardrops = 0;
3592 for(
const PAD*
pad : fp->Pads() )
3594 if(
pad->GetTeardropsEnabled() )
3595 padsWithTeardrops++;
3616 std::unique_ptr<BOARD> board = plugin.
LoadBoard( dataPath );
3620 BOOST_CHECK_MESSAGE( board->m_LegacyNetclassesLoaded,
3621 "m_LegacyNetclassesLoaded must be true after Allegro import" );
3622 BOOST_CHECK_MESSAGE( board->m_LegacyDesignSettingsLoaded,
3623 "m_LegacyDesignSettingsLoaded must be true after Allegro import" );
3633 std::vector<std::string> boards = GetAllBoardFiles();
3635 for(
const std::string& boardPath : boards )
3637 std::string boardName = std::filesystem::path( boardPath ).filename().string();
3638 BOARD* board = GetCachedBoard( boardPath );
3646 const auto& netclasses = netSettings->GetNetclasses();
3650 for(
const auto& [
name, nc] : netclasses )
3653 << nc->GetTrackWidth() <<
" clearance="
3654 << nc->GetClearance() );
3658 if( !
name.StartsWith( wxS(
"DP_" ) )
3659 && !
name.StartsWith( wxS(
"MG_" ) )
3660 && !
name.StartsWith( wxS(
"W" ) ) )
3662 BOOST_CHECK_MESSAGE( nc->HasTrackWidth(),
3663 name <<
" should have a track width" );
3664 BOOST_CHECK_MESSAGE( nc->GetTrackWidth() > 0,
3665 name <<
" track width should be positive" );
General utilities for PCB file IO for QA programs.
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
wxString GetNetname() const
std::shared_ptr< NET_SETTINGS > m_NetSettings
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Information pertinent to a Pcbnew printed circuit board.
const NETINFO_LIST & GetNetInfo() const
const ZONES & Zones() const
PCB_LAYER_ID GetLayerID(const wxString &aLayerName) const
Return the ID of a layer.
const FOOTPRINTS & Footprints() const
const TRACKS & Tracks() const
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
BOARD_DESIGN_SETTINGS & GetDesignSettings()
const DRAWINGS & Drawings() const
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
constexpr size_type GetWidth() const
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
constexpr size_type GetHeight() const
constexpr coord_type GetLeft() const
constexpr bool Contains(const Vec &aPoint) const
constexpr coord_type GetRight() const
constexpr coord_type GetTop() const
constexpr coord_type GetBottom() const
KICAD_T Type() const
Returns the type of object.
std::vector< VECTOR2I > GetPolyPoints() const
Duplicate the polygon outlines into a flat list of VECTOR2I points.
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
VECTOR3D m_Offset
3D model offset (mm)
VECTOR3D m_Rotation
3D model rotation (degrees)
virtual void SetReporter(REPORTER *aReporter)
Set an optional reporter for warnings/errors.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
virtual const char * what() const override
std::exception interface, returned as UTF-8
static ALLEGRO_CACHED_LOADER & GetInstance()
Get the singleton instance of the Allegro board cache loader.
BOARD * GetCachedBoard(const std::string &aFilePath)
Get a cached board for the given file path, or load it if not already cached, without forcing a reloa...
Custom REPORTER that captures all messages for later analysis in the unit test framework.
LSET is a set of PCB_LAYER_IDs.
static LSET AllCuMask(int aCuLayerCount)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
bool Contains(PCB_LAYER_ID aLayer) const
See if the layer set contains a PCB layer.
static const char Default[]
the name of the default NETCLASS
Handle the data for a net.
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
std::unique_ptr< BOARD > LoadBoard(const wxString &aFileName, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr)
Load information from some input file format that this PCB_IO implementation knows about into new BOA...
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
const VECTOR2I & GetStart() const
const VECTOR2I & GetEnd() const
Represent a set of closed polygons.
double Area()
Return the area of this poly set.
void BooleanIntersection(const SHAPE_POLY_SET &b)
Perform boolean polyset intersection.
Handle a list of polygons defining a copper zone.
PCB_LAYER_ID GetFirstLayer() const
static constexpr EDA_ANGLE ANGLE_0
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
bool IsFrontLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a front layer.
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
bool IsInnerCopperLayer(int aLayerId)
Test whether a layer is an inner (In1_Cu to In30_Cu) copper layer.
PCB_LAYER_ID
A quick note on layer IDs:
std::array< SEG, 4 > BoxToSegs(const BOX2I &aBox)
Decompose a BOX2 into four segments.
Test utilities for timestamps.
std::string AllegroBoardDataDir(const std::string &aBoardName)
void PrintBoardStats(const BOARD *aBoard, const std::string &aBoardName)
Print detailed board statistics for debugging using test-framework logging.
void FillZones(BOARD *m_board)
std::string AllegroBoardFile(const std::string &aFileName)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
PAD_ATTRIB
The set of pad shapes, used with PAD::{Set,Get}Attribute().
@ NPTH
like PAD_PTH, but not plated mechanical use only, no connection allowed
@ SMD
Smd pad, appears on the solder paste layer (default)
@ PTH
Plated through hole pad.
std::deque< BOARD_ITEM * > DRAWINGS
Utility functions for working with shapes.
Parse board outline geometry from a .alg ASCII reference file.
void updateBounds(double aX, double aY)
static ALG_OUTLINE_DATA ParseAlgOutlines(const std::string &aPath)
std::vector< OUTLINE_SEGMENT > designOutlineSegments
static const ALG_OUTLINE_DATA & GetCached(const std::string &aPath)
std::vector< OUTLINE_SEGMENT > outlineSegments
int expectedEdgeCutsSegments() const
Expected number of Edge_Cuts segments when translating to KiCad.
std::set< wxString > netNames
static ALG_REFERENCE_DATA ParseAlgFile(const std::string &aPath)
std::map< wxString, wxString > refDesToSymName
std::set< wxString > refDes
static std::vector< wxString > SplitAlgLine(const wxString &aLine)
std::vector< ALG_ZONE_POLYGON > zonePolygons
static int ParseRecordId(const wxString &aTag)
Extract the integer record ID from a RECORD_TAG field like "36 1 0".
static const ALG_REFERENCE_DATA & GetCached(const std::string &aPath)
std::map< wxString, std::set< wxString > > netToRefDes
Parse a FabMaster .alg file and extract reference data for cross-validation.
void AddPoint(double aX, double aY)
Data for parameterized all-boards test.
Fixture for comprehensive board import tests with error capturing.
PCB_IO_ALLEGRO m_allegroPlugin
BOARD * GetCachedBoard(const std::string &aFilePath)
Get a cached board, loading it on first access.
static std::vector< std::string > GetAllBoardFiles()
Get list of all .brd files in the Allegro test data directory.
ALLEGRO_COMPREHENSIVE_FIXTURE()
std::unique_ptr< BOARD > LoadAllegroBoard(const std::string &aFileName)
PCB_IO_ALLEGRO m_allegroPlugin
BOOST_AUTO_TEST_CASE(FootprintRefDes)
Test that footprints have valid reference designators.
static void AssertOutlineValid(const BOARD &aBoard)
static std::vector< BRD_ALG_PAIR > getBoardsWithAlg()
Get a list of all board files in the test data that have a corresponding .alg reference file.
static unsigned CountOutlineElements(const BOARD &board)
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_CHECK(res.column_datatype(0)==SQL_NUMERIC||res.column_datatype(0)==SQL_DECIMAL)
BOOST_REQUIRE_EQUAL(rows.size(), 1)
BOOST_CHECK_EQUAL(std::any_cast< std::string >(rows[0].at("val")), "12345678901234567.89")
BOOST_REQUIRE_MESSAGE(dc.CacheTableInfo(table, { "part_id", "val" }), dc.GetLastError())
BOOST_REQUIRE(res.columns()==1)
static EDA_ORIENTATION orientation(double d)
BOOST_AUTO_TEST_SUITE_END()
IbisParser parser & reporter
KIBIS top(path, &reporter)
VECTOR3I expected(15, 30, 45)
BOOST_TEST_CONTEXT("Test Clearance")
BOOST_TEST_MESSAGE("Polyline has "<< chain.PointCount()<< " points")
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
VECTOR2< int32_t > VECTOR2I