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)
 
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, std::vector< KICAD_T > aTypes={}) 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, wxPoint *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)
 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 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
 
const std::vector< CN_EDGEGetRatsnestForItems (const std::vector< BOARD_ITEM * > aItems)
 
const std::vector< CN_EDGEGetRatsnestForComponent (FOOTPRINT *aComponent, bool aSkipInternalConnections=false)
 
std::shared_ptr< FROM_TO_CACHEGetFromToCache ()
 

Private Member Functions

void updateRatsnest ()
 
void updateItemPositions (const std::vector< BOARD_ITEM * > &aItems)
 Updates the item positions without modifying the dirtyNet flag. More...
 
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
 
PROGRESS_REPORTERm_progressReporter
 
bool m_skipRatsnest = false
 
KISPINLOCK m_lock
 
std::map< int, wxString > m_netclassMap
 Map of netcode -> netclass the net is a member of; used for ratsnest painting. More...
 

Detailed Description

Definition at line 95 of file connectivity_data.h.

Constructor & Destructor Documentation

◆ CONNECTIVITY_DATA() [1/2]

CONNECTIVITY_DATA::CONNECTIVITY_DATA ( )

Definition at line 41 of file connectivity_data.cpp.

42 {
43  m_connAlgo.reset( new CN_CONNECTIVITY_ALGO );
44  m_progressReporter = nullptr;
45  m_fromToCache.reset( new FROM_TO_CACHE );
46 }
std::shared_ptr< CN_CONNECTIVITY_ALGO > m_connAlgo
PROGRESS_REPORTER * m_progressReporter
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 58 of file connectivity_data.cpp.

59 {
60  Clear();
61 }
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 49 of file connectivity_data.cpp.

50  : m_skipRatsnest( aSkipRatsnest )
51 {
52  Build( aItems );
53  m_progressReporter = nullptr;
54  m_fromToCache.reset( new FROM_TO_CACHE );
55 }
PROGRESS_REPORTER * m_progressReporter
std::shared_ptr< FROM_TO_CACHE > m_fromToCache
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 64 of file connectivity_data.cpp.

65 {
66  m_connAlgo->Add( aItem );
67  return true;
68 }
std::shared_ptr< CN_CONNECTIVITY_ALGO > m_connAlgo

References m_connAlgo.

◆ addRatsnestCluster()

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

Definition at line 164 of file connectivity_data.cpp.

165 {
166  auto rnNet = m_nets[ aCluster->OriginNet() ];
167 
168  rnNet->AddCluster( aCluster );
169 }
std::vector< RN_NET * > m_nets

References m_nets.

Referenced by RecalculateRatsnest().

◆ BlockRatsnestItems()

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

Definition at line 224 of file connectivity_data.cpp.

225 {
226  std::vector<BOARD_CONNECTED_ITEM*> citems;
227 
228  for( auto item : aItems )
229  {
230  if( item->Type() == PCB_FOOTPRINT_T )
231  {
232  for( PAD* pad : static_cast<FOOTPRINT*>(item)->Pads() )
233  citems.push_back( pad );
234  }
235  else
236  {
237  if( auto citem = dynamic_cast<BOARD_CONNECTED_ITEM*>( item ) )
238  citems.push_back( citem );
239  }
240  }
241 
242  for( const auto& item : citems )
243  {
244  if ( m_connAlgo->ItemExists( item ) )
245  {
246  auto& entry = m_connAlgo->ItemEntry( item );
247 
248  for( const auto& cnItem : entry.GetItems() )
249  {
250  for( auto anchor : cnItem->Anchors() )
251  anchor->SetNoLine( true );
252  }
253  }
254  }
255 }
std::shared_ptr< CN_CONNECTIVITY_ALGO > m_connAlgo
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
Definition: pad.h:57

References anchor, 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 86 of file connectivity_data.cpp.

87 {
88  m_connAlgo.reset( new CN_CONNECTIVITY_ALGO );
89  m_connAlgo->Build( aBoard, aReporter );
90 
91  m_netclassMap.clear();
92 
93  for( NETINFO_ITEM* net : aBoard->GetNetInfo() )
94  if( net->GetNetClass()->GetName() != NETCLASS::Default )
95  m_netclassMap[ net->GetNetCode() ] = net->GetNetClass()->GetName();
96 
98 }
std::shared_ptr< CN_CONNECTIVITY_ALGO > m_connAlgo
void RecalculateRatsnest(BOARD_COMMIT *aCommit=nullptr)
Function RecalculateRatsnest() Updates the ratsnest for the board.
const NETINFO_LIST & GetNetInfo() const
Definition: board.h:684
static const char Default[]
the name of the default NETCLASS
Definition: netclass.h:49
std::map< int, wxString > m_netclassMap
Map of netcode -> netclass the net is a member of; used for ratsnest painting.
Handle the data for a net.
Definition: netinfo.h:64

References NETCLASS::Default, BOARD::GetNetInfo(), m_connAlgo, m_netclassMap, and RecalculateRatsnest().

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 101 of file connectivity_data.cpp.

102 {
103  m_connAlgo.reset( new CN_CONNECTIVITY_ALGO );
104  m_connAlgo->Build( aItems );
105 
107 }
std::shared_ptr< CN_CONNECTIVITY_ALGO > m_connAlgo
void RecalculateRatsnest(BOARD_COMMIT *aCommit=nullptr)
Function RecalculateRatsnest() Updates the ratsnest for the board.

References m_connAlgo, and RecalculateRatsnest().

◆ CheckConnectivity()

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

Definition at line 463 of file connectivity_data.cpp.

464 {
466 
467  for( auto net : m_nets )
468  {
469  if( net )
470  {
471  for( const auto& edge : net->GetEdges() )
472  {
474  ent.net = edge.GetSourceNode()->Parent()->GetNetCode();
475  ent.a = edge.GetSourceNode()->Parent();
476  ent.b = edge.GetTargetNode()->Parent();
477  ent.anchorA = edge.GetSourceNode()->Pos();
478  ent.anchorB = edge.GetTargetNode()->Pos();
479  aReport.push_back( ent );
480  }
481  }
482  }
483 
484  return aReport.empty();
485 }
void RecalculateRatsnest(BOARD_COMMIT *aCommit=nullptr)
Function RecalculateRatsnest() Updates the ratsnest for the board.
BOARD_CONNECTED_ITEM * b
VECTOR2I anchorB
VECTOR2I anchorA
std::vector< RN_NET * > m_nets
BOARD_CONNECTED_ITEM * a
int net

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 401 of file connectivity_data.cpp.

402 {
403  for( auto net : m_nets )
404  delete net;
405 
406  m_nets.clear();
407 }
std::vector< RN_NET * > m_nets

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 327 of file connectivity_data.cpp.

328 {
329  m_connAlgo->ForEachAnchor( []( CN_ANCHOR& anchor )
330  {
331  anchor.SetNoLine( false );
332  } );
334 }
std::shared_ptr< CN_CONNECTIVITY_ALGO > m_connAlgo
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 
)

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

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

Definition at line 278 of file connectivity_data.cpp.

280 {
281  if( !aDynamicData )
282  return;
283 
284  m_dynamicRatsnest.clear();
285 
286  // This gets connections between the stationary board and the
287  // moving selection
288  for( unsigned int nc = 1; nc < aDynamicData->m_nets.size(); nc++ )
289  {
290  auto dynNet = aDynamicData->m_nets[nc];
291 
292  if( dynNet->GetNodeCount() != 0 )
293  {
294  auto ourNet = m_nets[nc];
295  CN_ANCHOR_PTR nodeA, nodeB;
296 
297  if( ourNet->NearestBicoloredPair( *dynNet, nodeA, nodeB ) )
298  {
299  RN_DYNAMIC_LINE l;
300  l.a = nodeA->Pos();
301  l.b = nodeB->Pos();
302  l.netCode = nc;
303 
304  m_dynamicRatsnest.push_back( l );
305  }
306  }
307  }
308 
309  // This gets the ratsnest for internal connections in the moving set
310  const auto& edges = GetRatsnestForItems( aItems );
311 
312  for( const auto& edge : edges )
313  {
314  const auto& nodeA = edge.GetSourceNode();
315  const auto& nodeB = edge.GetTargetNode();
316  RN_DYNAMIC_LINE l;
317 
318  // Use the parents' positions
319  l.a = nodeA->Parent()->GetPosition();
320  l.b = nodeB->Parent()->GetPosition();
321  l.netCode = 0;
322  m_dynamicRatsnest.push_back( l );
323  }
324 }
std::vector< RN_DYNAMIC_LINE > m_dynamicRatsnest
std::vector< RN_NET * > m_nets
std::shared_ptr< CN_ANCHOR > CN_ANCHOR_PTR
const std::vector< CN_EDGE > GetRatsnestForItems(const std::vector< BOARD_ITEM * > aItems)

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

