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 355 of file connectivity_items.h.

Member Typedef Documentation

◆ CONST_ITER

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

Definition at line 382 of file connectivity_items.h.

◆ ITER

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

Definition at line 381 of file connectivity_items.h.

Constructor & Destructor Documentation

◆ CN_LIST()

CN_LIST::CN_LIST ( )
inline

Definition at line 366 of file connectivity_items.h.

367  {
368  m_dirty = false;
369  m_hasInvalid = false;
370  }

References m_dirty, and m_hasInvalid.

Member Function Documentation

◆ Add() [1/5]

CN_ITEM * CN_LIST::Add ( PAD pad)

Definition at line 205 of file connectivity_items.cpp.

206  {
207  if( !pad->IsOnCopperLayer() )
208  return nullptr;
209 
210  auto item = new CN_ITEM( pad, false, 1 );
211  item->AddAnchor( pad->ShapePos() );
212  item->SetLayers( LAYER_RANGE( F_Cu, B_Cu ) );
213 
214  switch( pad->GetAttribute() )
215  {
216  case PAD_ATTRIB::SMD:
217  case PAD_ATTRIB::NPTH:
218  case PAD_ATTRIB::CONN:
219  {
220  LSET lmsk = pad->GetLayerSet();
221 
222  for( int i = 0; i <= MAX_CU_LAYERS; i++ )
223  {
224  if( lmsk[i] )
225  {
226  item->SetLayer( i );
227  break;
228  }
229  }
230  break;
231  }
232  default:
233  break;
234  }
235 
236  addItemtoTree( item );
237  m_items.push_back( item );
238  SetDirty();
239  return item;
240 }
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.
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 242 of file connectivity_items.cpp.

243 {
244  auto item = new CN_ITEM( track, true );
245  m_items.push_back( item );
246  item->AddAnchor( track->GetStart() );
247  item->AddAnchor( track->GetEnd() );
248  item->SetLayer( track->GetLayer() );
249  addItemtoTree( item );
250  SetDirty();
251  return item;
252 }
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)
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

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 254 of file connectivity_items.cpp.

255 {
256  auto item = new CN_ITEM( aArc, true );
257  m_items.push_back( item );
258  item->AddAnchor( aArc->GetStart() );
259  item->AddAnchor( aArc->GetEnd() );
260  item->SetLayer( aArc->GetLayer() );
261  addItemtoTree( item );
262  SetDirty();
263  return item;
264 }
std::vector< CN_ITEM * > m_items
void addItemtoTree(CN_ITEM *item)
void SetDirty(bool aDirty=true)

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 266 of file connectivity_items.cpp.

267  {
268  auto item = new CN_ITEM( via, !via->GetIsFree(), 1 );
269 
270  m_items.push_back( item );
271  item->AddAnchor( via->GetStart() );
272 
273  item->SetLayers( LAYER_RANGE( via->TopLayer(), via->BottomLayer() ) );
274  addItemtoTree( item );
275  SetDirty();
276  return item;
277  }
std::vector< CN_ITEM * > m_items
void addItemtoTree(CN_ITEM *item)
void SetDirty(bool aDirty=true)
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 279 of file connectivity_items.cpp.

280  {
281  const auto& polys = zone->GetFilledPolysList( aLayer );
282 
283  std::vector<CN_ITEM*> rv;
284 
285  for( int j = 0; j < polys.OutlineCount(); j++ )
286  {
287  CN_ZONE_LAYER* zitem = new CN_ZONE_LAYER( zone, aLayer, false, j );
288  const auto& outline = zone->GetFilledPolysList( aLayer ).COutline( j );
289 
290  for( int k = 0; k < outline.PointCount(); k++ )
291  zitem->AddAnchor( outline.CPoint( k ) );
292 
293  m_items.push_back( zitem );
294  zitem->SetLayer( aLayer );
295  addItemtoTree( zitem );
296  rv.push_back( zitem );
297  SetDirty();
298  }
299 
300  return rv;
301  }
std::vector< CN_ITEM * > m_items
void addItemtoTree(CN_ITEM *item)
const SHAPE_POLY_SET & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition: zone.h:632
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 360 of file connectivity_items.h.

361  {
362  m_index.Insert( item );
363  }
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 384 of file connectivity_items.h.

384 { 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 387 of file connectivity_items.h.

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

References m_items.

◆ Clear()

void CN_LIST::Clear ( )
inline

Definition at line 372 of file connectivity_items.h.

373  {
374  for( auto item : m_items )
375  delete item;
376 
377  m_items.clear();
378  m_index.RemoveAll();
379  }
std::vector< CN_ITEM * > m_items
void RemoveAll()
Function RemoveAll() Removes all items from the RTree.
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 412 of file connectivity_items.h.

413  {
414  for( auto item : m_items )
415  item->SetDirty( false );
416 
417  SetDirty( false );
418  }
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 385 of file connectivity_items.h.

385 { 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 392 of file connectivity_items.h.

393  {
394  return m_items.end();
395  }
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 400 of file connectivity_items.h.

401  {
402  m_index.Query( aItem->BBox(), aItem->Layers(), aFunc );
403  }
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 408 of file connectivity_items.h.

408 { 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 420 of file connectivity_items.h.

421  {
422  for( auto item : m_items )
423  item->SetDirty( true );
424 
425  SetDirty( true );
426  }
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 397 of file connectivity_items.h.

397 { 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 304 of file connectivity_items.cpp.

305 {
306  if( !m_hasInvalid )
307  return;
308 
309  auto lastItem = std::remove_if(m_items.begin(), m_items.end(), [&aGarbage] ( CN_ITEM* item )
310  {
311  if( !item->Valid() )
312  {
313  aGarbage.push_back ( item );
314  return true;
315  }
316 
317  return false;
318  } );
319 
320  m_items.resize( lastItem - m_items.begin() );
321 
322  for( auto item : m_items )
323  item->RemoveInvalidRefs();
324 
325  for( auto item : aGarbage )
326  m_index.Remove( item );
327 
328  m_hasInvalid = false;
329 }
std::vector< CN_ITEM * > m_items
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 407 of file connectivity_items.h.

407 { 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 405 of file connectivity_items.h.

405 { m_hasInvalid = aInvalid; }

References m_hasInvalid.

Referenced by CN_CONNECTIVITY_ALGO::Remove().

◆ Size()

int CN_LIST::Size ( ) const
inline

Definition at line 428 of file connectivity_items.h.

429  {
430  return m_items.size();
431  }
std::vector< CN_ITEM * > m_items

References m_items.

Member Data Documentation

◆ m_dirty

bool CN_LIST::m_dirty
private

Definition at line 444 of file connectivity_items.h.

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

◆ m_hasInvalid

bool CN_LIST::m_hasInvalid
private

Definition at line 445 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 447 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: