KiCad PCB EDA Suite
CN_LIST Class Reference

#include <connectivity_items.h>

Public Types

using ITER = decltype(m_items)::iterator
 

Public Member Functions

 CN_LIST ()
 
void Clear ()
 
ITER begin ()
 
ITER end ()
 
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 (D_PAD *pad)
 
CN_ITEMAdd (TRACK *track)
 
CN_ITEMAdd (ARC *track)
 
CN_ITEMAdd (VIA *via)
 
const std::vector< CN_ITEM * > Add (ZONE_CONTAINER *zone)
 

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

Member Typedef Documentation

◆ ITER

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

Definition at line 425 of file connectivity_items.h.

Constructor & Destructor Documentation

◆ CN_LIST()

CN_LIST::CN_LIST ( )
inline

Definition at line 410 of file connectivity_items.h.

411  {
412  m_dirty = false;
413  m_hasInvalid = false;
414  }

References m_dirty, and m_hasInvalid.

Member Function Documentation

◆ Add() [1/5]

CN_ITEM * CN_LIST::Add ( D_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:
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
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:66
void addItemtoTree(CN_ITEM *item)
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:62
void SetDirty(bool aDirty=true)
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:449
LSET is a set of PCB_LAYER_IDs.
bool IsOnCopperLayer() const override
Definition: class_pad.h:285
LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
Definition: class_pad.h:446
Like smd, does not appear on the solder paste layer (default) note also has a special attribute in Ge...
Definition: pad_shapes.h:63
wxPoint ShapePos() const
Definition: class_pad.cpp:570
LAYER_RANGE.
Definition: pns_layerset.h:32

References addItemtoTree(), B_Cu, F_Cu, D_PAD::GetAttribute(), D_PAD::GetLayerSet(), D_PAD::IsOnCopperLayer(), m_items, MAX_CU_LAYERS, PAD_ATTRIB_CONN, PAD_ATTRIB_HOLE_NOT_PLATED, PAD_ATTRIB_SMD, SetDirty(), and D_PAD::ShapePos().

Referenced by CN_CONNECTIVITY_ALGO::Add().

◆ Add() [2/5]

CN_ITEM * CN_LIST::Add ( 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 & GetStart() const
Definition: class_track.h:111
void addItemtoTree(CN_ITEM *item)
void SetDirty(bool aDirty=true)
const wxPoint & GetEnd() const
Definition: class_track.h:108
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.

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

◆ Add() [3/5]

CN_ITEM * CN_LIST::Add ( 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)

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

◆ Add() [4/5]

CN_ITEM * CN_LIST::Add ( VIA via)

Definition at line 265 of file connectivity_items.cpp.

266  {
267  auto item = new CN_ITEM( via, true, 1 );
268 
269  m_items.push_back( item );
270  item->AddAnchor( via->GetStart() );
271  item->SetLayers( LAYER_RANGE( F_Cu, B_Cu ) );
272  addItemtoTree( item );
273  SetDirty();
274  return item;
275  }
std::vector< CN_ITEM * > m_items
const wxPoint & GetStart() const
Definition: class_track.h:111
void addItemtoTree(CN_ITEM *item)
void SetDirty(bool aDirty=true)
LAYER_RANGE.
Definition: pns_layerset.h:32

References addItemtoTree(), B_Cu, F_Cu, TRACK::GetStart(), m_items, and SetDirty().

◆ Add() [5/5]

const std::vector< CN_ITEM * > CN_LIST::Add ( ZONE_CONTAINER zone)

Definition at line 277 of file connectivity_items.cpp.

278  {
279  const auto& polys = zone->GetFilledPolysList();
280 
281  std::vector<CN_ITEM*> rv;
282 
283  for( int j = 0; j < polys.OutlineCount(); j++ )
284  {
285  CN_ZONE* zitem = new CN_ZONE( zone, false, j );
286  const auto& outline = zone->GetFilledPolysList().COutline( j );
287 
288  for( int k = 0; k < outline.PointCount(); k++ )
289  zitem->AddAnchor( outline.CPoint( k ) );
290 
291  m_items.push_back( zitem );
292  zitem->SetLayer( zone->GetLayer() );
293  addItemtoTree( zitem );
294  rv.push_back( zitem );
295  SetDirty();
296  }
297 
298  return rv;
299  }
std::vector< CN_ITEM * > m_items
void addItemtoTree(CN_ITEM *item)
virtual PCB_LAYER_ID GetLayer() const override
Function GetLayer returns the primary layer this item is on.
Definition: class_zone.cpp:213
void SetDirty(bool aDirty=true)
void AddAnchor(const VECTOR2I &aPos)
void SetLayer(int aLayer)
Function SetLayer()
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
const SHAPE_POLY_SET & GetFilledPolysList() const
Function GetFilledPolysList returns a reference to the list of filled polygons.
Definition: class_zone.h:571

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

◆ addItemtoTree()

void CN_LIST::addItemtoTree ( CN_ITEM item)
inlineprotected

Definition at line 404 of file connectivity_items.h.

405  {
406  m_index.Insert( item );
407  }
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()

ITER CN_LIST::begin ( )
inline

Definition at line 427 of file connectivity_items.h.

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

References m_items.

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

◆ Clear()

void CN_LIST::Clear ( )
inline

Definition at line 416 of file connectivity_items.h.

417  {
418  for( auto item : m_items )
419  delete item;
420 
421  m_items.clear();
422  m_index.RemoveAll();
423  }
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 455 of file connectivity_items.h.

456  {
457  for( auto item : m_items )
458  item->SetDirty( false );
459 
460  SetDirty( false );
461  }
std::vector< CN_ITEM * > m_items
void SetDirty(bool aDirty=true)

References m_items, and SetDirty().

Referenced by CN_CONNECTIVITY_ALGO::searchConnections().

◆ end()

ITER CN_LIST::end ( )
inline

Definition at line 428 of file connectivity_items.h.

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

References m_items.

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

◆ FindNearby()

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

Definition at line 433 of file connectivity_items.h.

434  {
435  m_index.Query( aItem->BBox(), aItem->Layers(), aFunc );
436  }
void Query(const BOX2I &aBounds, const LAYER_RANGE &aRange, Visitor &aVisitor)
Function Query() Executes a function object aVisitor for each item whose bounding box intersects with...
const LAYER_RANGE & Layers() const
Function Layers()
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 448 of file connectivity_items.h.

449  {
450  return m_dirty;
451  }

References m_dirty.

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

◆ MarkAllAsDirty()

void CN_LIST::MarkAllAsDirty ( )
inline

Definition at line 463 of file connectivity_items.h.

464  {
465  for( auto item : m_items )
466  item->SetDirty( true );
467 
468  SetDirty( true );
469  }
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 430 of file connectivity_items.h.

430 { 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 302 of file connectivity_items.cpp.

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

444  {
445  m_dirty = aDirty;
446  }

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

439  {
440  m_hasInvalid = aInvalid;
441  }

References m_hasInvalid.

Referenced by CN_CONNECTIVITY_ALGO::Remove().

◆ Size()

int CN_LIST::Size ( ) const
inline

Definition at line 471 of file connectivity_items.h.

472  {
473  return m_items.size();
474  }
std::vector< CN_ITEM * > m_items

References m_items.

Member Data Documentation

◆ m_dirty

bool CN_LIST::m_dirty
private

Definition at line 396 of file connectivity_items.h.

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

◆ m_hasInvalid

bool CN_LIST::m_hasInvalid
private

Definition at line 397 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 399 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: