KiCad PCB EDA Suite
CONNECTIVITY_DATA Class Reference

#include <connectivity_data.h>

Public Member Functions

 CONNECTIVITY_DATA ()
 
 ~CONNECTIVITY_DATA ()
 
 CONNECTIVITY_DATA (const std::vector< BOARD_ITEM * > &aItems, bool aSkipItems=false)
 
void Build (BOARD *aBoard, PROGRESS_REPORTER *aReporter=nullptr)
 Function Build() Builds the connectivity database for the board aBoard. More...
 
void Build (const std::vector< BOARD_ITEM * > &aItems)
 Function Build() Builds the connectivity database for a set of items aItems. More...
 
bool Add (BOARD_ITEM *aItem)
 Function Add() Adds an item to the connectivity data. More...
 
bool Remove (BOARD_ITEM *aItem)
 Function Remove() Removes an item from the connectivity data. More...
 
bool Update (BOARD_ITEM *aItem)
 Function Update() Updates the connectivity data for an item. More...
 
void Move (const VECTOR2I &aDelta)
 Moves the connectivity list anchors. More...
 
void Clear ()
 Function Clear() Erases the connectivity database. More...
 
int GetNetCount () const
 Function GetNetCount() Returns the total number of nets in the connectivity database. More...
 
RN_NETGetRatsnestForNet (int aNet)
 Function GetRatsnestForNet() Returns the ratsnest, expressed as a set of graph edges for a given net. More...
 
void PropagateNets (BOARD_COMMIT *aCommit=nullptr, PROPAGATE_MODE aMode=PROPAGATE_MODE::SKIP_CONFLICTS)
 Propagates the net codes from the source pads to the tracks/vias. More...
 
bool CheckConnectivity (std::vector< CN_DISJOINT_NET_ENTRY > &aReport)
 
void FindIsolatedCopperIslands (ZONE *aZone, std::vector< int > &aIslands)
 Function FindIsolatedCopperIslands() Searches for copper islands in zone aZone that are not connected to any pad. More...
 
void FindIsolatedCopperIslands (std::vector< CN_ZONE_ISOLATED_ISLAND_LIST > &aZones, bool aConnectivityAlreadyRebuilt=false)
 
void RecalculateRatsnest (BOARD_COMMIT *aCommit=nullptr)
 Function RecalculateRatsnest() Updates the ratsnest for the board. More...
 
unsigned int GetUnconnectedCount () const
 Function GetUnconnectedCount() Returns the number of remaining edges in the ratsnest. More...
 
bool IsConnectedOnLayer (const BOARD_CONNECTED_ITEM *aItem, int aLayer, const std::initializer_list< KICAD_T > &aTypes={}, bool aCheckOptionalFlashing=false) const
 
unsigned int GetNodeCount (int aNet=-1) const
 
unsigned int GetPadCount (int aNet=-1) const
 
const std::vector< PCB_TRACK * > GetConnectedTracks (const BOARD_CONNECTED_ITEM *aItem) const
 
const std::vector< PAD * > GetConnectedPads (const BOARD_CONNECTED_ITEM *aItem) const
 
void GetConnectedPads (const BOARD_CONNECTED_ITEM *aItem, std::set< PAD * > *pads) const
 
const std::vector< BOARD_CONNECTED_ITEM * > GetConnectedItemsAtAnchor (const BOARD_CONNECTED_ITEM *aItem, const VECTOR2I &aAnchor, const KICAD_T aTypes[], const int &aMaxError=0) const
 Function GetConnectedItemsAtAnchor() Returns a list of items connected to a source item aItem at position aAnchor with an optional maximum distance from the defined anchor. More...
 
void GetUnconnectedEdges (std::vector< CN_EDGE > &aEdges) const
 
bool TestTrackEndpointDangling (PCB_TRACK *aTrack, VECTOR2I *aPos=nullptr)
 
