66 for(
RULE_AREA& ra : aTool->GetData()->m_areas )
68 if( ra.m_ruleName.Contains( ( aName ) ) )
79 if( ra.m_zone && ra.m_zone->GetPlacementAreaSource() == aGroupName )
92 if( zone == aRuleArea.
m_zone )
95 if( zone->GetZoneName() != aZoneName )
110 std::vector<wxString> tests = {
"vme-wren" };
112 for(
const wxString& relPath : tests )
119 toolMgr.
SetEnvironment( m_board.get(),
nullptr,
nullptr,
nullptr, toolsHolder );
128 auto ruleData = mtTool->
GetData();
131 static_cast<int>( ruleData->m_areas.size() ) ) );
137 ruleData->m_replaceExisting =
true;
142 || ra.
m_sheetName == wxT(
"pp_driver_2x.kicad_sch" ) )
156 int n_areas_io = 0, n_areas_pp = 0, n_areas_other = 0;
159 static_cast<int>(ruleData->m_areas.size() ) ) );
161 for(
const RULE_AREA& ra : ruleData->m_areas )
165 if( ra.
m_ruleName.Contains( wxT(
"io_drivers_fp" ) ) )
170 else if( ra.
m_ruleName.Contains( wxT(
"io_drivers_pp" ) ) )
182 n_areas_io, n_areas_pp, n_areas_other ) );
188 const std::vector<wxString> rulesToTest = { wxT(
"io_drivers_fp" ),
189 wxT(
"io_drivers_pp" ) };
191 for(
const wxString& ruleName : rulesToTest )
193 for(
const RULE_AREA& refArea : ruleData->m_areas )
195 if( !refArea.
m_ruleName.Contains( ruleName ) )
200 for(
const RULE_AREA& targetArea : ruleData->m_areas )
205 if( !targetArea.
m_ruleName.Contains( ruleName ) )
208 auto cgRef = CONNECTION_GRAPH::BuildFromFootprintSet( refArea.
m_components,
211 CONNECTION_GRAPH::BuildFromFootprintSet( targetArea.
m_components,
216 std::vector<TMATCH::TOPOLOGY_MISMATCH_REASON> details;
217 bool status = cgRef->FindIsomorphism( cgTarget.get(),
result, details );
220 "topo match: '%s' [%d] -> '%s' [%d] result %d", refArea.
m_ruleName.c_str().AsChar(),
222 static_cast<int>( targetArea.
m_components.size() ), status ? 1 : 0 ) );
224 for(
const auto& iter :
result )
227 iter.second->GetReference(),
228 iter.first->GetReference() ) );
231 BOOST_CHECK( status );
232 BOOST_CHECK( details.empty() );
239 BOOST_ASSERT( refArea );
241 const std::vector<wxString> targetAreaNames( { wxT(
"io_drivers_fp/bank2/io78/" ),
242 wxT(
"io_drivers_fp/bank1/io78/" ),
243 wxT(
"io_drivers_fp/bank0/io01/" ) } );
245 for(
const wxString& targetRaName : targetAreaNames )
249 BOOST_ASSERT( targetRA !=
nullptr );
253 ruleData->m_compatMap[targetRA].m_doCopy =
true;
258 BOOST_ASSERT(
result >= 0 );
274 toolMgr.
SetEnvironment( m_board.get(),
nullptr,
nullptr,
nullptr, toolsHolder );
281 auto ruleData = mtTool->
GetData();
284 static_cast<int>( ruleData->m_areas.size() ) ) );
286 BOOST_CHECK( ruleData->m_areas.size() >= 2 );
288 if( ruleData->m_areas.size() < 2 )
296 if( ra.
m_ruleName.Contains( wxT(
"Untitled Sheet/" ) ) )
298 else if( ra.
m_ruleName.Contains( wxT(
"Untitled Sheet1/" ) ) )
302 if( !refArea || !targetArea )
304 BOOST_TEST_MESSAGE(
"Could not find Untitled Sheet and Untitled Sheet1 rule areas, skipping test" );
332 if( !refFP || !targetFP )
334 BOOST_TEST_MESSAGE(
"Could not find matching footprints in the rule areas, skipping test" );
339 bool refValueVisible = refValueField ? refValueField->
IsVisible() :
true;
341 std::vector<FP_3DMODEL> refModels = refFP->
Models();
345 ruleData->m_compatMap[targetArea].m_doCopy =
true;
346 ruleData->m_options.m_copyPlacement =
true;
350 BOOST_CHECK(
result >= 0 );
354 if( targetValueField && refValueField )
358 refValueVisible, targetValueField->
IsVisible() ) );
363 if( !refModels.empty() )
366 static_cast<int>( refModels.size() ),
367 static_cast<int>( targetFP->
Models().size() ) ) );
386 toolMgr.
SetEnvironment( m_board.get(),
nullptr,
nullptr,
nullptr, toolsHolder );
393 auto ruleData = mtTool->
GetData();
396 static_cast<int>( ruleData->m_areas.size() ) ) );
400 if( ruleData->m_areas.size() < 2 )
417 int refViaCountBefore = 0;
419 for(
PCB_TRACK* track : m_board->Tracks() )
431 BOOST_TEST_MESSAGE( wxString::Format(
"Reference area vias before repeat: %d", refViaCountBefore ) );
432 BOOST_CHECK( refViaCountBefore > 0 );
436 ruleData->m_compatMap[targetArea].m_doCopy =
true;
437 ruleData->m_options.m_copyPlacement =
true;
438 ruleData->m_options.m_copyRouting =
true;
442 BOOST_CHECK(
result >= 0 );
444 int refViaCountAfter = 0;
446 for(
PCB_TRACK* track : m_board->Tracks() )
458 BOOST_TEST_MESSAGE( wxString::Format(
"Reference area vias after repeat: %d", refViaCountAfter ) );
475 toolMgr.
SetEnvironment( m_board.get(),
nullptr,
nullptr,
nullptr, toolsHolder );
538 auto cgRef = std::make_unique<CONNECTION_GRAPH>();
539 auto cgTarget = std::make_unique<CONNECTION_GRAPH>();
542 LIB_ID fpid( wxT(
"Package_SO" ), wxT(
"SOIC-8_3.9x4.9mm_P1.27mm" ) );
554 PAD padRef1( &fpRef );
557 fpRef.
Add( &padRef1 );
559 PAD padRef2( &fpRef );
562 fpRef.
Add( &padRef2 );
564 PAD padTarget1( &fpTarget );
567 fpTarget.
Add( &padTarget1 );
569 PAD padTarget2( &fpTarget );
572 fpTarget.
Add( &padTarget2 );
575 cgRef->AddFootprint( &fpRef,
VECTOR2I( 0, 0 ) );
576 cgTarget->AddFootprint( &fpTarget,
VECTOR2I( 0, 0 ) );
578 cgRef->BuildConnectivity();
579 cgTarget->BuildConnectivity();
585 COMPONENT* cmpRef = cgRef->Components()[0];
586 COMPONENT* cmpTarget = cgTarget->Components()[0];
588 bool sameKind = cmpRef->IsSameKind( *cmpTarget );
590 BOOST_TEST_MESSAGE( wxString::Format(
"TRIM_1.1 and TRIM_2.1 IsSameKind: %d", sameKind ? 1 : 0 ) );
591 BOOST_CHECK( sameKind );
595 std::vector<TMATCH::TOPOLOGY_MISMATCH_REASON> details;
596 bool status = cgRef->FindIsomorphism( cgTarget.get(),
result, details );
598 BOOST_TEST_MESSAGE( wxString::Format(
"Topology match result: %d", status ? 1 : 0 ) );
600 if( !status && !details.empty() )
602 for(
const auto& reason : details )
605 reason.m_reference, reason.m_candidate, reason.m_reason ) );
609 BOOST_CHECK( status );
610 BOOST_CHECK( details.empty() );
613 fpRef.
Pads().clear();
614 fpTarget.
Pads().clear();
633 toolMgr.
SetEnvironment( m_board.get(),
nullptr,
nullptr,
nullptr, toolsHolder );
640 auto ruleData = mtTool->
GetData();
648 if( ra.
m_sheetPath == wxT(
"/io_drivers_fp/bank0/io01/" ) )
650 else if( ra.
m_sheetPath == wxT(
"/io_drivers_fp/bank0/" ) )
652 else if( ra.
m_sheetPath == wxT(
"/io_drivers_fp/" ) )
660 BOOST_TEST_MESSAGE( wxString::Format(
"Leaf /io_drivers_fp/bank0/io01/ components: %d",
699 toolMgr.
SetEnvironment( m_board.get(),
nullptr,
nullptr,
nullptr, toolsHolder );
706 auto ruleData = mtTool->
GetData();
712 if( ra.
m_sheetName == wxT(
"io_driver.kicad_sch" ) )
726 auto cgRef = CONNECTION_GRAPH::BuildFromFootprintSet( refArea->
m_components,
728 auto cgTarget = CONNECTION_GRAPH::BuildFromFootprintSet( targetArea->
m_components,
733 std::atomic<bool> cancelled(
true );
734 std::atomic<int> matched( 0 );
735 std::atomic<int> total( 0 );
743 std::vector<TMATCH::TOPOLOGY_MISMATCH_REASON> details;
745 bool status = cgRef->FindIsomorphism( cgTarget.get(),
result, details, params );
747 BOOST_CHECK( !status );
748 BOOST_CHECK(
result.empty() );
755 std::atomic<bool> cancelled(
false );
756 std::atomic<int> matched( 0 );
757 std::atomic<int> total( 0 );
765 std::vector<TMATCH::TOPOLOGY_MISMATCH_REASON> details;
767 bool status = cgRef->FindIsomorphism( cgTarget.get(),
result, details, params );
769 BOOST_CHECK( status );
771 int finalMatched = matched.load();
772 int finalTotal = total.load();
774 BOOST_TEST_MESSAGE( wxString::Format(
"Progress: matched=%d, total=%d", finalMatched, finalTotal ) );
776 BOOST_CHECK( finalTotal > 0 );
783 std::vector<TMATCH::TOPOLOGY_MISMATCH_REASON> details;
785 bool status = cgRef->FindIsomorphism( cgTarget.get(),
result, details );
787 BOOST_CHECK( status );
788 BOOST_CHECK( !
result.empty() );
814 toolMgr.
SetEnvironment( m_board.get(),
nullptr,
nullptr,
nullptr, toolsHolder );
821 auto ruleData = mtTool->
GetData();
824 static_cast<int>( ruleData->m_areas.size() ) ) );
838 if( source == wxT(
"/i2c_thingy_ch0/" ) )
840 else if( source == wxT(
"/i2c_thingy_ch1/" ) )
844 BOOST_REQUIRE_MESSAGE( ch0Area !=
nullptr,
"Could not find i2c_thingy_ch0 rule area" );
845 BOOST_REQUIRE_MESSAGE( ch1Area !=
nullptr,
"Could not find i2c_thingy_ch1 rule area" );
853 auto cgRef = CONNECTION_GRAPH::BuildFromFootprintSet( ch0Area->
m_components,
855 auto cgTarget = CONNECTION_GRAPH::BuildFromFootprintSet( ch1Area->
m_components,
859 std::vector<TMATCH::TOPOLOGY_MISMATCH_REASON> details;
860 bool status = cgRef->FindIsomorphism( cgTarget.get(),
result, details );
864 for(
const auto& reason : details )
867 reason.m_reference, reason.m_candidate,
873 "Topology match failed for channels with hierarchical pins "
874 "tied to global nets (issue 21739)" );
889 m_board = std::make_unique<BOARD>();
905 pad->SetNumber( wxT(
"1" ) );
907 pad->SetPosition( aPos );
919 FOOTPRINT* refFp1 = makeFootprint( wxT(
"R1" ),
921 FOOTPRINT* refFp2 = makeFootprint( wxT(
"R2" ),
929 m_board->Add( silkRect );
932 FOOTPRINT* destFp1 = makeFootprint( wxT(
"R3" ),
934 FOOTPRINT* destFp2 = makeFootprint( wxT(
"R4" ),
938 destGroup->
SetName( wxT(
"design-block-dest" ) );
941 m_board->Add( destGroup );
950 m_board->Add( unrelatedSilk );
960 BOOST_REQUIRE_EQUAL( silkBefore, 2 );
993 toolMgr.
SetEnvironment( m_board.get(),
nullptr,
nullptr,
nullptr, toolsHolder );
999 .m_connectedRoutingOnly =
false,
1000 .m_copyPlacement =
true,
1001 .m_copyOtherItems =
true,
1002 .m_groupItems =
false,
1003 .m_includeLockedItems =
true,
1004 .m_anchorFp =
nullptr };
1016 int silkInGroup = 0;
1017 bool unrelatedSurvived =
false;
1020 for(
BOARD_ITEM* item : m_board->Drawings() )
1027 if( item == unrelatedSilk )
1028 unrelatedSurvived =
true;
1030 if( item->GetParentGroup() == destGroup )
1042 wxString::Format(
"Expected 3 silkscreen shapes after Apply Design Block "
1043 "Layout (2 original + 1 copy), found %d (issue 24372)",
1046 wxString::Format(
"Expected 1 silkscreen shape in destination group, "
1047 "found %d (issue 24372)",
1050 "Unrelated silkscreen drawing outside the design block group was "
1051 "deleted by Apply Design Block Layout (issue 24372)" );
constexpr EDA_IU_SCALE pcbIUScale
virtual bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Information pertinent to a Pcbnew printed circuit board.
const ZONES & Zones() const
static constexpr BOX2< VECTOR2I > ByCorners(const VECTOR2I &aCorner1, const VECTOR2I &aCorner2)
Store all of the related component information found in a netlist.
void AddItem(EDA_ITEM *aItem)
Add item to group.
void SetName(const wxString &aName)
void SetStart(const VECTOR2I &aStart)
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
void SetEnd(const VECTOR2I &aEnd)
virtual bool IsVisible() const
A logical library item identifier and consists of various portions much like a URI.
LSET is a set of PCB_LAYER_IDs.
static const LSET & AllTechMask()
Return a mask holding all technical layers (no CU layer) on both side.
static LSET AllCuMask(int aCuLayerCount)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Handle the data for a net.
void SetNumber(const wxString &aNumber)
Set the pad number (note that it can be alphanumeric, such as the array reference "AA12").
A set of BOARD_ITEMs (i.e., without duplicates).
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
void SetStroke(const STROKE_PARAMS &aStroke) override
bool Contains(const VECTOR2I &aP, int aSubpolyIndex=-1, int aAccuracy=0, bool aUseBBoxCaches=false) const
Return true if a given subpolygon contains the point aP.
Simple container to manage line stroke parameters.
Handle a list of polygons defining a copper zone.
void AddPolygon(std::vector< VECTOR2I > &aPolygon)
Add a polygon to the zone outline.
wxString GetPlacementAreaSource() const
SHAPE_POLY_SET * Outline()
void SetIsRuleArea(bool aEnable)
void SetLayerSet(const LSET &aLayerSet) override
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
SHAPE_LINE_CHAIN BoxToLineChain(const BOX2I &aBox)
void LoadBoard(SETTINGS_MANAGER &aSettingsManager, const wxString &aRelPath, std::unique_ptr< BOARD > &aBoard)
std::map< FOOTPRINT *, FOOTPRINT * > COMPONENT_MATCHES
Class to handle a set of BOARD_ITEMs.
Utility functions for working with shapes.
MULTICHANNEL_TEST_FIXTURE()
SETTINGS_MANAGER m_settingsManager
std::unique_ptr< BOARD > m_board
bool m_includeLockedItems
std::vector< RULE_AREA > m_areas
std::unordered_set< EDA_ITEM * > m_designBlockItems
PLACEMENT_SOURCE_T m_sourceType
std::set< FOOTPRINT * > m_components
std::atomic< bool > * m_cancelled
std::atomic< int > * m_matchedComponents
std::atomic< int > * m_totalComponents
@ VALUE
Field Value of part, i.e. "3.3K".
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END()
RULE_AREA * findRuleAreaByPartialName(MULTICHANNEL_TOOL *aTool, const wxString &aName)
BOOST_FIXTURE_TEST_CASE(MultichannelToolRegressions, MULTICHANNEL_TEST_FIXTURE)
int countZonesByNameInRuleArea(BOARD *aBoard, const wxString &aZoneName, const RULE_AREA &aRuleArea)
RULE_AREA * findRuleAreaByPlacementGroup(MULTICHANNEL_TOOL *aTool, const wxString &aGroupName)
BOOST_CHECK_MESSAGE(totalMismatches==0, std::to_string(totalMismatches)+" board(s) with strategy disagreements")
BOOST_TEST_MESSAGE("\n=== Real-World Polygon PIP Benchmark ===\n"<< formatTable(table))
wxString result
Test unit parsing edge cases and error handling.
BOOST_CHECK_EQUAL(result, "25.4")
@ 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)
VECTOR2< int32_t > VECTOR2I