KiCad PCB EDA Suite
CN_LIST Class Reference

#include <connectivity_items.h>

Public Types

using ITER = decltype(m_items)::iterator
 
using CONST_ITER = decltype(m_items)::const_iterator
 

Public Member Functions

 CN_LIST ()
 
void Clear ()
 
ITER begin ()
 
ITER end ()
 
CONST_ITER begin () const
 
CONST_ITER end () const
 
CN_ITEMoperator[] (int aIndex)
 
template<class T >
void FindNearby (CN_ITEM *aItem, T aFunc)
 
void SetHasInvalid (bool aInvalid=true)
 
void SetDirty (bool aDirty=true)
 
bool IsDirty () const
 
void RemoveInvalidItems (std::vector< CN_ITEM * > &aGarbage)
 
void ClearDirtyFlags ()
 
void MarkAllAsDirty ()
 
int Size () const
 
CN_ITEMAdd (PAD *pad)
 
CN_ITEMAdd (PCB_TRACK *track)
 
CN_ITEMAdd (PCB_ARC *track)
 
CN_ITEMAdd (PCB_VIA *via)
 
const std::vector< CN_ITEM * > Add (ZONE *zone, PCB_LAYER_ID aLayer)
 

Protected Member Functions

void addItemtoTree (CN_ITEM *item)
 

Protected Attributes

std::vector< CN_ITEM * > m_items
 

Private Attributes

bool m_dirty
 
bool m_hasInvalid
 
CN_RTREE< CN_ITEM * > m_index
 

Detailed Description

Definition at line 346 of file connectivity_items.h.

Member Typedef Documentation

◆ CONST_ITER

using CN_LIST::CONST_ITER = decltype( m_items )::const_iterator

Definition at line 373 of file connectivity_items.h.

◆ ITER

using CN_LIST::ITER = decltype( m_items )::iterator

Definition at line 372 of file connectivity_items.h.

Constructor & Destructor Documentation

◆ CN_LIST()

CN_LIST::CN_LIST ( )
inline

Definition at line 357 of file connectivity_items.h.

358  {
359  m_dirty = false;
360  m_hasInvalid = false;
361  }

References m_dirty, and m_hasInvalid.

Member Function Documentation

◆ Add() [1/5]

CN_ITEM * CN_LIST::Add ( PAD pad)

Definition at line 204 of file connectivity_items.cpp.