void ClearDynamicRatsnest ()
 Function ClearDynamicRatsnest() Erases the temporary dynamic ratsnest (i.e. More...
 
void HideDynamicRatsnest ()
 Hides the temporary dynamic ratsnest lines. More...
 
void ComputeDynamicRatsnest (const std::vector< BOARD_ITEM * > &aItems, const CONNECTIVITY_DATA *aDynamicData, VECTOR2I aInternalOffset={ 0, 0 })
 Function ComputeDynamicRatsnest() Calculates the temporary dynamic ratsnest (i.e. More...
 
const std::vector< RN_DYNAMIC_LINE > & GetDynamicRatsnest () const
 
const std::vector< BOARD_CONNECTED_ITEM * > GetConnectedItems (const BOARD_CONNECTED_ITEM *aItem, const std::initializer_list< KICAD_T > &aTypes, bool aIgnoreNetcodes=false) const
 Function GetConnectedItems() Returns a list of items connected to a source item aItem. More...
 
const std::vector< BOARD_CONNECTED_ITEM * > GetNetItems (int aNetCode, const KICAD_T aTypes[]) const
 Function GetNetItems() Returns the list of items that belong to a certain net. More...
 
void BlockRatsnestItems (const std::vector< BOARD_ITEM * > &aItems)
 
std::shared_ptr< CN_CONNECTIVITY_ALGOGetConnectivityAlgo () const
 
KISPINLOCKGetLock ()
 
void MarkItemNetAsDirty (BOARD_ITEM *aItem)
 
void SetProgressReporter (PROGRESS_REPORTER *aReporter)
 
const std::map< int, wxString > & GetNetclassMap () const
 
void AddExclusion (const KIID &aBoardItemId1, const KIID &aBoardItemId2)
 
void RemoveExclusion (const KIID &aBoardItemId1, const KIID &aBoardItemId2)
 
const std::vector< CN_EDGEGetRatsnestForItems (const std::vector< BOARD_ITEM * > aItems)
 
const std::vector< CN_EDGEGetRatsnestForPad (const PAD *aPad)
 
const std::vector< CN_EDGEGetRatsnestForComponent (FOOTPRINT *aComponent, bool aSkipInternalConnections=false)
 
std::shared_ptr< FROM_TO_CACHEGetFromToCache ()
 

Private Member Functions

void updateRatsnest ()
 
void addRatsnestCluster (const std::shared_ptr< CN_CLUSTER > &aCluster)
 

Private Attributes

std::shared_ptr< CN_CONNECTIVITY_ALGOm_connAlgo
 
std::shared_ptr< FROM_TO_CACHEm_fromToCache
 
std::vector< RN_DYNAMIC_LINEm_dynamicRatsnest
 
std::vector< RN_NET * > m_nets
 
bool m_skipRatsnest = false
 Used to suppress ratsnest calculations on dynamic ratsnests. More...
 
std::set< std::pair< KIID, KIID > > m_exclusions
 Ratsnest lines that have been excluded in DRC. More...
 
KISPINLOCK m_lock
 
std::map< int, wxString > m_netclassMap
 Map of netcode -> netclass the net is a member of; used for ratsnest painting. More...
 
PROGRESS_REPORTERm_progressReporter
 

Detailed Description

Definition at line 100 of file connectivity_data.h.

Constructor & Destructor Documentation

◆ CONNECTIVITY_DATA() [1/2]

CONNECTIVITY_DATA::CONNECTIVITY_DATA ( )

Definition at line 46 of file connectivity_data.cpp.

47{
49 m_progressReporter = nullptr;
50 m_fromToCache.reset( new FROM_TO_CACHE );
51}
PROGRESS_REPORTER * m_progressReporter
std::shared_ptr< CN_CONNECTIVITY_ALGO > m_connAlgo
std::shared_ptr< FROM_TO_CACHE > m_fromToCache

References m_connAlgo, m_fromToCache, and m_progressReporter.

◆ ~CONNECTIVITY_DATA()

CONNECTIVITY_DATA::~CONNECTIVITY_DATA ( )

Definition at line 63 of file connectivity_data.cpp.

64{
65 Clear();
66}
void Clear()
Function Clear() Erases the connectivity database.

References Clear().

◆ CONNECTIVITY_DATA() [2/2]

CONNECTIVITY_DATA::CONNECTIVITY_DATA ( const std::vector< BOARD_ITEM * > &  aItems,
bool  aSkipItems = false 
)

Definition at line 54 of file connectivity_data.cpp.

55 : m_skipRatsnest( aSkipRatsnest )
56{
57 Build( aItems );
58 m_progressReporter = nullptr;
59 m_fromToCache.reset( new FROM_TO_CACHE );
60}
bool m_skipRatsnest
Used to suppress ratsnest calculations on dynamic ratsnests.
void Build(BOARD *aBoard, PROGRESS_REPORTER *aReporter=nullptr)
Function Build() Builds the connectivity database for the board aBoard.

References Build(), m_fromToCache, and m_progressReporter.

Member Function Documentation

◆ Add()

bool CONNECTIVITY_DATA::Add ( BOARD_ITEM aItem)

Function Add() Adds an item to the connectivity data.

Parameters
aItemis an item to be added.
Returns
True if operation succeeded.

Definition at line 69 of file connectivity_data.cpp.

70{
71 m_connAlgo->Add( aItem );
72 return true;
73}

References m_connAlgo.

◆ AddExclusion()

void CONNECTIVITY_DATA::AddExclusion ( const KIID aBoardItemId1,
const KIID aBoardItemId2 
)

Definition at line 881 of file connectivity_data.cpp.

882{
883 m_exclusions.emplace( aBoardItemId1, aBoardItemId2 );
884 m_exclusions.emplace( aBoardItemId2, aBoardItemId1 );
885
886 for( RN_NET* rnNet : m_nets )
887 {
888 for( CN_EDGE& edge : rnNet->GetEdges() )
889 {
890 if( ( edge.GetSourceNode()->Parent()->m_Uuid == aBoardItemId1
891 && edge.GetTargetNode()->Parent()->m_Uuid == aBoardItemId2 )
892 || ( edge.GetSourceNode()->Parent()->m_Uuid == aBoardItemId2
893 && edge.GetTargetNode()->Parent()->m_Uuid == aBoardItemId1 ) )
894 {
895 edge.SetVisible( false );
896 }
897 }
898 }
899}
CN_EDGE represents a point-to-point connection, whether realized or unrealized (ie: tracks etc.
std::set< std::pair< KIID, KIID > > m_exclusions
Ratsnest lines that have been excluded in DRC.
std::vector< RN_NET * > m_nets
Describe ratsnest for a single net.
Definition: ratsnest_data.h:63

References m_exclusions, and m_nets.

◆ addRatsnestCluster()

void CONNECTIVITY_DATA::addRatsnestCluster ( const std::shared_ptr< CN_CLUSTER > &  aCluster)
private

Definition at line 185 of file connectivity_data.cpp.

186{
187 RN_NET* rnNet = m_nets[ aCluster->OriginNet() ];
188
189 rnNet->AddCluster( aCluster );
190}
void AddCluster(std::shared_ptr< CN_CLUSTER > aCluster)

References RN_NET::AddCluster(), and m_nets.

Referenced by RecalculateRatsnest().

◆ BlockRatsnestItems()

void CONNECTIVITY_DATA::BlockRatsnestItems ( const std::vector< BOARD_ITEM * > &  aItems)

Definition at line 245 of file connectivity_data.cpp.

246{
247 std::vector<BOARD_CONNECTED_ITEM*> citems;
248
249 for( BOARD_ITEM* item : aItems )
250 {
251 if( item->Type() == PCB_FOOTPRINT_T )
252 {
253 for( PAD* pad : static_cast<FOOTPRINT*>(item)->Pads() )
254 citems.push_back( pad );
255 }
256 else
257 {
258 if( BOARD_CONNECTED_ITEM* citem = dynamic_cast<BOARD_CONNECTED_ITEM*>( item ) )
259 citems.push_back( citem );
260 }
261 }
262
263 for( const BOARD_CONNECTED_ITEM* item : citems )
264 {
265 if ( m_connAlgo->ItemExists( item ) )
266 {
267 CN_CONNECTIVITY_ALGO::ITEM_MAP_ENTRY& entry = m_connAlgo->ItemEntry( item );
268
269 for( CN_ITEM* cnItem : entry.GetItems() )
270 {
271 for( const std::shared_ptr<CN_ANCHOR>& anchor : cnItem->Anchors() )
272 anchor->SetNoLine( true );
273 }
274 }
275 }
276}
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:53
const std::list< CN_ITEM * > GetItems() const
CN_ITEM represents a BOARD_CONNETED_ITEM in the connectivity system (ie: a pad, track/arc/via,...
Definition: pad.h:59
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:88

References anchor, CN_CONNECTIVITY_ALGO::ITEM_MAP_ENTRY::GetItems(), m_connAlgo, pad, and PCB_FOOTPRINT_T.

◆ Build() [1/2]

void CONNECTIVITY_DATA::Build ( BOARD aBoard,
PROGRESS_REPORTER aReporter = nullptr 
)

Function Build() Builds the connectivity database for the board aBoard.

Definition at line 91 of file connectivity_data.cpp.

92{
93 aBoard->CacheTriangulation( aReporter );
94
95 std::unique_lock<KISPINLOCK> lock( m_lock, std::try_to_lock );
96
97 if( !lock )
98 return;
99
100 if( aReporter )
101 {
102 aReporter->Report( _( "Updating nets..." ) );
103 aReporter->KeepRefreshing( false );
104 }
105
106 m_connAlgo.reset( new CN_CONNECTIVITY_ALGO );
107 m_connAlgo->Build( aBoard, aReporter );
108
109 m_netclassMap.clear();
110
111 for( NETINFO_ITEM* net : aBoard->GetNetInfo() )
112 {
113 if( net->GetNetClass()->GetName() != NETCLASS::Default )
114 m_netclassMap[ net->GetNetCode() ] = net->GetNetClass()->GetName();
115 }
116
117 if( aReporter )
118 {
119 aReporter->SetCurrentProgress( 0.75 );
120 aReporter->KeepRefreshing( false );
121 }
122
124
125 if( aReporter )
126 {
127 aReporter->SetCurrentProgress( 1.0 );
128 aReporter->KeepRefreshing( false );
129 }
130}
const NETINFO_LIST & GetNetInfo() const
Definition: board.h:737
void CacheTriangulation(PROGRESS_REPORTER *aReporter=nullptr, const std::vector< ZONE * > &aZones={})
Definition: board.cpp:633
void RecalculateRatsnest(BOARD_COMMIT *aCommit=nullptr)
Function RecalculateRatsnest() Updates the ratsnest for the board.
std::map< int, wxString > m_netclassMap
Map of netcode -> netclass the net is a member of; used for ratsnest painting.
static const char Default[]
the name of the default NETCLASS
Definition: netclass.h:49
Handle the data for a net.
Definition: netinfo.h:66
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
virtual void Report(const wxString &aMessage)=0
Display aMessage in the progress bar dialog.
virtual void SetCurrentProgress(double aProgress)=0
Set the progress value to aProgress (0..1).
#define _(s)

References _, BOARD::CacheTriangulation(), NETCLASS::Default, BOARD::GetNetInfo(), PROGRESS_REPORTER::KeepRefreshing(), m_connAlgo, m_lock, m_netclassMap, RecalculateRatsnest(), PROGRESS_REPORTER::Report(), and PROGRESS_REPORTER::SetCurrentProgress().

Referenced by CONNECTIVITY_DATA().

◆ Build() [2/2]

void CONNECTIVITY_DATA::Build ( const std::vector< BOARD_ITEM * > &  aItems)

Function Build() Builds the connectivity database for a set of items aItems.

Definition at line 133 of file connectivity_data.cpp.

134{
135 std::unique_lock<KISPINLOCK> lock( m_lock, std::try_to_lock );
136
137 if( !lock )
138 return;
139
140 m_connAlgo.reset( new CN_CONNECTIVITY_ALGO );
141 m_connAlgo->LocalBuild( aItems );
142
144}

References m_connAlgo, m_lock, and RecalculateRatsnest().

◆ CheckConnectivity()

bool CONNECTIVITY_DATA::CheckConnectivity ( std::vector< CN_DISJOINT_NET_ENTRY > &  aReport)

Definition at line 541 of file connectivity_data.cpp.

542{
544
545 for( auto net : m_nets )
546 {
547 if( net )
548 {
549 for( const auto& edge : net->GetEdges() )
550 {
552 ent.net = edge.GetSourceNode()->Parent()->GetNetCode();
553 ent.a = edge.GetSourceNode()->Parent();
554 ent.b = edge.GetTargetNode()->Parent();
555 ent.anchorA = edge.GetSourceNode()->Pos();
556 ent.anchorB = edge.GetTargetNode()->Pos();
557 aReport.push_back( ent );
558 }
559 }
560 }
561
562 return aReport.empty();
563}
BOARD_CONNECTED_ITEM * b
BOARD_CONNECTED_ITEM * a
int net
VECTOR2I anchorB
VECTOR2I anchorA

References CN_DISJOINT_NET_ENTRY::a, CN_DISJOINT_NET_ENTRY::anchorA, CN_DISJOINT_NET_ENTRY::anchorB, CN_DISJOINT_NET_ENTRY::b, m_nets, CN_DISJOINT_NET_ENTRY::net, and RecalculateRatsnest().

◆ Clear()

void CONNECTIVITY_DATA::Clear ( )

Function Clear() Erases the connectivity database.

Definition at line 476 of file connectivity_data.cpp.

477{
478 for( RN_NET* net : m_nets )
479 delete net;
480
481 m_nets.clear();
482}

References m_nets.

Referenced by ~CONNECTIVITY_DATA().

◆ ClearDynamicRatsnest()

void CONNECTIVITY_DATA::ClearDynamicRatsnest ( )

Function ClearDynamicRatsnest() Erases the temporary dynamic ratsnest (i.e.

the ratsnest lines that pcbnew displays when moving an item/set of items)

Definition at line 350 of file connectivity_data.cpp.

351{
352 m_connAlgo->ForEachAnchor( []( CN_ANCHOR& anchor )
353 {
354 anchor.SetNoLine( false );
355 } );
357}
CN_ANCHOR represents a physical location that can be connected: a pad or a track/arc/via endpoint.
void HideDynamicRatsnest()
Hides the temporary dynamic ratsnest lines.

References anchor, HideDynamicRatsnest(), and m_connAlgo.

◆ ComputeDynamicRatsnest()

void CONNECTIVITY_DATA::ComputeDynamicRatsnest ( const std::vector< BOARD_ITEM * > &  aItems,
const CONNECTIVITY_DATA aDynamicData,
VECTOR2I  aInternalOffset = { 0, 0 } 
)

Function ComputeDynamicRatsnest() Calculates the temporary dynamic ratsnest (i.e.

the ratsnest lines that) for the set of items aItems.

Definition at line 300 of file connectivity_data.cpp.

303{
304 if( !aDynamicData )
305 return;
306
307 m_dynamicRatsnest.clear();
308
309 // This gets connections between the stationary board and the
310 // moving selection
311 for( unsigned int nc = 1; nc < aDynamicData->m_nets.size(); nc++ )
312 {
313 auto dynNet = aDynamicData->m_nets[nc];
314
315 if( dynNet->GetNodeCount() != 0 )
316 {
317 RN_NET* ourNet = m_nets[nc];
318 VECTOR2I pos1, pos2;
319
320 if( ourNet->NearestBicoloredPair( *dynNet, &pos1, &pos2 ) )
321 {
323 l.a = pos1;
324 l.b = pos2;
325 l.netCode = nc;
326
327 m_dynamicRatsnest.push_back( l );
328 }
329 }
330 }
331
332 // This gets the ratsnest for internal connections in the moving set
333 const std::vector<CN_EDGE>& edges = GetRatsnestForItems( aItems );
334
335 for( const CN_EDGE& edge : edges )
336 {
337 const std::shared_ptr<CN_ANCHOR>& nodeA = edge.GetSourceNode();
338 const std::shared_ptr<CN_ANCHOR>& nodeB = edge.GetTargetNode();
340
341 // Use the parents' positions
342 l.a = nodeA->Parent()->GetPosition() + aInternalOffset;
343 l.b = nodeB->Parent()->GetPosition() + aInternalOffset;
344 l.netCode = 0;
345 m_dynamicRatsnest.push_back( l );
346 }
347}
std::vector< RN_DYNAMIC_LINE > m_dynamicRatsnest
const std::vector< CN_EDGE > GetRatsnestForItems(const std::vector< BOARD_ITEM * > aItems)
bool NearestBicoloredPair(const RN_NET &aOtherNet, VECTOR2I *aPos1, VECTOR2I *aPos2) const

References RN_DYNAMIC_LINE::a, RN_DYNAMIC_LINE::b, GetRatsnestForItems(), m_dynamicRatsnest, m_nets, RN_NET::NearestBicoloredPair(), and RN_DYNAMIC_LINE::netCode.

◆ FindIsolatedCopperIslands() [1/2]

void CONNECTIVITY_DATA::FindIsolatedCopperIslands ( std::vector< CN_ZONE_ISOLATED_ISLAND_LIST > &  aZones,
bool  aConnectivityAlreadyRebuilt = false 
)

Definition at line 293 of file connectivity_data.cpp.

295{
296 m_connAlgo->FindIsolatedCopperIslands( aZones, aConnectivityAlreadyRebuilt );
297}

References m_connAlgo.

◆ FindIsolatedCopperIslands() [2/2]

void CONNECTIVITY_DATA::FindIsolatedCopperIslands ( ZONE aZone,
std::vector< int > &  aIslands 
)

Function FindIsolatedCopperIslands() Searches for copper islands in zone aZone that are not connected to any pad.

Parameters
aZonezone to test
aIslandslist of islands that have no connections (outline indices in the polygon set)

Definition at line 285 of file connectivity_data.cpp.

286{
287 // TODO(JE) ZONES
288#if 0
289 m_connAlgo->FindIsolatedCopperIslands( aZone, aIslands );
290#endif
291}

References m_connAlgo.

◆ GetConnectedItems()

const std::vector< BOARD_CONNECTED_ITEM * > CONNECTIVITY_DATA::GetConnectedItems ( const BOARD_CONNECTED_ITEM aItem,
const std::initializer_list< KICAD_T > &  aTypes,
bool  aIgnoreNetcodes = false 
) const

Function GetConnectedItems() Returns a list of items connected to a source item aItem.

Parameters
aItemis the reference item to find other connected items.
aTypesallows one to filter by item types.

Definition at line 486 of file connectivity_data.cpp.

488{
489 std::vector<BOARD_CONNECTED_ITEM*> rv;
491
492 if( aIgnoreNetcodes )
494 else
496
497 const auto clusters = m_connAlgo->SearchClusters( searchMode, aTypes,
498 aIgnoreNetcodes ? -1 : aItem->GetNetCode() );
499
500 for( const std::shared_ptr<CN_CLUSTER>& cl : clusters )
501 {
502 if( cl->Contains( aItem ) )
503 {
504 for( const CN_ITEM* item : *cl )
505 {
506 if( item->Valid() )
507 rv.push_back( item->Parent() );
508 }
509 }
510 }
511
512 return rv;
513}

References CN_CONNECTIVITY_ALGO::CSM_CONNECTIVITY_CHECK, CN_CONNECTIVITY_ALGO::CSM_PROPAGATE, BOARD_CONNECTED_ITEM::GetNetCode(), and m_connAlgo.

◆ GetConnectedItemsAtAnchor()

const std::vector< BOARD_CONNECTED_ITEM * > CONNECTIVITY_DATA::GetConnectedItemsAtAnchor ( const BOARD_CONNECTED_ITEM aItem,
const VECTOR2I aAnchor,
const KICAD_T  aTypes[],
const int &  aMaxError = 0 
) const

Function GetConnectedItemsAtAnchor() Returns a list of items connected to a source item aItem at position aAnchor with an optional maximum distance from the defined anchor.

Parameters
aItemis the reference item to find other connected items.
aAnchoris the position to find connected items on.
aTypesallows one to filter by item types.
aMaxErrorMaximum distance of the found items' anchors to aAnchor in IU
Returns

Definition at line 812 of file connectivity_data.cpp.

817{
818 auto& entry = m_connAlgo->ItemEntry( aItem );
819 std::vector<BOARD_CONNECTED_ITEM*> rv;
820 SEG::ecoord maxErrorSq = (SEG::ecoord) aMaxError * aMaxError;
821
822 for( auto cnItem : entry.GetItems() )
823 {
824 for( auto connected : cnItem->ConnectedItems() )
825 {
826 for( auto anchor : connected->Anchors() )
827 {
828 if( ( anchor->Pos() - aAnchor ).SquaredEuclideanNorm() <= maxErrorSq )
829 {
830 for( int i = 0; aTypes[i] > 0; i++ )
831 {
832 if( connected->Valid() && connected->Parent()->Type() == aTypes[i] )
833 {
834 rv.push_back( connected->Parent() );
835 break;
836 }
837 }
838
839 break;
840 }
841 }
842 }
843 }
844
845 return rv;
846}
VECTOR2I::extended_type ecoord
Definition: seg.h:44

References anchor, and m_connAlgo.

◆ GetConnectedPads() [1/2]

const std::vector< PAD * > CONNECTIVITY_DATA::GetConnectedPads ( const BOARD_CONNECTED_ITEM aItem) const

Definition at line 605 of file connectivity_data.cpp.

607{
608 std::set<PAD*> pads;
609 std::vector<PAD*> rv;
610
611 GetConnectedPads( aItem, &pads );
612
613 std::copy( pads.begin(), pads.end(), std::back_inserter( rv ) );
614 return rv;
615}
const std::vector< PAD * > GetConnectedPads(const BOARD_CONNECTED_ITEM *aItem) const

References GetConnectedPads().

Referenced by GetConnectedPads().

◆ GetConnectedPads() [2/2]

void CONNECTIVITY_DATA::GetConnectedPads ( const BOARD_CONNECTED_ITEM aItem,
std::set< PAD * > *  pads 
) const

Definition at line 591 of file connectivity_data.cpp.

593{
594 for( CN_ITEM* citem : m_connAlgo->ItemEntry( aItem ).GetItems() )
595 {
596 for( CN_ITEM* connected : citem->ConnectedItems() )
597 {
598 if( connected->Valid() && connected->Parent()->Type() == PCB_PAD_T )
599 pads->insert( static_cast<PAD*> ( connected->Parent() ) );
600 }
601 }
602}
const std::vector< CN_ITEM * > & ConnectedItems() const
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:89

References CN_ITEM::ConnectedItems(), m_connAlgo, and PCB_PAD_T.

◆ GetConnectedTracks()

const std::vector< PCB_TRACK * > CONNECTIVITY_DATA::GetConnectedTracks ( const BOARD_CONNECTED_ITEM aItem) const

Definition at line 566 of file connectivity_data.cpp.

568{
569 auto& entry = m_connAlgo->ItemEntry( aItem );
570
571 std::set<PCB_TRACK*> tracks;
572 std::vector<PCB_TRACK*> rv;
573
574 for( CN_ITEM* citem : entry.GetItems() )
575 {
576 for( CN_ITEM* connected : citem->ConnectedItems() )
577 {
578 if( connected->Valid() &&
579 ( connected->Parent()->Type() == PCB_TRACE_T ||
580 connected->Parent()->Type() == PCB_VIA_T ||
581 connected->Parent()->Type() == PCB_ARC_T ) )
582 tracks.insert( static_cast<PCB_TRACK*> ( connected->Parent() ) );
583 }
584 }
585
586 std::copy( tracks.begin(), tracks.end(), std::back_inserter( rv ) );
587 return rv;
588}
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:104
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:105
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:103

References CN_ITEM::ConnectedItems(), m_connAlgo, PCB_ARC_T, PCB_TRACE_T, and PCB_VIA_T.

◆ GetConnectivityAlgo()

std::shared_ptr< CN_CONNECTIVITY_ALGO > CONNECTIVITY_DATA::GetConnectivityAlgo ( ) const
inline

Definition at line 285 of file connectivity_data.h.

286 {
287 return m_connAlgo;
288 }

References m_connAlgo.

Referenced by TestTrackEndpointDangling().

◆ GetDynamicRatsnest()

const std::vector< RN_DYNAMIC_LINE > & CONNECTIVITY_DATA::GetDynamicRatsnest ( ) const
inline

Definition at line 260 of file connectivity_data.h.

261 {
262 return m_dynamicRatsnest;
263 }

References m_dynamicRatsnest.

◆ GetFromToCache()

std::shared_ptr< FROM_TO_CACHE > CONNECTIVITY_DATA::GetFromToCache ( )
inline

Definition at line 315 of file connectivity_data.h.

316 {
317 return m_fromToCache;
318 }

References m_fromToCache.

◆ GetLock()

KISPINLOCK & CONNECTIVITY_DATA::GetLock ( )
inline

Definition at line 290 of file connectivity_data.h.

291 {
292 return m_lock;
293 }

References m_lock.

◆ GetNetclassMap()

const std::map< int, wxString > & CONNECTIVITY_DATA::GetNetclassMap ( ) const
inline

Definition at line 298 of file connectivity_data.h.

299 {
300 return m_netclassMap;
301 }

References m_netclassMap.

◆ GetNetCount()

int CONNECTIVITY_DATA::GetNetCount ( ) const

Function GetNetCount() Returns the total number of nets in the connectivity database.

Definition at line 279 of file connectivity_data.cpp.

280{
281 return m_connAlgo->NetCount();
282}

References m_connAlgo.

◆ GetNetItems()

const std::vector< BOARD_CONNECTED_ITEM * > CONNECTIVITY_DATA::GetNetItems ( int  aNetCode,
const KICAD_T  aTypes[] 
) const

Function GetNetItems() Returns the list of items that belong to a certain net.

Parameters
aNetCodeis the net code.
aTypesallows one to filter by item types.

Definition at line 516 of file connectivity_data.cpp.

518{
519 std::vector<BOARD_CONNECTED_ITEM*> items;
520 items.reserve( 32 );
521
522 std::bitset<MAX_STRUCT_TYPE_ID> type_bits;
523
524 for( unsigned int i = 0; aTypes[i] != EOT; ++i )
525 {
526 wxASSERT( aTypes[i] < MAX_STRUCT_TYPE_ID );
527 type_bits.set( aTypes[i] );
528 }
529
530 m_connAlgo->ForEachItem( [&]( CN_ITEM& aItem ) {
531 if( aItem.Valid() && ( aItem.Net() == aNetCode ) && type_bits[aItem.Parent()->Type()] )
532 items.push_back( aItem.Parent() );
533 } );
534
535 std::sort( items.begin(), items.end() );
536 items.erase( std::unique( items.begin(), items.end() ), items.end() );
537 return items;
538}
int Net() const
allow parallel connection threads
bool Valid() const
BOARD_CONNECTED_ITEM * Parent() const
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
@ EOT
search types array terminator (End Of Types)
Definition: typeinfo.h:81
@ MAX_STRUCT_TYPE_ID
Definition: typeinfo.h:233

References EOT, m_connAlgo, MAX_STRUCT_TYPE_ID, CN_ITEM::Net(), CN_ITEM::Parent(), EDA_ITEM::Type(), and CN_ITEM::Valid().

◆ GetNodeCount()

unsigned int CONNECTIVITY_DATA::GetNodeCount ( int  aNet = -1) const

Definition at line 618 of file connectivity_data.cpp.

619{
620 int sum = 0;
621
622 if( aNet < 0 ) // Node count for all nets
623 {
624 for( const RN_NET* net : m_nets )
625 sum += net->GetNodeCount();
626 }
627 else if( aNet < (int) m_nets.size() )
628 {
629 sum = m_nets[aNet]->GetNodeCount();
630 }
631
632 return sum;
633}

References m_nets.

◆ GetPadCount()

unsigned int CONNECTIVITY_DATA::GetPadCount ( int  aNet = -1) const

Definition at line 636 of file connectivity_data.cpp.

637{
638 int n = 0;
639
640 for( CN_ITEM* pad : m_connAlgo->ItemList() )
641 {
642 if( !pad->Valid() || pad->Parent()->Type() != PCB_PAD_T)
643 continue;
644
645 PAD* dpad = static_cast<PAD*>( pad->Parent() );
646
647 if( aNet < 0 || aNet == dpad->GetNetCode() )
648 n++;
649 }
650
651 return n;
652}

References m_connAlgo, pad, and PCB_PAD_T.

◆ GetRatsnestForComponent()

const std::vector< CN_EDGE > CONNECTIVITY_DATA::GetRatsnestForComponent ( FOOTPRINT aComponent,
bool  aSkipInternalConnections = false 
)

Definition at line 987 of file connectivity_data.cpp.

988{
989 std::set<int> nets;
990 std::set<const PAD*> pads;
991 std::vector<CN_EDGE> edges;
992
993 for( auto pad : aComponent->Pads() )
994 {
995 nets.insert( pad->GetNetCode() );
996 pads.insert( pad );
997 }
998
999 for( const auto& netcode : nets )
1000 {
1001 RN_NET* net = GetRatsnestForNet( netcode );
1002
1003 for( const CN_EDGE& edge : net->GetEdges() )
1004 {
1005 auto srcNode = edge.GetSourceNode();
1006 auto dstNode = edge.GetTargetNode();
1007
1008 const PAD* srcParent = static_cast<const PAD*>( srcNode->Parent() );
1009 const PAD* dstParent = static_cast<const PAD*>( dstNode->Parent() );
1010
1011 bool srcFound = ( pads.find(srcParent) != pads.end() );
1012 bool dstFound = ( pads.find(dstParent) != pads.end() );
1013
1014 if ( srcFound && dstFound && !aSkipInternalConnections )
1015 {
1016 edges.push_back( edge );
1017 }
1018 else if ( srcFound || dstFound )
1019 {
1020 edges.push_back( edge );
1021 }
1022 }
1023 }
1024
1025 return edges;
1026}
RN_NET * GetRatsnestForNet(int aNet)
Function GetRatsnestForNet() Returns the ratsnest, expressed as a set of graph edges for a given net.
PADS & Pads()
Definition: footprint.h:175
const std::vector< CN_EDGE > & GetEdges() const
Definition: ratsnest_data.h:90

References RN_NET::GetEdges(), GetRatsnestForNet(), pad, and FOOTPRINT::Pads().

◆ GetRatsnestForItems()

const std::vector< CN_EDGE > CONNECTIVITY_DATA::GetRatsnestForItems ( const std::vector< BOARD_ITEM * >  aItems)

Definition at line 923 of file connectivity_data.cpp.

924{
925 std::set<int> nets;
926 std::vector<CN_EDGE> edges;
927 std::set<BOARD_CONNECTED_ITEM*> item_set;
928
929 for( BOARD_ITEM* item : aItems )
930 {
931 if( item->Type() == PCB_FOOTPRINT_T )
932 {
933 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( item );
934
935 for( PAD* pad : footprint->Pads() )
936 {
937 nets.insert( pad->GetNetCode() );
938 item_set.insert( pad );
939 }
940 }
941 else if( auto conn_item = dyn_cast<BOARD_CONNECTED_ITEM*>( item ) )
942 {
943 item_set.insert( conn_item );
944 nets.insert( conn_item->GetNetCode() );
945 }
946 }
947
948 for( int netcode : nets )
949 {
950 RN_NET* net = GetRatsnestForNet( netcode );
951
952 for( const CN_EDGE& edge : net->GetEdges() )
953 {
954 std::shared_ptr<CN_ANCHOR> srcNode = edge.GetSourceNode();
955 std::shared_ptr<CN_ANCHOR> dstNode = edge.GetTargetNode();
956
957 BOARD_CONNECTED_ITEM* srcParent = srcNode->Parent();
958 BOARD_CONNECTED_ITEM* dstParent = dstNode->Parent();
959
960 bool srcFound = ( item_set.find( srcParent ) != item_set.end() );
961 bool dstFound = ( item_set.find( dstParent ) != item_set.end() );
962
963 if ( srcFound && dstFound )
964 edges.push_back( edge );
965 }
966 }
967
968 return edges;
969}

References RN_NET::GetEdges(), GetRatsnestForNet(), pad, FOOTPRINT::Pads(), and PCB_FOOTPRINT_T.

Referenced by ComputeDynamicRatsnest().

◆ GetRatsnestForNet()

RN_NET * CONNECTIVITY_DATA::GetRatsnestForNet ( int  aNet)

Function GetRatsnestForNet() Returns the ratsnest, expressed as a set of graph edges for a given net.

Definition at line 849 of file connectivity_data.cpp.

850{
851 if ( aNet < 0 || aNet >= (int) m_nets.size() )
852 {
853 return nullptr;
854 }
855
856 return m_nets[ aNet ];
857}

References m_nets.

Referenced by GetRatsnestForComponent(), GetRatsnestForItems(), and GetRatsnestForPad().

◆ GetRatsnestForPad()

const std::vector< CN_EDGE > CONNECTIVITY_DATA::GetRatsnestForPad ( const PAD aPad)

Definition at line 972 of file connectivity_data.cpp.

973{
974 std::vector<CN_EDGE> edges;
975 RN_NET* net = GetRatsnestForNet( aPad->GetNetCode() );
976
977 for( const CN_EDGE& edge : net->GetEdges() )
978 {
979 if( edge.GetSourceNode()->Parent() == aPad || edge.GetTargetNode()->Parent() == aPad )
980 edges.push_back( edge );
981 }
982
983 return edges;
984}

References RN_NET::GetEdges(), BOARD_CONNECTED_ITEM::GetNetCode(), and GetRatsnestForNet().

◆ GetUnconnectedCount()

unsigned int CONNECTIVITY_DATA::GetUnconnectedCount ( ) const

Function GetUnconnectedCount() Returns the number of remaining edges in the ratsnest.

Definition at line 456 of file connectivity_data.cpp.

457{
458 unsigned int unconnected = 0;
459
460 for( RN_NET* net : m_nets )
461 {
462 if( !net )
463 continue;
464
465 for( const CN_EDGE& edge : net->GetEdges() )
466 {
467 if( edge.IsVisible() )
468 ++unconnected;
469 }
470 }
471
472 return unconnected;
473}

References m_nets.

◆ GetUnconnectedEdges()

void CONNECTIVITY_DATA::GetUnconnectedEdges ( std::vector< CN_EDGE > &  aEdges) const

Definition at line 655 of file connectivity_data.cpp.

656{
657 for( const RN_NET* rnNet : m_nets )
658 {
659 if( rnNet )
660 {
661 for( const CN_EDGE& edge : rnNet->GetEdges() )
662 aEdges.push_back( edge );
663 }
664 }
665}

References m_nets.

◆ HideDynamicRatsnest()

void CONNECTIVITY_DATA::HideDynamicRatsnest ( )

Hides the temporary dynamic ratsnest lines.

Definition at line 360 of file connectivity_data.cpp.

361{
362 m_dynamicRatsnest.clear();
363}

References m_dynamicRatsnest.

Referenced by ClearDynamicRatsnest().

◆ IsConnectedOnLayer()

bool CONNECTIVITY_DATA::IsConnectedOnLayer ( const BOARD_CONNECTED_ITEM aItem,
int  aLayer,
const std::initializer_list< KICAD_T > &  aTypes = {},
bool  aCheckOptionalFlashing = false 
) const

Definition at line 372 of file connectivity_data.cpp.

375{
376 CN_CONNECTIVITY_ALGO::ITEM_MAP_ENTRY &entry = m_connAlgo->ItemEntry( aItem );
377
378 auto matchType =
379 [&]( KICAD_T aItemType )
380 {
381 if( aTypes.size() == 0 )
382 return true;
383
384 return alg::contains( aTypes, aItemType);
385 };
386
387 for( CN_ITEM* citem : entry.GetItems() )
388 {
389 for( CN_ITEM* connected : citem->ConnectedItems() )
390 {
391 CN_ZONE_LAYER* zoneLayer = dynamic_cast<CN_ZONE_LAYER*>( connected );
392
393 if( connected->Valid()
394 && connected->Layers().Overlaps( aLayer )
395 && matchType( connected->Parent()->Type() )
396 && connected->Net() == aItem->GetNetCode() )
397 {
398 if( aItem->Type() == PCB_PAD_T && zoneLayer )
399 {
400 const PAD* pad = static_cast<const PAD*>( aItem );
401 ZONE* zone = static_cast<ZONE*>( zoneLayer->Parent() );
402 int islandIdx = zoneLayer->SubpolyIndex();
403
404 if( zone->IsFilled() )
405 {
406 const SHAPE_POLY_SET* zoneFill = zone->GetFill( ToLAYER_ID( aLayer ) );
407 const SHAPE_LINE_CHAIN& padHull = pad->GetEffectivePolygon()->Outline( 0 );
408
409 for( const VECTOR2I& pt : zoneFill->COutline( islandIdx ).CPoints() )
410 {
411 // If the entire island is inside the pad's flashing then the pad
412 // won't actually connect to anything else, so only return true if
413 // part of the island is *outside* the pad's flashing.
414
415 if( !padHull.PointInside( pt ) )
416 return true;
417 }
418 }
419
420 continue;
421 }
422 else if( aItem->Type() == PCB_VIA_T && zoneLayer )
423 {
424 const PCB_VIA* via = static_cast<const PCB_VIA*>( aItem );
425 ZONE* zone = static_cast<ZONE*>( zoneLayer->Parent() );
426 int islandIdx = zoneLayer->SubpolyIndex();
427
428 if( zone->IsFilled() )
429 {
430 const SHAPE_POLY_SET* zoneFill = zone->GetFill( ToLAYER_ID( aLayer ) );
431 SHAPE_CIRCLE viaHull( via->GetCenter(), via->GetWidth() / 2 );
432
433 for( const VECTOR2I& pt : zoneFill->COutline( islandIdx ).CPoints() )
434 {
435 // If the entire island is inside the via's flashing then the via
436 // won't actually connect to anything else, so only return true if
437 // part of the island is *outside* the via's flashing.
438
439 if( !viaHull.SHAPE::Collide( pt ) )
440 return true;
441 }
442 }
443
444 continue;
445 }
446
447 return true;
448 }
449 }
450 }
451
452 return false;
453}
int SubpolyIndex() const
bool PointInside(const VECTOR2I &aPt, int aAccuracy=0, bool aUseBBoxCache=false) const
Check if point aP lies inside a polygon (any type) defined by the line chain.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const std::vector< VECTOR2I > & CPoints() const
Represent a set of closed polygons.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
Handle a list of polygons defining a copper zone.
Definition: zone.h:58
bool IsFilled() const
Definition: zone.h:257
SHAPE_POLY_SET * GetFill(PCB_LAYER_ID aLayer)
Definition: zone.h:625
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:926
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:99
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78

References CN_ITEM::ConnectedItems(), alg::contains(), SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CPoints(), ZONE::GetFill(), CN_CONNECTIVITY_ALGO::ITEM_MAP_ENTRY::GetItems(), BOARD_CONNECTED_ITEM::GetNetCode(), ZONE::IsFilled(), m_connAlgo, pad, CN_ITEM::Parent(), PCB_PAD_T, PCB_VIA_T, SHAPE_LINE_CHAIN_BASE::PointInside(), CN_ZONE_LAYER::SubpolyIndex(), ToLAYER_ID(), EDA_ITEM::Type(), and via.

◆ MarkItemNetAsDirty()

void CONNECTIVITY_DATA::MarkItemNetAsDirty ( BOARD_ITEM aItem)

Definition at line 860 of file connectivity_data.cpp.

861{
862 if ( aItem->Type() == PCB_FOOTPRINT_T)
863 {
864 for( PAD* pad : static_cast<FOOTPRINT*>( aItem )->Pads() )
865 m_connAlgo->MarkNetAsDirty( pad->GetNetCode() );
866 }
867 if (aItem->IsConnected() )
868 {
869 m_connAlgo->MarkNetAsDirty( static_cast<BOARD_CONNECTED_ITEM*>( aItem )->GetNetCode() );
870 }
871}
virtual bool IsConnected() const
Returns information if the object is derived from BOARD_CONNECTED_ITEM.
Definition: board_item.h:108

References BOARD_ITEM::IsConnected(), m_connAlgo, pad, PCB_FOOTPRINT_T, and EDA_ITEM::Type().

◆ Move()

void CONNECTIVITY_DATA::Move ( const VECTOR2I aDelta)

Moves the connectivity list anchors.

N.B., this does not move the bounding boxes for the RTree, so the use of this function will invalidate the connectivity data for uses other than the dynamic ratsnest

Parameters
aDeltavector for movement of the tree

Definition at line 147 of file connectivity_data.cpp.

148{
149 m_connAlgo->ForEachAnchor( [&aDelta]( CN_ANCHOR& anchor )
150 {
151 anchor.Move( aDelta );
152 } );
153}

References anchor, and m_connAlgo.

Referenced by BOARD_INSPECTION_TOOL::calculateSelectionRatsnest().

◆ PropagateNets()

void CONNECTIVITY_DATA::PropagateNets ( BOARD_COMMIT aCommit = nullptr,
PROPAGATE_MODE  aMode = PROPAGATE_MODE::SKIP_CONFLICTS 
)

Propagates the net codes from the source pads to the tracks/vias.

Parameters
aCommitis used to save the undo state of items modified by this call
aModecontrols how conflicts between pads are resolved

Definition at line 366 of file connectivity_data.cpp.

367{
368 m_connAlgo->PropagateNets( aCommit, aMode );
369}

References m_connAlgo.

◆ RecalculateRatsnest()

void CONNECTIVITY_DATA::RecalculateRatsnest ( BOARD_COMMIT aCommit = nullptr)

Function RecalculateRatsnest() Updates the ratsnest for the board.

Parameters
aCommitis used to save the undo state of items modified by this call

Definition at line 193 of file connectivity_data.cpp.

194{
195 m_connAlgo->PropagateNets( aCommit );
196
197 int lastNet = m_connAlgo->NetCount();
198
199 if( lastNet >= (int) m_nets.size() )
200 {
201 unsigned int prevSize = m_nets.size();
202 m_nets.resize( lastNet + 1 );
203
204 for( unsigned int i = prevSize; i < m_nets.size(); i++ )
205 m_nets[i] = new RN_NET;
206 }
207
208 const std::vector<std::shared_ptr<CN_CLUSTER>>& clusters = m_connAlgo->GetClusters();
209
210 int dirtyNets = 0;
211
212 for( int net = 0; net < lastNet; net++ )
213 {
214 if( m_connAlgo->IsNetDirty( net ) )
215 {
216 m_nets[net]->Clear();
217 dirtyNets++;
218 }
219 }
220
221 for( const std::shared_ptr<CN_CLUSTER>& c : clusters )
222 {
223 int net = c->OriginNet();
224
225 // Don't add intentionally-kept zone islands to the ratsnest
226 if( c->IsOrphaned() && c->Size() == 1 )
227 {
228 if( dynamic_cast<CN_ZONE_LAYER*>( *c->begin() ) )
229 continue;
230 }
231
232 if( m_connAlgo->IsNetDirty( net ) )
233 {
235 }
236 }
237
238 m_connAlgo->ClearDirtyFlags();
239
240 if( !m_skipRatsnest )
242}
void addRatsnestCluster(const std::shared_ptr< CN_CLUSTER > &aCluster)

References addRatsnestCluster(), m_connAlgo, m_nets, m_skipRatsnest, and updateRatsnest().

Referenced by Build(), and CheckConnectivity().

◆ Remove()

bool CONNECTIVITY_DATA::Remove ( BOARD_ITEM aItem)

Function Remove() Removes an item from the connectivity data.

Parameters
aItemis an item to be updated.
Returns
True if operation succeeded.

Definition at line 76 of file connectivity_data.cpp.

77{
78 m_connAlgo->Remove( aItem );
79 return true;
80}

References m_connAlgo.

◆ RemoveExclusion()

void CONNECTIVITY_DATA::RemoveExclusion ( const KIID aBoardItemId1,
const KIID aBoardItemId2 
)

Definition at line 902 of file connectivity_data.cpp.

903{
904 m_exclusions.erase( std::pair<KIID, KIID>( aBoardItemId1, aBoardItemId2 ) );
905 m_exclusions.erase( std::pair<KIID, KIID>( aBoardItemId2, aBoardItemId1 ) );
906
907 for( RN_NET* rnNet : m_nets )
908 {
909 for( CN_EDGE& edge : rnNet->GetEdges() )
910 {
911 if( ( edge.GetSourceNode()->Parent()->m_Uuid == aBoardItemId1
912 && edge.GetTargetNode()->Parent()->m_Uuid == aBoardItemId2 )
913 || ( edge.GetSourceNode()->Parent()->m_Uuid == aBoardItemId2
914 && edge.GetTargetNode()->Parent()->m_Uuid == aBoardItemId1 ) )
915 {
916 edge.SetVisible( true );
917 }
918 }
919 }
920}

References m_exclusions, and m_nets.

◆ SetProgressReporter()

void CONNECTIVITY_DATA::SetProgressReporter ( PROGRESS_REPORTER aReporter)

Definition at line 874 of file connectivity_data.cpp.

875{
876 m_progressReporter = aReporter;
877 m_connAlgo->SetProgressReporter( m_progressReporter );
878}

References m_connAlgo, and m_progressReporter.

◆ TestTrackEndpointDangling()

bool CONNECTIVITY_DATA::TestTrackEndpointDangling ( PCB_TRACK aTrack,
VECTOR2I aPos = nullptr 
)

Definition at line 687 of file connectivity_data.cpp.

688{
689 std::list<CN_ITEM*> items = GetConnectivityAlgo()->ItemEntry( aTrack ).GetItems();
690
691 // Not in the connectivity system. This is a bug!
692 if( items.empty() )
693 {
694 wxFAIL_MSG( wxT( "track not in connectivity system" ) );
695 return false;
696 }
697
698 CN_ITEM* citem = items.front();
699
700 if( !citem->Valid() )
701 return false;
702
703 if( aTrack->Type() == PCB_TRACE_T || aTrack->Type() == PCB_ARC_T )
704 {
705 // Test if a segment is connected on each end.
706 //
707 // NB: be wary of short segments which can be connected to the *same* other item on
708 // each end. If that's their only connection then they're still dangling.
709
710 PCB_LAYER_ID layer = aTrack->GetLayer();
711 int accuracy = KiROUND( aTrack->GetWidth() / 2 );
712 int start_count = 0;
713 int end_count = 0;
714
715 for( CN_ITEM* connected : citem->ConnectedItems() )
716 {
717 BOARD_CONNECTED_ITEM* item = connected->Parent();
718 ZONE* zone = dynamic_cast<ZONE*>( item );
719 DRC_RTREE* rtree = nullptr;
720 bool hitStart = false;
721 bool hitEnd = false;
722
723 if( item->GetFlags() & IS_DELETED )
724 continue;
725
726 if( zone )
727 rtree = zone->GetBoard()->m_CopperZoneRTreeCache[ zone ].get();
728
729 if( rtree )
730 {
731 SHAPE_CIRCLE start( aTrack->GetStart(), accuracy );
732 SHAPE_CIRCLE end( aTrack->GetEnd(), accuracy );
733
734 hitStart = rtree->QueryColliding( start.BBox(), &start, layer );
735 hitEnd = rtree->QueryColliding( end.BBox(), &end, layer );
736 }
737 else
738 {
739 std::shared_ptr<SHAPE> shape = item->GetEffectiveShape( layer );
740
741 hitStart = shape->Collide( aTrack->GetStart(), accuracy );
742 hitEnd = shape->Collide( aTrack->GetEnd(), accuracy );
743 }
744
745 if( hitStart && hitEnd )
746 {
747 if( getMinDist( item, aTrack->GetStart() ) < getMinDist( item, aTrack->GetEnd() ) )
748 start_count++;
749 else
750 end_count++;
751 }
752 else if( hitStart )
753 {
754 start_count++;
755 }
756 else if( hitEnd )
757 {
758 end_count++;
759 }
760
761 if( start_count > 0 && end_count > 0 )
762 return false;
763 }
764
765 if( aPos )
766 *aPos = (start_count == 0 ) ? aTrack->GetStart() : aTrack->GetEnd();
767
768 return true;
769 }
770 else if( aTrack->Type() == PCB_VIA_T )
771 {
772 // Test if a via is only connected on one layer
773
774 const std::vector<CN_ITEM*>& connected = citem->ConnectedItems();
775
776 if( connected.empty() )
777 {
778 if( aPos )
779 *aPos = aTrack->GetPosition();
780
781 return true;
782 }
783
784 // Here, we check if the via is connected only to items on a single layer
785 int first_layer = UNDEFINED_LAYER;
786
787 for( CN_ITEM* item : connected )
788 {
789 if( item->Parent()->GetFlags() & IS_DELETED )
790 continue;
791
792 if( first_layer == UNDEFINED_LAYER )
793 first_layer = item->Layer();
794 else if( item->Layer() != first_layer )
795 return false;
796 }
797
798 if( aPos )
799 *aPos = aTrack->GetPosition();
800
801 return true;
802 }
803 else
804 {
805 wxFAIL_MSG( wxT( "CONNECTIVITY_DATA::TestTrackEndpointDangling: unknown track type" ) );
806 }
807
808 return false;
809}
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:170
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: board_item.cpp:197
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:37
std::unordered_map< ZONE *, std::unique_ptr< DRC_RTREE > > m_CopperZoneRTreeCache
Definition: board.h:1128
std::shared_ptr< CN_CONNECTIVITY_ALGO > GetConnectivityAlgo() const
Implement an R-tree for fast spatial and layer indexing of connectable items.
Definition: drc_rtree.h:48
int QueryColliding(BOARD_ITEM *aRefItem, PCB_LAYER_ID aRefLayer, PCB_LAYER_ID aTargetLayer, std::function< bool(BOARD_ITEM *)> aFilter=nullptr, std::function< bool(BOARD_ITEM *)> aVisitor=nullptr, int aClearance=0) const
This is a fast test which essentially does bounding-box overlap given a worst-case clearance.
Definition: drc_rtree.h:211
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:154
int GetWidth() const
Definition: pcb_track.h:103
const VECTOR2I & GetStart() const
Definition: pcb_track.h:109
VECTOR2I GetPosition() const override
Definition: pcb_track.h:99
const VECTOR2I & GetEnd() const
Definition: pcb_track.h:106
static int getMinDist(BOARD_CONNECTED_ITEM *aItem, const VECTOR2I &aPoint)
#define IS_DELETED
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ UNDEFINED_LAYER
Definition: layer_ids.h:60
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:80

References SHAPE_CIRCLE::BBox(), CN_ITEM::ConnectedItems(), BOARD_ITEM::GetBoard(), GetConnectivityAlgo(), BOARD_ITEM::GetEffectiveShape(), PCB_TRACK::GetEnd(), EDA_ITEM::GetFlags(), BOARD_ITEM::GetLayer(), getMinDist(), PCB_TRACK::GetPosition(), PCB_TRACK::GetStart(), PCB_TRACK::GetWidth(), IS_DELETED, KiROUND(), BOARD::m_CopperZoneRTreeCache, PCB_ARC_T, PCB_TRACE_T, PCB_VIA_T, DRC_RTREE::QueryColliding(), EDA_ITEM::Type(), UNDEFINED_LAYER, and CN_ITEM::Valid().

◆ Update()

bool CONNECTIVITY_DATA::Update ( BOARD_ITEM aItem)

Function Update() Updates the connectivity data for an item.

Parameters
aItemis an item to be updated.
Returns
True if operation succeeded.

Definition at line 83 of file connectivity_data.cpp.

84{
85 m_connAlgo->Remove( aItem );
86 m_connAlgo->Add( aItem );
87 return true;
88}

References m_connAlgo.

◆ updateRatsnest()

void CONNECTIVITY_DATA::updateRatsnest ( )
private

Definition at line 156 of file connectivity_data.cpp.

157{
158#ifdef PROFILE
159 PROF_COUNTER rnUpdate( "update-ratsnest" );
160#endif
161
162 std::vector<RN_NET*> dirty_nets;
163
164 // Start with net 1 as net 0 is reserved for not-connected
165 // Nets without nodes are also ignored
166 std::copy_if( m_nets.begin() + 1, m_nets.end(), std::back_inserter( dirty_nets ),
167 [] ( RN_NET* aNet )
168 {
169 return aNet->IsDirty() && aNet->GetNodeCount() > 0;
170 } );
171
172 GetKiCadThreadPool().parallelize_loop( 0, dirty_nets.size(),
173 [&]( const int a, const int b)
174 {
175 for( int ii = a; ii < b; ++ii )
176 dirty_nets[ii]->Update( m_exclusions );
177 }).wait();
178
179#ifdef PROFILE
180 rnUpdate.Show();
181#endif
182}
A thread-safe event counter.
Definition: profile.h:226
thread_pool & GetKiCadThreadPool()
Get a reference to the current thread pool.
Definition: thread_pool.cpp:32

References GetKiCadThreadPool(), m_nets, and PROF_COUNTER::Show().

Referenced by RecalculateRatsnest().

Member Data Documentation

◆ m_connAlgo

◆ m_dynamicRatsnest

std::vector<RN_DYNAMIC_LINE> CONNECTIVITY_DATA::m_dynamicRatsnest
private

◆ m_exclusions

std::set<std::pair<KIID, KIID> > CONNECTIVITY_DATA::m_exclusions
private

Ratsnest lines that have been excluded in DRC.

Definition at line 336 of file connectivity_data.h.

Referenced by AddExclusion(), and RemoveExclusion().

◆ m_fromToCache

std::shared_ptr<FROM_TO_CACHE> CONNECTIVITY_DATA::m_fromToCache
private

Definition at line 328 of file connectivity_data.h.

Referenced by CONNECTIVITY_DATA(), and GetFromToCache().

◆ m_lock

KISPINLOCK CONNECTIVITY_DATA::m_lock
private

Definition at line 338 of file connectivity_data.h.

Referenced by Build(), and GetLock().

◆ m_netclassMap

std::map<int, wxString> CONNECTIVITY_DATA::m_netclassMap
private

Map of netcode -> netclass the net is a member of; used for ratsnest painting.

Definition at line 341 of file connectivity_data.h.

Referenced by Build(), and GetNetclassMap().

◆ m_nets

◆ m_progressReporter

PROGRESS_REPORTER* CONNECTIVITY_DATA::m_progressReporter
private

Definition at line 343 of file connectivity_data.h.

Referenced by CONNECTIVITY_DATA(), and SetProgressReporter().

◆ m_skipRatsnest

bool CONNECTIVITY_DATA::m_skipRatsnest = false
private

Used to suppress ratsnest calculations on dynamic ratsnests.

Definition at line 333 of file connectivity_data.h.

Referenced by RecalculateRatsnest().


The documentation for this class was generated from the following files: