KiCad PCB EDA Suite
Loading...
Searching...
No Matches
topo_match.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include <cstdio>
25#include <cstdlib>
26#include <cmath>
27#include <string>
28#include <vector>
29#include <algorithm>
30#include <cassert>
31#include <map>
32#include <set>
33#include <cctype>
34
35#include <pad.h>
36#include <footprint.h>
37#include <refdes_utils.h>
38#include <board.h>
39#include <wx/string.h>
40#include <wx/log.h>
41
42#include "topo_match.h"
43
44
45static const wxString traceTopoMatch = wxT( "TOPO_MATCH" );
46
47namespace TMATCH
48{
49
50bool PIN::IsIsomorphic( const PIN& b, TOPOLOGY_MISMATCH_REASON& aReason ) const
51{
52 if( m_conns.size() != b.m_conns.size() )
53 {
54 wxLogTrace( traceTopoMatch,
55 wxT( "[conns mismatch n1 %d n2 %d c-ref %d c-other %d thispin %s-%s "
56 "otherpin %s-%s" ),
58 b.m_netcode,
59 (int) m_conns.size(),
60 (int) b.m_conns.size(),
61 m_parent->m_reference,
62 m_ref,
64 b.m_ref );
65
66 aReason.m_reference = m_parent->GetParent()->GetReferenceAsString();
68 aReason.m_reason = wxString::Format(
69 _( "Pad %s of %s connects to %lu pads, but candidate pad %s of %s connects to %lu." ), m_ref,
70 aReason.m_reference, static_cast<unsigned long>( m_conns.size() ), b.m_ref, aReason.m_candidate,
71 static_cast<unsigned long>( b.m_conns.size() ) );
72
73 for( auto c : m_conns )
74 {
75 wxLogTrace( traceTopoMatch, wxT( "%s-%s " ), c->m_parent->m_reference, c->m_ref );
76 }
77
78 wxLogTrace( traceTopoMatch, wxT( "||" ) );
79
80 for( auto c : b.m_conns )
81 {
82 wxLogTrace( traceTopoMatch, wxT( "%s-%s " ), c->m_parent->m_reference, c->m_ref );
83 }
84
85
86 wxLogTrace( traceTopoMatch, wxT( "] " ) );
87 return false;
88 }
89
90 if( m_conns.empty() )
91 {
92 wxLogTrace( traceTopoMatch, wxT( "[conns empty]" ) );
93 return true;
94 }
95
96 std::vector<bool> matches( m_conns.size() );
97
98 for( int i = 0; i < m_conns.size(); i++ )
99 matches[i] = false;
100
101 int nref = 0;
102
103 for( auto& cref : m_conns )
104 {
105 for( int i = 0; i < m_conns.size(); i++ )
106 {
107 if( b.m_conns[i]->IsTopologicallySimilar( *cref ) )
108 {
109 matches[nref] = true;
110 break;
111 }
112 }
113
114 nref++;
115 }
116
117 for( int i = 0; i < m_conns.size(); i++ )
118 {
119 if( !matches[i] )
120 {
121 aReason.m_reference = m_parent->GetParent()->GetReferenceAsString();
123 aReason.m_reason = wxString::Format(
124 _( "Pad %s of %s cannot match candidate pad %s of %s due to differing connectivity." ), m_ref,
125 aReason.m_reference, b.m_ref, aReason.m_candidate );
126
127 return false;
128 }
129 }
130
131 return true;
132}
133
134
135// fixme: terrible performance, but computers are fast these days, ain't they? :D
136bool checkIfPadNetsMatch( const BACKTRACK_STAGE& aMatches, CONNECTION_GRAPH* aRefGraph, COMPONENT* aRef,
137 COMPONENT* aTgt, TOPOLOGY_MISMATCH_REASON& aReason )
138{
139 std::map<PIN*, PIN*> pairs;
140 std::vector<PIN*> pref, ptgt;
141
142 // GetMatchingComponentPairs() returns target->reference map
143 for( auto& m : aMatches.GetMatchingComponentPairs() )
144 {
145 for( PIN* p : m.second->Pins() )
146 {
147 pref.push_back( p );
148 }
149
150 for( PIN* p : m.first->Pins() )
151 {
152 ptgt.push_back( p );
153 }
154 }
155
156 for( PIN* p : aRef->Pins() )
157 {
158 pref.push_back( p );
159 }
160
161 for( PIN* p : aTgt->Pins() )
162 {
163 ptgt.push_back( p );
164 }
165
166 if( pref.size() != ptgt.size() )
167 {
168 aReason.m_reference = aRef->GetParent()->GetReferenceAsString();
169 aReason.m_candidate = aTgt->GetParent()->GetReferenceAsString();
170 aReason.m_reason =
171 wxString::Format( _( "Component %s expects %lu matching pads but candidate %s provides %lu." ),
172 aReason.m_reference, static_cast<unsigned long>( pref.size() ),
173 aReason.m_candidate, static_cast<unsigned long>( ptgt.size() ) );
174 return false;
175 }
176
177 for( unsigned int i = 0; i < pref.size(); i++ )
178 {
179 pairs[pref[i]] = ptgt[i];
180 }
181
182 for( PIN* refPin : aRef->Pins() )
183 {
184 wxLogTrace( traceTopoMatch, wxT( "pad %s-%s: " ),
185 aRef->GetParent()->GetReferenceAsString(), refPin->GetReference() );
186
187 std::optional<int> prevNet;
188
189 for( COMPONENT* refCmp : aRefGraph->Components() )
190 {
191 for( PIN* ppin : refCmp->Pins() )
192 {
193 if ( ppin->GetNetCode() != refPin->GetNetCode() )
194 continue;
195
196 wxLogTrace( traceTopoMatch, wxT( "{ref %s-%s:%d} " ),
197 ppin->GetParent()->GetParent()->GetReferenceAsString(),
198 ppin->GetReference(), ppin->GetNetCode() );
199
200 auto tpin = pairs.find( ppin );
201
202 if( tpin != pairs.end() )
203 {
204 int nc = tpin->second->GetNetCode();
205
206 if( prevNet && ( *prevNet != nc ) )
207 {
208 wxLogTrace( traceTopoMatch, wxT( "nets inconsistent\n" ) );
209
210 aReason.m_reference = aRef->GetParent()->GetReferenceAsString();
211 aReason.m_candidate = aTgt->GetParent()->GetReferenceAsString();
212
213 wxString refNetName;
214 wxString tgtNetName;
215
216 if( const BOARD* refBoard = aRef->GetParent()->GetBoard() )
217 {
218 if( const NETINFO_ITEM* net = refBoard->FindNet( refPin->GetNetCode() ) )
219 refNetName = net->GetNetname();
220 }
221
222 if( const BOARD* tgtBoard = aTgt->GetParent()->GetBoard() )
223 {
224 if( const NETINFO_ITEM* net = tgtBoard->FindNet( nc ) )
225 tgtNetName = net->GetNetname();
226 }
227
228 if( refNetName.IsEmpty() )
229 refNetName = wxString::Format( _( "net %d" ), refPin->GetNetCode() );
230
231 if( tgtNetName.IsEmpty() )
232 tgtNetName = wxString::Format( _( "net %d" ), nc );
233
234 aReason.m_reason = wxString::Format(
235 _( "Pad %s of %s is on net %s but its match in candidate %s is on net %s." ),
236 refPin->GetReference(), aReason.m_reference, refNetName, aReason.m_candidate,
237 tgtNetName );
238
239 return false;
240 }
241
242 prevNet = nc;
243 }
244 }
245 }
246 }
247
248 return true;
249}
250
251
252std::vector<COMPONENT*>
254 const BACKTRACK_STAGE& partialMatches,
255 std::vector<TOPOLOGY_MISMATCH_REASON>& aMismatchReasons )
256{
257 aMismatchReasons.clear();
258 std::vector<COMPONENT*> matches;
259 for( auto cmpTarget : m_components )
260 {
261 // already matched to sth? move on.
262 if( partialMatches.m_locked.find( cmpTarget ) != partialMatches.m_locked.end() )
263 {
264 continue;
265 }
266
267 wxLogTrace( traceTopoMatch, wxT( "Check '%s'/'%s' " ), aRef->m_reference,
268 cmpTarget->m_reference );
269
270 // first, a basic heuristic (reference prefix, pin count & footprint) followed by a pin
271 // connection topology check
272 TOPOLOGY_MISMATCH_REASON localReason;
273 localReason.m_reference = aRef->GetParent()->GetReferenceAsString();
274 localReason.m_candidate = cmpTarget->GetParent()->GetReferenceAsString();
275
276 if( aRef->MatchesWith( cmpTarget, localReason ) )
277 {
278 // then a net integrity check (expensive because of poor optimization)
279 if( checkIfPadNetsMatch( partialMatches, aRefGraph, aRef, cmpTarget, localReason ) )
280 {
281 wxLogTrace( traceTopoMatch, wxT("match!\n") );
282 matches.push_back( cmpTarget );
283 }
284 else
285 {
286 wxLogTrace( traceTopoMatch, wxT("Reject [net topo mismatch]\n") );
287 aMismatchReasons.push_back( localReason );
288 }
289 }
290 else
291 {
292 wxLogTrace( traceTopoMatch, wxT("reject\n") );
293 aMismatchReasons.push_back( localReason );
294 }
295 }
296
297 auto padSimilarity=[]( COMPONENT*a, COMPONENT*b ) -> double
298 {
299 int n=0;
300
301 for(int i=0;i<a->m_pins.size();i++)
302 {
303 PIN* pa = a->m_pins[i];
304 PIN* pb = b->m_pins[i];
305
306 if( pa->GetNetCode() == pb->GetNetCode() )
307 n++;
308 }
309
310 return (double)n / (double) a->m_pins.size();
311 };
312
313
314 std::sort(matches.begin(), matches.end(), [&] ( COMPONENT*a, COMPONENT*b ) -> int
315 {
316 return padSimilarity( aRef,a ) > padSimilarity( aRef, b );
317 }
318);
319
320 if( matches.empty() )
321 {
323 reason.m_reference = aRef->GetParent()->GetReferenceAsString();
324 reason.m_reason = _( "No compatible component found in the target area." );
325
326 if( aMismatchReasons.empty() )
327 aMismatchReasons.push_back( reason );
328 }
329
330 return matches;
331}
332
333
335{
336 std::sort( m_pins.begin(), m_pins.end(),
337 []( PIN* a, PIN* b )
338 {
339 return a->GetReference() < b->GetReference();
340 } );
341}
342
343
345{
346 std::map<int, std::vector<PIN*>> nets;
347
349
350 for( auto c : m_components )
351 {
352 c->sortPinsByName();
353
354 for( auto p : c->Pins() )
355 {
356 if( p->GetNetCode() > 0 )
357 nets[p->GetNetCode()].push_back( p );
358 }
359 }
360
361 for( auto iter : nets )
362 {
363 wxLogTrace( traceTopoMatch, wxT( "net %d: %d connections\n" ), iter.first,
364 (int) iter.second.size() );
365
366 for( auto p : iter.second )
367 {
368 for( auto p2 : iter.second )
369 {
370 if( p != p2 && !alg::contains( p->m_conns, p2 ) )
371 {
372 p->m_conns.push_back( p2 );
373 }
374 }
375 }
376 }
377
378/* for( auto c : m_components )
379 for( auto p : c->Pins() )
380 {
381 printf("pin %s: \n", p->m_ref.c_str().AsChar() );
382
383 for( auto c : p->m_conns )
384 printf( "%s ", c->m_ref.c_str().AsChar() );
385 printf("\n");
386 }
387 */
388}
389
390
392 std::vector<TOPOLOGY_MISMATCH_REASON>& aMismatchReasons )
393{
394 std::vector<BACKTRACK_STAGE> stack;
395 BACKTRACK_STAGE top;
396
397 aMismatchReasons.clear();
398
399 std::vector<TOPOLOGY_MISMATCH_REASON> localReasons;
400
401 if( m_components.empty()|| aTarget->m_components.empty() )
402 {
404 reason.m_reason = _( "One or both of the areas has no components assigned." );
405 aMismatchReasons.push_back( reason );
406 return false;
407 }
408
409 if( m_components.size() != aTarget->m_components.size() )
410 {
412 reason.m_reason = _( "Component count mismatch" );
413 aMismatchReasons.push_back( reason );
414 return false;
415 }
416
417 top.m_ref = m_components.front();
418 top.m_refIndex = 0;
419
420 stack.push_back( top );
421
422 bool matchFound = false;
423 int nloops = 0;
424
425 while( !stack.empty() )
426 {
427 nloops++;
428 auto& current = stack.back();
429
430 for( auto it = current.m_locked.begin(); it != current.m_locked.end(); it++ )
431 {
432 if (it->second == current.m_ref)
433 {
434 wxLogTrace( traceTopoMatch, wxT( "stk: Remove %s from locked\n" ),
435 current.m_ref->m_reference );
436 current.m_locked.erase( it );
437 break;
438 }
439 }
440
441 if( nloops >= c_ITER_LIMIT )
442 {
443 wxLogTrace( traceTopoMatch, wxT( "stk: Iter cnt exceeded\n" ) );
444
446 reason.m_reason = _( "Iteration count exceeded (timeout)" );
447
448 if( aMismatchReasons.empty() )
449 aMismatchReasons.push_back( reason );
450 else
451 aMismatchReasons.insert( aMismatchReasons.begin(), reason );
452
453 return false;
454 }
455
456 if( current.m_currentMatch < 0 )
457 {
458 localReasons.clear();
459 current.m_matches = aTarget->findMatchingComponents( this, current.m_ref, current, localReasons );
460
461 if( current.m_matches.empty() && aMismatchReasons.empty() && !localReasons.empty() )
462 aMismatchReasons = localReasons;
463
464 current.m_currentMatch = 0;
465 }
466
467 wxLogTrace( traceTopoMatch, wxT( "stk: Current '%s' stack %d cm %d/%d locked %d/%d\n" ),
468 current.m_ref->m_reference, (int) stack.size(), current.m_currentMatch,
469 (int) current.m_matches.size(), (int) current.m_locked.size(),
470 (int) m_components.size() );
471
472 if ( current.m_matches.empty() )
473 {
474 wxLogTrace( traceTopoMatch, wxT( "stk: No matches at all, going up [level=%d]\n" ),
475 (int) stack.size() );
476 stack.pop_back();
477 continue;
478 }
479
480 if( current.m_currentMatch >= 0 && current.m_currentMatch >= current.m_matches.size() )
481 {
482 wxLogTrace( traceTopoMatch, wxT( "stk: No more matches, going up [level=%d]\n" ),
483 (int) stack.size() );
484 stack.pop_back();
485 continue;
486 }
487
488 auto& match = current.m_matches[current.m_currentMatch];
489
490 wxLogTrace( traceTopoMatch, wxT( "stk: candidate '%s', match list : ( " ),
491 current.m_matches[current.m_currentMatch]->m_reference, current.m_refIndex );
492
493 for( auto m : current.m_matches )
494 wxLogTrace( traceTopoMatch, wxT( "%s " ), m->GetParent()->GetReferenceAsString() );
495
496 wxLogTrace( traceTopoMatch, wxT( "\n" ) );
497
498 current.m_currentMatch++;
499 current.m_locked[match] = current.m_ref;
500
501 if( current.m_locked.size() == m_components.size() )
502 {
503 current.m_nloops = nloops;
504
505 aResult.clear();
506 aMismatchReasons.clear();
507
508 for( auto iter : current.m_locked )
509 aResult[ iter.second->GetParent() ] = iter.first->GetParent();
510
511 return true;
512 }
513
514
515 int minMatches = std::numeric_limits<int>::max();
516 COMPONENT* altNextRef = nullptr;
517 COMPONENT* bestNextRef = nullptr;
518 int bestRefIndex = 0;
519 int altRefIndex = 0;
520
521 for( size_t i = 0; i < m_components.size(); i++ )
522 {
523 COMPONENT* cmp = m_components[i];
524
525 if( cmp == current.m_ref )
526 continue;
527
528 bool found = false;
529
530 for( auto it = current.m_locked.begin(); it != current.m_locked.end(); it++ )
531 {
532 if( it->second == cmp )
533 {
534 found = true;
535 break;
536 }
537 }
538
539 if( found )
540 continue;
541
542 localReasons.clear();
543 auto matches = aTarget->findMatchingComponents( this, cmp, current, localReasons );
544
545 int nMatches = matches.size();
546
547 if( nMatches == 1 )
548 {
549 bestNextRef = cmp;
550 bestRefIndex = i;
551 break;
552 }
553 else if( nMatches == 0 )
554 {
555 altNextRef = cmp;
556 altRefIndex = i;
557
558 if( aMismatchReasons.empty() && !localReasons.empty() )
559 aMismatchReasons = localReasons;
560 }
561 else if( nMatches < minMatches )
562 {
563 minMatches = nMatches;
564 bestNextRef = cmp;
565 bestRefIndex = i;
566 }
567 }
568
569 BACKTRACK_STAGE next( current );
570 next.m_currentMatch = -1;
571
572 if( bestNextRef )
573 {
574 next.m_ref = bestNextRef;
575 next.m_refIndex = bestRefIndex;
576 }
577 else
578 {
579 next.m_ref = altNextRef;
580 next.m_refIndex = altRefIndex;
581 }
582
583 stack.push_back( next );
584 };
585
586 return false;
587}
588
589
590#if 0
591int main()
592{
593 FILE * f = fopen("connectivity.dump","rb" );
594 auto cgRef = loadCGraph(f);
595 auto cgTarget = loadCGraph(f);
596
597 cgRef->buildConnectivity();
598 cgTarget->buildConnectivity();
599
600 int attempts = 0;
601 int max_loops = 0;
602
603 for( ;; )
604 {
605 cgRef->shuffle();
606 cgTarget->shuffle();
607
608 const BacktrackStage latest = cgRef->matchCGraphs( cgTarget );
609
610 if( !latest.locked.size() )
611 {
612 printf("MATCH FAIL\n");
613 break;
614 }
615
616 //printf("loops: %d\n", latest.nloops );
617 //printf("Locked: %d\n", latest.locked.size() );
618
619 //if (matchFound)
620 //{
621 // for( auto& iter : latest.locked )
622 //{
623 // printf("%-10s : %-10s\n", iter.first->reference.c_str(), iter.second->reference.c_str() );
624 //}
625
626 //}
627
628 if( latest.nloops > max_loops )
629 {
630 max_loops = latest.nloops;
631 }
632
633 if (attempts % 10000 == 0)
634 {
635 printf("attempts: %d maxloops: %d\n", attempts, max_loops );
636 }
637
638 attempts++;
639
640 }
641
642 fclose(f);
643
644 return 0;
645}
646
647#endif
648
649
650COMPONENT::COMPONENT( const wxString& aRef, FOOTPRINT* aParentFp,
651 std::optional<VECTOR2I> aRaOffset ) :
652 m_reference( aRef ),
653 m_parentFootprint( aParentFp ), m_raOffset( aRaOffset )
654{
656}
657
658
659bool COMPONENT::IsSameKind( const COMPONENT& b ) const
660{
661 return m_prefix == b.m_prefix
662 && ( ( m_parentFootprint->GetFPID() == b.m_parentFootprint->GetFPID() )
663 || ( m_parentFootprint->GetFPID().empty()
664 && b.m_parentFootprint->GetFPID().empty() ) );
665}
666
667
669{
670 m_pins.push_back( aPin );
671 aPin->SetParent( this );
672}
673
674
676{
677 if( GetPinCount() != b->GetPinCount() )
678 {
681 aReason.m_reason =
682 wxString::Format( _( "Component %s has %d pads but candidate %s has %d." ), aReason.m_reference,
683 GetPinCount(), aReason.m_candidate, b->GetPinCount() );
684 return false;
685 }
686
687 if( !IsSameKind( *b ) )
688 {
691
692 if( m_prefix != b->m_prefix )
693 {
694 aReason.m_reason = wxString::Format(
695 _( "Reference prefix mismatch: %s uses prefix '%s' but candidate %s uses '%s'." ),
696 aReason.m_reference, m_prefix, aReason.m_candidate, b->m_prefix );
697 }
698 else
699 {
700 wxString refFootprint = GetParent()->GetFPIDAsString();
701 wxString candFootprint = b->GetParent()->GetFPIDAsString();
702
703 if( refFootprint.IsEmpty() )
704 refFootprint = _( "(no library ID)" );
705
706 if( candFootprint.IsEmpty() )
707 candFootprint = _( "(no library ID)" );
708
709 aReason.m_reason =
710 wxString::Format( _( "Library link mismatch: %s expects '%s' but candidate %s is '%s'." ),
711 aReason.m_reference, refFootprint, aReason.m_candidate, candFootprint );
712 }
713
714 return false;
715 }
716
717 for( int pin = 0; pin < b->GetPinCount(); pin++ )
718 {
719 if( !b->m_pins[pin]->IsIsomorphic( *m_pins[pin], aReason ) )
720 {
721 if( aReason.m_reason.IsEmpty() )
722 {
725 aReason.m_reason = wxString::Format( _( "Component pads differ between %s and %s." ),
726 aReason.m_reference, aReason.m_candidate );
727 }
728
729 return false;
730 }
731
732 }
733
734 return true;
735}
736
737
739{
740 auto cmp = new COMPONENT( aFp->GetReference(), aFp );
741
742 for( auto pad : aFp->Pads() )
743 {
744 auto pin = new PIN( );
745 pin->m_netcode = pad->GetNetCode();
746 pin->m_ref = pad->GetNumber();
747 cmp->AddPin( pin );
748 }
749
750 m_components.push_back( cmp );
751}
752
753
754std::unique_ptr<CONNECTION_GRAPH>
755CONNECTION_GRAPH::BuildFromFootprintSet( const std::set<FOOTPRINT*>& aFps )
756{
757 auto cgraph = std::make_unique<CONNECTION_GRAPH>();
758 VECTOR2I ref(0, 0);
759
760 if( aFps.size() > 0 )
761 ref = (*aFps.begin())->GetPosition();
762
763 for( auto fp : aFps )
764 {
765 cgraph->AddFootprint( fp, fp->GetPosition() - ref );
766 }
767
768 cgraph->BuildConnectivity();
769
770 return std::move(cgraph);
771}
772
773
778
779
781{
782 for( COMPONENT* fp : m_components )
783 {
784 delete fp;
785 }
786}
787
788
790{
791 for( PIN* p : m_pins )
792 {
793 delete p;
794 }
795}
796
797
798}; // namespace TMATCH
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:322
std::deque< PAD * > & Pads()
Definition footprint.h:224
wxString GetFPIDAsString() const
Definition footprint.h:275
const LIB_ID & GetFPID() const
Definition footprint.h:269
wxString GetReferenceAsString() const
Definition footprint.h:670
const wxString & GetReference() const
Definition footprint.h:661
bool empty() const
Definition lib_id.h:193
Handle the data for a net.
Definition netinfo.h:54
const std::map< COMPONENT *, COMPONENT * > & GetMatchingComponentPairs() const
Definition topo_match.h:145
std::map< COMPONENT *, COMPONENT * > m_locked
Definition topo_match.h:152
bool IsSameKind(const COMPONENT &b) const
int GetPinCount() const
Definition topo_match.h:63
COMPONENT(const wxString &aRef, FOOTPRINT *aParentFp, std::optional< VECTOR2I > aRaOffset=std::optional< VECTOR2I >())
FOOTPRINT * m_parentFootprint
Definition topo_match.h:78
std::optional< VECTOR2I > m_raOffset
Definition topo_match.h:75
bool MatchesWith(COMPONENT *b, TOPOLOGY_MISMATCH_REASON &aDetail)
wxString m_prefix
Definition topo_match.h:77
void AddPin(PIN *p)
std::vector< PIN * > & Pins()
Definition topo_match.h:65
friend class PIN
Definition topo_match.h:54
wxString m_reference
Definition topo_match.h:76
std::vector< PIN * > m_pins
Definition topo_match.h:79
FOOTPRINT * GetParent() const
Definition topo_match.h:66
std::vector< COMPONENT * > & Components()
Definition topo_match.h:171
std::vector< COMPONENT * > m_components
Definition topo_match.h:189
void AddFootprint(FOOTPRINT *aFp, const VECTOR2I &aOffset)
static std::unique_ptr< CONNECTION_GRAPH > BuildFromFootprintSet(const std::set< FOOTPRINT * > &aFps)
bool FindIsomorphism(CONNECTION_GRAPH *target, COMPONENT_MATCHES &result, std::vector< TOPOLOGY_MISMATCH_REASON > &aFailureDetails)
std::vector< COMPONENT * > findMatchingComponents(CONNECTION_GRAPH *aRefGraph, COMPONENT *ref, const BACKTRACK_STAGE &partialMatches, std::vector< TOPOLOGY_MISMATCH_REASON > &aFailureDetails)
std::vector< PIN * > m_conns
Definition topo_match.h:119
void SetParent(COMPONENT *parent)
Definition topo_match.h:90
COMPONENT * m_parent
Definition topo_match.h:118
bool IsIsomorphic(const PIN &b, TOPOLOGY_MISMATCH_REASON &aDetail) const
int GetNetCode() const
Definition topo_match.h:108
wxString m_ref
Definition topo_match.h:116
#define _(s)
std::map< FOOTPRINT *, FOOTPRINT * > COMPONENT_MATCHES
Definition topo_match.h:156
bool checkIfPadNetsMatch(const BACKTRACK_STAGE &aMatches, CONNECTION_GRAPH *aRefGraph, COMPONENT *aRef, COMPONENT *aTgt, TOPOLOGY_MISMATCH_REASON &aReason)
wxString GetRefDesPrefix(const wxString &aRefDes)
Get the (non-numeric) prefix from a refdes - e.g.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition kicad_algo.h:100
CITER next(CITER it)
Definition ptree.cpp:124
Collection of utility functions for component reference designators (refdes)
static const wxString traceTopoMatch
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695