205  {
206  if( !pad->IsOnCopperLayer() )
207  return nullptr;
208 
209  auto item = new CN_ITEM( pad, false, 1 );
210  item->AddAnchor( pad->ShapePos() );
211  item->SetLayers( LAYER_RANGE( F_Cu, B_Cu ) );
212 
213  switch( pad->GetAttribute() )
214  {
215  case PAD_ATTRIB::SMD:
216  case PAD_ATTRIB::NPTH:
217  case PAD_ATTRIB::CONN:
218  {
219  LSET lmsk = pad->GetLayerSet();
220 
221  for( int i = 0; i <= MAX_CU_LAYERS; i++ )
222  {
223  if( lmsk[i] )
224  {
225  item->SetLayer( i );
226  break;
227  }
228  }
229  break;
230  }
231  default:
232  break;
233  }
234 
235  addItemtoTree( item );
236  m_items.push_back( item );
237  SetDirty();
238  return item;
239 }
std::vector< CN_ITEM * > m_items
void addItemtoTree(CN_ITEM *item)
Like smd, does not appear on the solder paste layer (default)
Smd pad, appears on the solder paste layer (default)
void SetDirty(bool aDirty=true)
like PAD_PTH, but not plated
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:516
#define MAX_CU_LAYERS
Definition: layer_ids.h:147
CN_ITEM represents a BOARD_CONNETED_ITEM in the connectivity system (ie: a pad, track/arc/via,...
Definition: layer_ids.h:71
Represent a contiguous set of PCB layers.
Definition: pns_layerset.h:31

References addItemtoTree(), B_Cu, CONN, F_Cu, m_items, MAX_CU_LAYERS, NPTH, pad, SetDirty(), and SMD.

Referenced by CN_CONNECTIVITY_ALGO::Add().

◆ Add() [2/5]

CN_ITEM * CN_LIST::Add ( PCB_TRACK track)

Definition at line 241 of file connectivity_items.cpp.

242 {
243  auto item = new CN_ITEM( track, true );
244  m_items.push_back( item );
245  item->AddAnchor( track->GetStart() );
246  item->AddAnchor( track->GetEnd() );
247  item->SetLayer( track->GetLayer() );
248  addItemtoTree( item );
249  SetDirty();
250  return item;
251 }
std::vector< CN_ITEM * > m_items
const wxPoint & GetEnd() const
Definition: pcb_track.h:105
void addItemtoTree(CN_ITEM *item)
void SetDirty(bool aDirty=true)
CN_ITEM represents a BOARD_CONNETED_ITEM in the connectivity system (ie: a pad, track/arc/via,...
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:143
const wxPoint & GetStart() const
Definition: pcb_track.h:108

References addItemtoTree(), PCB_TRACK::GetEnd(), BOARD_ITEM::GetLayer(), PCB_TRACK::GetStart(), m_items, and SetDirty().

◆ Add() [3/5]

CN_ITEM * CN_LIST::Add ( PCB_ARC track)

Definition at line 253 of file connectivity_items.cpp.

254 {
255  auto item = new CN_ITEM( aArc, true );
256  m_items.push_back( item );
257  item->AddAnchor( aArc->GetStart() );
258  item->AddAnchor( aArc->GetEnd() );
259  item->SetLayer( aArc->GetLayer() );
260  addItemtoTree( item );
261  SetDirty();
262  return item;
263 }
std::vector< CN_ITEM * > m_items
void addItemtoTree(CN_ITEM *item)
void SetDirty(bool aDirty=true)
CN_ITEM represents a BOARD_CONNETED_ITEM in the connectivity system (ie: a pad, track/arc/via,...

References addItemtoTree(), PCB_TRACK::GetEnd(), BOARD_ITEM::GetLayer(), PCB_TRACK::GetStart(), m_items, and SetDirty().

◆ Add() [4/5]

CN_ITEM * CN_LIST::Add ( PCB_VIA via)

Definition at line 265 of file connectivity_items.cpp.

266  {
267  auto item = new CN_ITEM( via, !via->GetIsFree(), 1 );
268 
269  m_items.push_back( item );
270  item->AddAnchor( via->GetStart() );
271 
272  item->SetLayers( LAYER_RANGE( via->TopLayer(), via->BottomLayer() ) );
273  addItemtoTree( item );
274  SetDirty();
275  return item;
276  }
std::vector< CN_ITEM * > m_items
void addItemtoTree(CN_ITEM *item)
void SetDirty(bool aDirty=true)
CN_ITEM represents a BOARD_CONNETED_ITEM in the connectivity system (ie: a pad, track/arc/via,...
Represent a contiguous set of PCB layers.
Definition: pns_layerset.h:31

References addItemtoTree(), m_items, SetDirty(), and via.

◆ Add() [5/5]

const std::vector< CN_ITEM * > CN_LIST::Add ( ZONE zone,
PCB_LAYER_ID  aLayer 
)

Definition at line 278 of file connectivity_items.cpp.

279  {
280  const auto& polys = zone->GetFilledPolysList( aLayer );
281 
282  std::vector<CN_ITEM*> rv;
283 
284  for( int j = 0; j < polys.OutlineCount(); j++ )
285  {
286  CN_ZONE_LAYER* zitem = new CN_ZONE_LAYER( zone, aLayer, false, j );
287  const auto& outline = zone->GetFilledPolysList( aLayer ).COutline( j );
288 
289  for( int k = 0; k < outline.PointCount(); k++ )
290  zitem->AddAnchor( outline.CPoint( k ) );
291 
292  m_items.push_back( zitem );
293  zitem->SetLayer( aLayer );
294  addItemtoTree( zitem );
295  rv.push_back( zitem );
296  SetDirty();
297  }
298 
299  return rv;
300  }
std::vector< CN_ITEM * > m_items
void addItemtoTree(CN_ITEM *item)
const SHAPE_POLY_SET & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition: zone.h:637
void SetDirty(bool aDirty=true)
void AddAnchor(const VECTOR2I &aPos)
void SetLayer(int aLayer)
Set the layers spanned by the item to a single layer aLayer.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const

References CN_ITEM::AddAnchor(), addItemtoTree(), SHAPE_POLY_SET::COutline(), ZONE::GetFilledPolysList(), m_items, SetDirty(), and CN_ITEM::SetLayer().

◆ addItemtoTree()

void CN_LIST::addItemtoTree ( CN_ITEM item)
inlineprotected

Definition at line 351 of file connectivity_items.h.

352  {
353  m_index.Insert( item );
354  }
void Insert(T aItem)
Function Insert() Inserts an item into the tree.
CN_RTREE< CN_ITEM * > m_index

References CN_RTREE< T >::Insert(), and m_index.

Referenced by Add().

◆ begin() [1/2]

ITER CN_LIST::begin ( )
inline

Definition at line 375 of file connectivity_items.h.

375 { return m_items.begin(); };
std::vector< CN_ITEM * > m_items

References m_items.

Referenced by CN_CONNECTIVITY_ALGO::SearchClusters(), and CN_CONNECTIVITY_ALGO::searchConnections().

◆ begin() [2/2]

CONST_ITER CN_LIST::begin ( ) const
inline

Definition at line 378 of file connectivity_items.h.

379  {
380  return m_items.begin();
381  }
std::vector< CN_ITEM * > m_items

References m_items.

◆ Clear()

void CN_LIST::Clear ( )
inline

Definition at line 363 of file connectivity_items.h.

364  {
365  for( CN_ITEM* item : m_items )
366  delete item;
367 
368  m_items.clear();
369  m_index.RemoveAll();
370  }
std::vector< CN_ITEM * > m_items
void RemoveAll()
Function RemoveAll() Removes all items from the RTree.
CN_ITEM represents a BOARD_CONNETED_ITEM in the connectivity system (ie: a pad, track/arc/via,...
CN_RTREE< CN_ITEM * > m_index

References m_index, m_items, and CN_RTREE< T >::RemoveAll().

Referenced by CN_CONNECTIVITY_ALGO::Clear().

◆ ClearDirtyFlags()

void CN_LIST::ClearDirtyFlags ( )
inline

Definition at line 403 of file connectivity_items.h.

404  {
405  for( auto item : m_items )
406  item->SetDirty( false );
407 
408  SetDirty( false );
409  }
std::vector< CN_ITEM * > m_items
void SetDirty(bool aDirty=true)

References m_items, and SetDirty().

Referenced by CN_CONNECTIVITY_ALGO::searchConnections().

◆ end() [1/2]

ITER CN_LIST::end ( )
inline

Definition at line 376 of file connectivity_items.h.

376 { return m_items.end(); };
std::vector< CN_ITEM * > m_items

References m_items.

Referenced by CN_CONNECTIVITY_ALGO::SearchClusters(), and CN_CONNECTIVITY_ALGO::searchConnections().

◆ end() [2/2]

CONST_ITER CN_LIST::end ( ) const
inline

Definition at line 383 of file connectivity_items.h.

384  {
385  return m_items.end();
386  }
std::vector< CN_ITEM * > m_items

References m_items.

◆ FindNearby()

template<class T >
void CN_LIST::FindNearby ( CN_ITEM aItem,
aFunc 
)
inline

Definition at line 391 of file connectivity_items.h.

392  {
393  m_index.Query( aItem->BBox(), aItem->Layers(), aFunc );
394  }
void Query(const BOX2I &aBounds, const LAYER_RANGE &aRange, Visitor &aVisitor) const
Function Query() Executes a function object aVisitor for each item whose bounding box intersects with...
const LAYER_RANGE & Layers() const
Return the contiguous set of layers spanned by the item.
const BOX2I & BBox()
CN_RTREE< CN_ITEM * > m_index

References CN_ITEM::BBox(), CN_ITEM::Layers(), m_index, and CN_RTREE< T >::Query().

◆ IsDirty()

bool CN_LIST::IsDirty ( ) const
inline

Definition at line 399 of file connectivity_items.h.

399 { return m_dirty; }

References m_dirty.

Referenced by CN_CONNECTIVITY_ALGO::SearchClusters(), and CN_CONNECTIVITY_ALGO::searchConnections().

◆ MarkAllAsDirty()

void CN_LIST::MarkAllAsDirty ( )
inline

Definition at line 411 of file connectivity_items.h.

412  {
413  for( auto item : m_items )
414  item->SetDirty( true );
415 
416  SetDirty( true );
417  }
std::vector< CN_ITEM * > m_items
void SetDirty(bool aDirty=true)

References m_items, and SetDirty().

◆ operator[]()

CN_ITEM* CN_LIST::operator[] ( int  aIndex)
inline

Definition at line 388 of file connectivity_items.h.

388 { return m_items[aIndex]; }
std::vector< CN_ITEM * > m_items

References m_items.

◆ RemoveInvalidItems()

void CN_LIST::RemoveInvalidItems ( std::vector< CN_ITEM * > &  aGarbage)

Definition at line 303 of file connectivity_items.cpp.

304 {
305  if( !m_hasInvalid )
306  return;
307 
308  auto lastItem = std::remove_if(m_items.begin(), m_items.end(), [&aGarbage] ( CN_ITEM* item )
309  {
310  if( !item->Valid() )
311  {
312  aGarbage.push_back ( item );
313  return true;
314  }
315 
316  return false;
317  } );
318 
319  m_items.resize( lastItem - m_items.begin() );
320 
321  for( auto item : m_items )
322  item->RemoveInvalidRefs();
323 
324  for( auto item : aGarbage )
325  m_index.Remove( item );
326 
327  m_hasInvalid = false;
328 }
std::vector< CN_ITEM * > m_items
CN_ITEM represents a BOARD_CONNETED_ITEM in the connectivity system (ie: a pad, track/arc/via,...
void Remove(T aItem)
Function Remove() Removes an item from the tree.
CN_RTREE< CN_ITEM * > m_index

References m_hasInvalid, m_index, m_items, and CN_RTREE< T >::Remove().

Referenced by CN_CONNECTIVITY_ALGO::searchConnections().

◆ SetDirty()

void CN_LIST::SetDirty ( bool  aDirty = true)
inline

Definition at line 398 of file connectivity_items.h.

398 { m_dirty = aDirty; }

References m_dirty.

Referenced by Add(), ClearDirtyFlags(), MarkAllAsDirty(), and CN_CONNECTIVITY_ALGO::Remove().

◆ SetHasInvalid()

void CN_LIST::SetHasInvalid ( bool  aInvalid = true)
inline

Definition at line 396 of file connectivity_items.h.

396 { m_hasInvalid = aInvalid; }

References m_hasInvalid.

Referenced by CN_CONNECTIVITY_ALGO::Remove().

◆ Size()

int CN_LIST::Size ( ) const
inline

Definition at line 419 of file connectivity_items.h.

420  {
421  return m_items.size();
422  }
std::vector< CN_ITEM * > m_items

References m_items.

Member Data Documentation

◆ m_dirty

bool CN_LIST::m_dirty
private

Definition at line 435 of file connectivity_items.h.

Referenced by CN_LIST(), IsDirty(), and SetDirty().

◆ m_hasInvalid

bool CN_LIST::m_hasInvalid
private

Definition at line 436 of file connectivity_items.h.

Referenced by CN_LIST(), RemoveInvalidItems(), and SetHasInvalid().

◆ m_index

CN_RTREE<CN_ITEM*> CN_LIST::m_index
private

Definition at line 438 of file connectivity_items.h.

Referenced by addItemtoTree(), Clear(), FindNearby(), and RemoveInvalidItems().

◆ m_items

std::vector<CN_ITEM*> CN_LIST::m_items
protected

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