◆ FindIsolatedCopperIslands() [1/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 264 of file connectivity_data.cpp.

265 {
266  // TODO(JE) ZONES
267 #if 0
268  m_connAlgo->FindIsolatedCopperIslands( aZone, aIslands );
269 #endif
270 }
std::shared_ptr< CN_CONNECTIVITY_ALGO > m_connAlgo

References m_connAlgo.

◆ FindIsolatedCopperIslands() [2/2]

void CONNECTIVITY_DATA::FindIsolatedCopperIslands ( std::vector< CN_ZONE_ISOLATED_ISLAND_LIST > &  aZones)

Definition at line 272 of file connectivity_data.cpp.

273 {
274  m_connAlgo->FindIsolatedCopperIslands( aZones );
275 }
std::shared_ptr< CN_CONNECTIVITY_ALGO > m_connAlgo

References m_connAlgo.

◆ GetConnectedItems()

const std::vector< BOARD_CONNECTED_ITEM * > CONNECTIVITY_DATA::GetConnectedItems ( const BOARD_CONNECTED_ITEM aItem,
const 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 410 of file connectivity_data.cpp.

414 {
415  std::vector<BOARD_CONNECTED_ITEM*> rv;
416  const auto clusters = m_connAlgo->SearchClusters(
417  aIgnoreNetcodes ?
420  aIgnoreNetcodes ? -1 : aItem->GetNetCode() );
421 
422  for( auto cl : clusters )
423  {
424  if( cl->Contains( aItem ) )
425  {
426  for( const auto item : *cl )
427  {
428  if( item->Valid() )
429  rv.push_back( item->Parent() );
430  }
431  }
432  }
433 
434  return rv;
435 }
std::shared_ptr< CN_CONNECTIVITY_ALGO > m_connAlgo

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 716 of file connectivity_data.cpp.

721 {
722  auto& entry = m_connAlgo->ItemEntry( aItem );
723  std::vector<BOARD_CONNECTED_ITEM*> rv;
724  SEG::ecoord maxErrorSq = (SEG::ecoord) aMaxError * aMaxError;
725 
726  for( auto cnItem : entry.GetItems() )
727  {
728  for( auto connected : cnItem->ConnectedItems() )
729  {
730  for( auto anchor : connected->Anchors() )
731  {
732  if( ( anchor->Pos() - aAnchor ).SquaredEuclideanNorm() <= maxErrorSq )
733  {
734  for( int i = 0; aTypes[i] > 0; i++ )
735  {
736  if( connected->Valid() && connected->Parent()->Type() == aTypes[i] )
737  {
738  rv.push_back( connected->Parent() );
739  break;
740  }
741  }
742 
743  break;
744  }
745  }
746  }
747  }
748 
749  return rv;
750 }
std::shared_ptr< CN_CONNECTIVITY_ALGO > m_connAlgo
VECTOR2I::extended_type ecoord
Definition: seg.h:43

References anchor, and m_connAlgo.

◆ GetConnectedPads() [1/2]

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

Definition at line 527 of file connectivity_data.cpp.

529 {
530  std::set<PAD*> pads;
531  std::vector<PAD*> rv;
532 
533  GetConnectedPads( aItem, &pads );
534 
535  std::copy( pads.begin(), pads.end(), std::back_inserter( rv ) );
536  return rv;
537 }
const std::vector< PAD * > GetConnectedPads(const BOARD_CONNECTED_ITEM *aItem) const

◆ GetConnectedPads() [2/2]

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

Definition at line 513 of file connectivity_data.cpp.

515 {
516  for( CN_ITEM* citem : m_connAlgo->ItemEntry( aItem ).GetItems() )
517  {
518  for( CN_ITEM* connected : citem->ConnectedItems() )
519  {
520  if( connected->Valid() && connected->Parent()->Type() == PCB_PAD_T )
521  pads->insert( static_cast<PAD*> ( connected->Parent() ) );
522  }
523  }
524 }
const CONNECTED_ITEMS & ConnectedItems() const
std::shared_ptr< CN_CONNECTIVITY_ALGO > m_connAlgo
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 488 of file connectivity_data.cpp.

490 {
491  auto& entry = m_connAlgo->ItemEntry( aItem );
492 
493  std::set<PCB_TRACK*> tracks;
494  std::vector<PCB_TRACK*> rv;
495 
496  for( CN_ITEM* citem : entry.GetItems() )
497  {
498  for( CN_ITEM* connected : citem->ConnectedItems() )
499  {
500  if( connected->Valid() &&
501  ( connected->Parent()->Type() == PCB_TRACE_T ||
502  connected->Parent()->Type() == PCB_VIA_T ||
503  connected->Parent()->Type() == PCB_ARC_T ) )
504  tracks.insert( static_cast<PCB_TRACK*> ( connected->Parent() ) );
505  }
506  }
507 
508  std::copy( tracks.begin(), tracks.end(), std::back_inserter( rv ) );
509  return rv;
510 }
const CONNECTED_ITEMS & ConnectedItems() const
std::shared_ptr< CN_CONNECTIVITY_ALGO > m_connAlgo
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96

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 276 of file connectivity_data.h.

277  {
278  return m_connAlgo;
279  }
std::shared_ptr< CN_CONNECTIVITY_ALGO > m_connAlgo

References m_connAlgo.

Referenced by TestTrackEndpointDangling().

◆ GetDynamicRatsnest()

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

Definition at line 251 of file connectivity_data.h.

252  {
253  return m_dynamicRatsnest;
254  }
std::vector< RN_DYNAMIC_LINE > m_dynamicRatsnest

References m_dynamicRatsnest.

◆ GetFromToCache()

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

Definition at line 301 of file connectivity_data.h.

302  {
303  return m_fromToCache;
304  }
std::shared_ptr< FROM_TO_CACHE > m_fromToCache

References m_fromToCache.

◆ GetLock()

KISPINLOCK& CONNECTIVITY_DATA::GetLock ( )
inline

Definition at line 281 of file connectivity_data.h.

282  {
283  return m_lock;
284  }

References m_lock.

◆ GetNetclassMap()

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

Definition at line 289 of file connectivity_data.h.

290  {
291  return m_netclassMap;
292  }
std::map< int, wxString > m_netclassMap
Map of netcode -> netclass the net is a member of; used for ratsnest painting.

References m_netclassMap.

◆ GetNetCount()

int CONNECTIVITY_DATA::GetNetCount ( ) const

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

Definition at line 258 of file connectivity_data.cpp.

259 {
260  return m_connAlgo->NetCount();
261 }
std::shared_ptr< CN_CONNECTIVITY_ALGO > m_connAlgo

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 438 of file connectivity_data.cpp.

440 {
441  std::vector<BOARD_CONNECTED_ITEM*> items;
442  items.reserve( 32 );
443 
444  std::bitset<MAX_STRUCT_TYPE_ID> type_bits;
445 
446  for( unsigned int i = 0; aTypes[i] != EOT; ++i )
447  {
448  wxASSERT( aTypes[i] < MAX_STRUCT_TYPE_ID );
449  type_bits.set( aTypes[i] );
450  }
451 
452  m_connAlgo->ForEachItem( [&]( CN_ITEM& aItem ) {
453  if( aItem.Valid() && ( aItem.Net() == aNetCode ) && type_bits[aItem.Parent()->Type()] )
454  items.push_back( aItem.Parent() );
455  } );
456 
457  std::sort( items.begin(), items.end() );
458  items.erase( std::unique( items.begin(), items.end() ), items.end() );
459  return items;
460 }
std::shared_ptr< CN_CONNECTIVITY_ALGO > m_connAlgo
BOARD_CONNECTED_ITEM * Parent() const
int Net() const
allow parallel connection threads
search types array terminator (End Of Types)
Definition: typeinfo.h:81
bool Valid() const
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

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 540 of file connectivity_data.cpp.

541 {
542  int sum = 0;
543 
544  if( aNet < 0 ) // Node count for all nets
545  {
546  for( const RN_NET* net : m_nets )
547  sum += net->GetNodeCount();
548  }
549  else if( aNet < (int) m_nets.size() )
550  {
551  sum = m_nets[aNet]->GetNodeCount();
552  }
553 
554  return sum;
555 }
std::vector< RN_NET * > m_nets
Describe ratsnest for a single net.
Definition: ratsnest_data.h:61

References m_nets.

◆ GetPadCount()

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

Definition at line 558 of file connectivity_data.cpp.

559 {
560  int n = 0;
561 
562  for( CN_ITEM* pad : m_connAlgo->ItemList() )
563  {
564  if( !pad->Valid() || pad->Parent()->Type() != PCB_PAD_T)
565  continue;
566 
567  PAD* dpad = static_cast<PAD*>( pad->Parent() );
568 
569  if( aNet < 0 || aNet == dpad->GetNetCode() )
570  n++;
571  }
572 
573  return n;
574 }
std::shared_ptr< CN_CONNECTIVITY_ALGO > m_connAlgo
class PAD, a pad in a footprint
Definition: typeinfo.h:89
Definition: pad.h:57

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 834 of file connectivity_data.cpp.

835 {
836  std::set<int> nets;
837  std::set<const PAD*> pads;
838  std::vector<CN_EDGE> edges;
839 
840  for( auto pad : aComponent->Pads() )
841  {
842  nets.insert( pad->GetNetCode() );
843  pads.insert( pad );
844  }
845 
846  for( const auto& netcode : nets )
847  {
848  const auto& net = GetRatsnestForNet( netcode );
849 
850  for( const auto& edge : net->GetEdges() )
851  {
852  auto srcNode = edge.GetSourceNode();
853  auto dstNode = edge.GetTargetNode();
854 
855  const PAD* srcParent = static_cast<const PAD*>( srcNode->Parent() );
856  const PAD* dstParent = static_cast<const PAD*>( dstNode->Parent() );
857 
858  bool srcFound = ( pads.find(srcParent) != pads.end() );
859  bool dstFound = ( pads.find(dstParent) != pads.end() );
860 
861  if ( srcFound && dstFound && !aSkipInternalConnections )
862  {
863  edges.push_back( edge );
864  }
865  else if ( srcFound || dstFound )
866  {
867  edges.push_back( edge );
868  }
869  }
870  }
871 
872  return edges;
873 }
PADS & Pads()
Definition: footprint.h:168
RN_NET * GetRatsnestForNet(int aNet)
Function GetRatsnestForNet() Returns the ratsnest, expressed as a set of graph edges for a given net.
Definition: pad.h:57

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

◆ GetRatsnestForItems()

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

Definition at line 785 of file connectivity_data.cpp.

786 {
787  std::set<int> nets;
788  std::vector<CN_EDGE> edges;
789  std::set<BOARD_CONNECTED_ITEM*> item_set;
790 
791  for( auto item : aItems )
792  {
793  if( item->Type() == PCB_FOOTPRINT_T )
794  {
795  FOOTPRINT* footprint = static_cast<FOOTPRINT*>( item );
796 
797  for( PAD* pad : footprint->Pads() )
798  {
799  nets.insert( pad->GetNetCode() );
800  item_set.insert( pad );
801  }
802  }
803  else if( auto conn_item = dyn_cast<BOARD_CONNECTED_ITEM*>( item ) )
804  {
805  item_set.insert( conn_item );
806  nets.insert( conn_item->GetNetCode() );
807  }
808  }
809 
810  for( const auto& netcode : nets )
811  {
812  const auto& net = GetRatsnestForNet( netcode );
813 
814  for( const auto& edge : net->GetEdges() )
815  {
816  auto srcNode = edge.GetSourceNode();
817  auto dstNode = edge.GetTargetNode();
818 
819  auto srcParent = srcNode->Parent();
820  auto dstParent = dstNode->Parent();
821 
822  bool srcFound = ( item_set.find(srcParent) != item_set.end() );
823  bool dstFound = ( item_set.find(dstParent) != item_set.end() );
824 
825  if ( srcFound && dstFound )
826  edges.push_back( edge );
827  }
828  }
829 
830  return edges;
831 }
PADS & Pads()
Definition: footprint.h:168
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
RN_NET * GetRatsnestForNet(int aNet)
Function GetRatsnestForNet() Returns the ratsnest, expressed as a set of graph edges for a given net.
Definition: pad.h:57

References 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 753 of file connectivity_data.cpp.

754 {
755  if ( aNet < 0 || aNet >= (int) m_nets.size() )
756  {
757  return nullptr;
758  }
759 
760  return m_nets[ aNet ];
761 }
std::vector< RN_NET * > m_nets

References m_nets.

Referenced by GetRatsnestForComponent(), and GetRatsnestForItems().

◆ GetUnconnectedCount()

unsigned int CONNECTIVITY_DATA::GetUnconnectedCount ( ) const

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

Definition at line 380 of file connectivity_data.cpp.

381 {
382  unsigned int unconnected = 0;
383 
384  for( auto net : m_nets )
385  {
386  if( !net )
387  continue;
388 
389  const auto& edges = net->GetUnconnected();
390 
391  if( edges.empty() )
392  continue;
393 
394  unconnected += edges.size();
395  }
396 
397  return unconnected;
398 }
std::vector< RN_NET * > m_nets

References m_nets.

◆ GetUnconnectedEdges()

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

Definition at line 577 of file connectivity_data.cpp.

578 {
579  for( const RN_NET* rnNet : m_nets )
580  {
581  if( rnNet )
582  {
583  for( const CN_EDGE& edge : rnNet->GetEdges() )
584  aEdges.push_back( edge );
585  }
586  }
587 }
std::vector< RN_NET * > m_nets
Describe ratsnest for a single net.
Definition: ratsnest_data.h:61

References m_nets.

◆ HideDynamicRatsnest()

void CONNECTIVITY_DATA::HideDynamicRatsnest ( )

Hides the temporary dynamic ratsnest lines.

Definition at line 337 of file connectivity_data.cpp.

338 {
339  m_dynamicRatsnest.clear();
340 }
std::vector< RN_DYNAMIC_LINE > m_dynamicRatsnest

References m_dynamicRatsnest.

Referenced by ClearDynamicRatsnest().

◆ IsConnectedOnLayer()

bool CONNECTIVITY_DATA::IsConnectedOnLayer ( const BOARD_CONNECTED_ITEM aItem,
int  aLayer,
std::vector< KICAD_T aTypes = {} 
) const

Definition at line 349 of file connectivity_data.cpp.

351 {
352  CN_CONNECTIVITY_ALGO::ITEM_MAP_ENTRY &entry = m_connAlgo->ItemEntry( aItem );
353 
354  auto matchType = [&]( KICAD_T aItemType )
355  {
356  if( aTypes.empty() )
357  return true;
358 
359  return std::count( aTypes.begin(), aTypes.end(), aItemType ) > 0;
360  };
361 
362  for( CN_ITEM* citem : entry.GetItems() )
363  {
364  for( CN_ITEM* connected : citem->ConnectedItems() )
365  {
366  if( connected->Valid()
367  && connected->Layers().Overlaps( aLayer )
368  && connected->Net() == aItem->GetNetCode()
369  && matchType( connected->Parent()->Type() ) )
370  {
371  return true;
372  }
373  }
374  }
375 
376  return false;
377 }
const CONNECTED_ITEMS & ConnectedItems() const
std::shared_ptr< CN_CONNECTIVITY_ALGO > m_connAlgo
const std::list< CN_ITEM * > GetItems() const
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77

References CN_ITEM::ConnectedItems(), CN_CONNECTIVITY_ALGO::ITEM_MAP_ENTRY::GetItems(), BOARD_CONNECTED_ITEM::GetNetCode(), and m_connAlgo.

◆ MarkItemNetAsDirty()

void CONNECTIVITY_DATA::MarkItemNetAsDirty ( BOARD_ITEM aItem)

Definition at line 764 of file connectivity_data.cpp.

765 {
766  if ( aItem->Type() == PCB_FOOTPRINT_T)
767  {
768  for( PAD* pad : static_cast<FOOTPRINT*>( aItem )->Pads() )
769  m_connAlgo->MarkNetAsDirty( pad->GetNetCode() );
770  }
771  if (aItem->IsConnected() )
772  {
773  m_connAlgo->MarkNetAsDirty( static_cast<BOARD_CONNECTED_ITEM*>( aItem )->GetNetCode() );
774  }
775 }
std::shared_ptr< CN_CONNECTIVITY_ALGO > m_connAlgo
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
virtual bool IsConnected() const
Returns information if the object is derived from BOARD_CONNECTED_ITEM.
Definition: board_item.h:134
Definition: pad.h:57
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

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 110 of file connectivity_data.cpp.

111 {
112  m_connAlgo->ForEachAnchor( [&aDelta]( CN_ANCHOR& anchor )
113  {
114  anchor.Move( aDelta );
115  } );
116 }
std::shared_ptr< CN_CONNECTIVITY_ALGO > m_connAlgo

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 343 of file connectivity_data.cpp.

344 {
345  m_connAlgo->PropagateNets( aCommit, aMode );
346 }
std::shared_ptr< CN_CONNECTIVITY_ALGO > m_connAlgo

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 172 of file connectivity_data.cpp.

173 {
174  m_connAlgo->PropagateNets( aCommit );
175 
176  int lastNet = m_connAlgo->NetCount();
177 
178  if( lastNet >= (int) m_nets.size() )
179  {
180  unsigned int prevSize = m_nets.size();
181  m_nets.resize( lastNet + 1 );
182 
183  for( unsigned int i = prevSize; i < m_nets.size(); i++ )
184  m_nets[i] = new RN_NET;
185  }
186 
187  auto clusters = m_connAlgo->GetClusters();
188 
189  int dirtyNets = 0;
190 
191  for( int net = 0; net < lastNet; net++ )
192  {
193  if( m_connAlgo->IsNetDirty( net ) )
194  {
195  m_nets[net]->Clear();
196  dirtyNets++;
197  }
198  }
199 
200  for( const auto& c : clusters )
201  {
202  int net = c->OriginNet();
203 
204  // Don't add intentionally-kept zone islands to the ratsnest
205  if( c->IsOrphaned() && c->Size() == 1 )
206  {
207  if( dynamic_cast<CN_ZONE_LAYER*>( *c->begin() ) )
208  continue;
209  }
210 
211  if( m_connAlgo->IsNetDirty( net ) )
212  {
213  addRatsnestCluster( c );
214  }
215  }
216 
217  m_connAlgo->ClearDirtyFlags();
218 
219  if( !m_skipRatsnest )
220  updateRatsnest();
221 }
std::shared_ptr< CN_CONNECTIVITY_ALGO > m_connAlgo
std::vector< RN_NET * > m_nets
Describe ratsnest for a single net.
Definition: ratsnest_data.h:61
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 71 of file connectivity_data.cpp.

72 {
73  m_connAlgo->Remove( aItem );
74  return true;
75 }
std::shared_ptr< CN_CONNECTIVITY_ALGO > m_connAlgo

References m_connAlgo.

◆ SetProgressReporter()

void CONNECTIVITY_DATA::SetProgressReporter ( PROGRESS_REPORTER aReporter)

Definition at line 778 of file connectivity_data.cpp.

779 {
780  m_progressReporter = aReporter;
781  m_connAlgo->SetProgressReporter( m_progressReporter );
782 }
std::shared_ptr< CN_CONNECTIVITY_ALGO > m_connAlgo
PROGRESS_REPORTER * m_progressReporter

References m_connAlgo, and m_progressReporter.

◆ TestTrackEndpointDangling()

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

Definition at line 609 of file connectivity_data.cpp.

610 {
611  std::list<CN_ITEM*> items = GetConnectivityAlgo()->ItemEntry( aTrack ).GetItems();
612 
613  // Not in the connectivity system. This is a bug!
614  if( items.empty() )
615  {
616  wxFAIL_MSG( "track not in connectivity system" );
617  return false;
618  }
619 
620  CN_ITEM* citem = items.front();
621 
622  if( !citem->Valid() )
623  return false;
624 
625  if( aTrack->Type() == PCB_TRACE_T || aTrack->Type() == PCB_ARC_T )
626  {
627  // Test if a segment is connected on each end.
628  //
629  // NB: be wary of short segments which can be connected to the *same* other item on
630  // each end. If that's their only connection then they're still dangling.
631 
632  PCB_LAYER_ID layer = aTrack->GetLayer();
633  int accuracy = KiROUND( aTrack->GetWidth() / 2 );
634  int start_count = 0;
635  int end_count = 0;
636 
637  for( CN_ITEM* connected : citem->ConnectedItems() )
638  {
639  BOARD_CONNECTED_ITEM* item = connected->Parent();
640 
641  if( item->GetFlags() & IS_DELETED )
642  continue;
643 
644  std::shared_ptr<SHAPE> shape = item->GetEffectiveShape( layer );
645 
646  bool hitStart = shape->Collide( aTrack->GetStart(), accuracy );
647  bool hitEnd = shape->Collide( aTrack->GetEnd(), accuracy );
648 
649  if( hitStart && hitEnd )
650  {
651  if( getMinDist( item, aTrack->GetStart() ) < getMinDist( item, aTrack->GetEnd() ) )
652  start_count++;
653  else
654  end_count++;
655  }
656  else if( hitStart )
657  {
658  start_count++;
659  }
660  else if( hitEnd )
661  {
662  end_count++;
663  }
664 
665  if( start_count > 0 && end_count > 0 )
666  return false;
667  }
668 
669  if( aPos )
670  *aPos = (start_count == 0 ) ? aTrack->GetStart() : aTrack->GetEnd();
671 
672  return true;
673  }
674  else if( aTrack->Type() == PCB_VIA_T )
675  {
676  // Test if a via is only connected on one layer
677 
678  const std::vector<CN_ITEM*>& connected = citem->ConnectedItems();
679 
680  if( connected.empty() )
681  {
682  if( aPos )
683  *aPos = aTrack->GetPosition();
684 
685  return true;
686  }
687 
688  // Here, we check if the via is connected only to items on a single layer
689  int first_layer = UNDEFINED_LAYER;
690 
691  for( CN_ITEM* item : connected )
692  {
693  if( item->Parent()->GetFlags() & IS_DELETED )
694  continue;
695 
696  if( first_layer == UNDEFINED_LAYER )
697  first_layer = item->Layer();
698  else if( item->Layer() != first_layer )
699  return false;
700  }
701 
702  if( aPos )
703  *aPos = aTrack->GetPosition();
704 
705  return true;
706  }
707  else
708  {
709  wxFAIL_MSG( "CONNECTIVITY_DATA::TestTrackEndpointDangling: unknown track type" );
710  }
711 
712  return false;
713 }
const CONNECTED_ITEMS & ConnectedItems() const
wxPoint GetPosition() const override
Definition: pcb_track.h:98
const wxPoint & GetEnd() const
Definition: pcb_track.h:105
std::shared_ptr< CN_CONNECTIVITY_ALGO > GetConnectivityAlgo() const
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
int GetWidth() const
Definition: pcb_track.h:102
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
#define IS_DELETED
static int getMinDist(BOARD_CONNECTED_ITEM *aItem, const wxPoint &aPoint)
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:155
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:64
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:73
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER) const
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: board_item.cpp:181
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:171
const wxPoint & GetStart() const
Definition: pcb_track.h:108
bool Valid() const
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

References CN_ITEM::ConnectedItems(), 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(), PCB_ARC_T, PCB_TRACE_T, PCB_VIA_T, 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 78 of file connectivity_data.cpp.

79 {
80  m_connAlgo->Remove( aItem );
81  m_connAlgo->Add( aItem );
82  return true;
83 }
std::shared_ptr< CN_CONNECTIVITY_ALGO > m_connAlgo

References m_connAlgo.

Referenced by updateRatsnest().

◆ updateItemPositions()

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

Updates the item positions without modifying the dirtyNet flag.

This is valid only when the item list contains all elements in the connectivity database

Parameters
aItemsList of items with new positions

◆ updateRatsnest()

void CONNECTIVITY_DATA::updateRatsnest ( )
private

Definition at line 119 of file connectivity_data.cpp.

120 {
121  #ifdef PROFILE
122  PROF_COUNTER rnUpdate( "update-ratsnest" );
123  #endif
124  std::vector<RN_NET*> dirty_nets;
125 
126  // Start with net 1 as net 0 is reserved for not-connected
127  // Nets without nodes are also ignored
128  std::copy_if( m_nets.begin() + 1, m_nets.end(), std::back_inserter( dirty_nets ),
129  [] ( RN_NET* aNet ) { return aNet->IsDirty() && aNet->GetNodeCount() > 0; } );
130 
131  // We don't want to spin up a new thread for fewer than 8 nets (overhead costs)
132  size_t parallelThreadCount = std::min<size_t>( std::thread::hardware_concurrency(),
133  ( dirty_nets.size() + 7 ) / 8 );
134 
135  std::atomic<size_t> nextNet( 0 );
136  std::vector<std::future<size_t>> returns( parallelThreadCount );
137 
138  auto update_lambda = [&nextNet, &dirty_nets]() -> size_t
139  {
140  for( size_t i = nextNet++; i < dirty_nets.size(); i = nextNet++ )
141  dirty_nets[i]->Update();
142 
143  return 1;
144  };
145 
146  if( parallelThreadCount == 1 )
147  update_lambda();
148  else
149  {
150  for( size_t ii = 0; ii < parallelThreadCount; ++ii )
151  returns[ii] = std::async( std::launch::async, update_lambda );
152 
153  // Finalize the ratsnest threads
154  for( size_t ii = 0; ii < parallelThreadCount; ++ii )
155  returns[ii].wait();
156  }
157 
158  #ifdef PROFILE
159  rnUpdate.Show();
160  #endif /* PROFILE */
161 }
bool Update(BOARD_ITEM *aItem)
Function Update() Updates the connectivity data for an item.
A small class to help profiling.
Definition: profile.h:45
std::vector< RN_NET * > m_nets
Describe ratsnest for a single net.
Definition: ratsnest_data.h:61

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

Referenced by RecalculateRatsnest().

Member Data Documentation

◆ m_connAlgo

◆ m_dynamicRatsnest

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

◆ m_fromToCache

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

Definition at line 319 of file connectivity_data.h.

Referenced by CONNECTIVITY_DATA(), and GetFromToCache().

◆ m_lock

KISPINLOCK CONNECTIVITY_DATA::m_lock
private

Definition at line 327 of file connectivity_data.h.

Referenced by 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 330 of file connectivity_data.h.

Referenced by Build(), and GetNetclassMap().

◆ m_nets

◆ m_progressReporter

PROGRESS_REPORTER* CONNECTIVITY_DATA::m_progressReporter
private

Definition at line 323 of file connectivity_data.h.

Referenced by CONNECTIVITY_DATA(), and SetProgressReporter().

◆ m_skipRatsnest

bool CONNECTIVITY_DATA::m_skipRatsnest = false
private

Definition at line 325 of file connectivity_data.h.

Referenced by RecalculateRatsnest().


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