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

Member Typedef Documentation

◆ ITER

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

Definition at line 410 of file connectivity_items.h.

Constructor & Destructor Documentation

◆ CN_LIST()

CN_LIST::CN_LIST ( )
inline

Definition at line 395 of file connectivity_items.h.

References m_dirty, and m_hasInvalid.

396  {
397  m_dirty = false;
398  m_hasInvalid = false;
399  }

Member Function Documentation

◆ Add() [1/4]

CN_ITEM * CN_LIST::Add ( D_PAD pad)

Definition at line 124 of file connectivity_items.cpp.

References addItemtoTree(), B_Cu, F_Cu, D_PAD::GetAttribute(), D_PAD::GetLayerSet(), i, 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().

125  {
126  auto item = new CN_ITEM( pad, false, 1 );
127  item->AddAnchor( pad->ShapePos() );
128  item->SetLayers( LAYER_RANGE( F_Cu, B_Cu ) );
129 
130  switch( pad->GetAttribute() )
131  {
132  case PAD_ATTRIB_SMD:
134  case PAD_ATTRIB_CONN:
135  {
136  LSET lmsk = pad->GetLayerSet();
137 
138  for( int i = 0; i <= MAX_CU_LAYERS; i++ )
139  {
140  if( lmsk[i] )
141  {
142  item->SetLayer( i );
143  break;
144  }
145  }
146  break;
147  }
148  default:
149  break;
150  }
151 
152  addItemtoTree( item );
153  m_items.push_back( item );
154  SetDirty();
155  return item;
156  }
std::vector< CN_ITEM * > m_items
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:65
void addItemtoTree(CN_ITEM *item)
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:61
void SetDirty(bool aDirty=true)
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:412
Class LSET is a set of PCB_LAYER_IDs.
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:409
Like smd, does not appear on the solder paste layer (default) note also has a special attribute in Ge...
Definition: pad_shapes.h:62
size_t i
Definition: json11.cpp:597
wxPoint ShapePos() const
Definition: class_pad.cpp:550
Class LAYER_RANGE.
Definition: pns_layerset.h:32

◆ Add() [2/4]

CN_ITEM * CN_LIST::Add ( TRACK track)

Definition at line 158 of file connectivity_items.cpp.

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

159  {
160  auto item = new CN_ITEM( track, true );
161  m_items.push_back( item );
162  item->AddAnchor( track->GetStart() );
163  item->AddAnchor( track->GetEnd() );
164  item->SetLayer( track->GetLayer() );
165  addItemtoTree( item );
166  SetDirty();
167  return item;
168  }
std::vector< CN_ITEM * > m_items
const wxPoint & GetStart() const
Definition: class_track.h:126
void addItemtoTree(CN_ITEM *item)
void SetDirty(bool aDirty=true)
const wxPoint & GetEnd() const
Definition: class_track.h:123
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.

◆ Add() [3/4]

CN_ITEM * CN_LIST::Add ( VIA via)

Definition at line 170 of file connectivity_items.cpp.

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

171  {
172  auto item = new CN_ITEM( via, true, 1 );
173 
174  m_items.push_back( item );
175  item->AddAnchor( via->GetStart() );
176  item->SetLayers( LAYER_RANGE( F_Cu, B_Cu ) );
177  addItemtoTree( item );
178  SetDirty();
179  return item;
180  }
std::vector< CN_ITEM * > m_items
const wxPoint & GetStart() const
Definition: class_track.h:126
void addItemtoTree(CN_ITEM *item)
void SetDirty(bool aDirty=true)
Class LAYER_RANGE.
Definition: pns_layerset.h:32

◆ Add() [4/4]

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

Definition at line 182 of file connectivity_items.cpp.

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

183  {
184  const auto& polys = zone->GetFilledPolysList();
185 
186  std::vector<CN_ITEM*> rv;
187 
188  for( int j = 0; j < polys.OutlineCount(); j++ )
189  {
190  CN_ZONE* zitem = new CN_ZONE( zone, false, j );
191  const auto& outline = zone->GetFilledPolysList().COutline( j );
192 
193  for( int k = 0; k < outline.PointCount(); k++ )
194  zitem->AddAnchor( outline.CPoint( k ) );
195 
196  m_items.push_back( zitem );
197  zitem->SetLayer( zone->GetLayer() );
198  addItemtoTree( zitem );
199  rv.push_back( zitem );
200  SetDirty();
201  }
202 
203  return rv;
204  }
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:175
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:559

◆ addItemtoTree()

void CN_LIST::addItemtoTree ( CN_ITEM item)
inlineprotected

Definition at line 389 of file connectivity_items.h.

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

Referenced by Add().

390  {
391  m_index.Insert( item );
392  }
void Insert(T aItem)
Function Insert() Inserts an item into the tree.
CN_RTREE< CN_ITEM * > m_index

◆ begin()

ITER CN_LIST::begin ( )
inline

Definition at line 412 of file connectivity_items.h.

References m_items.

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

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

◆ Clear()

void CN_LIST::Clear ( )
inline

Definition at line 401 of file connectivity_items.h.

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

Referenced by CN_CONNECTIVITY_ALGO::Clear().

402  {
403  for( auto item : m_items )
404  delete item;
405 
406  m_items.clear();
407  m_index.RemoveAll();
408  }
std::vector< CN_ITEM * > m_items
void RemoveAll()
Function RemoveAll() Removes all items from the RTree.
CN_RTREE< CN_ITEM * > m_index

◆ ClearDirtyFlags()

void CN_LIST::ClearDirtyFlags ( )
inline

Definition at line 440 of file connectivity_items.h.

References m_items, and SetDirty().

Referenced by CN_CONNECTIVITY_ALGO::searchConnections().

441  {
442  for( auto item : m_items )
443  item->SetDirty( false );
444 
445  SetDirty( false );
446  }
std::vector< CN_ITEM * > m_items
void SetDirty(bool aDirty=true)

◆ end()

ITER CN_LIST::end ( )
inline

Definition at line 413 of file connectivity_items.h.

References m_items.

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

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

◆ FindNearby()

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

Definition at line 418 of file connectivity_items.h.

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

419  {
420  m_index.Query( aItem->BBox(), aItem->Layers(), aFunc );
421  }
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

◆ IsDirty()

bool CN_LIST::IsDirty ( ) const
inline

Definition at line 433 of file connectivity_items.h.

References m_dirty.

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

434  {
435  return m_dirty;
436  }

◆ MarkAllAsDirty()

void CN_LIST::MarkAllAsDirty ( )
inline

Definition at line 448 of file connectivity_items.h.

References m_items, and SetDirty().

449  {
450  for( auto item : m_items )
451  item->SetDirty( true );
452 
453  SetDirty( true );
454  }
std::vector< CN_ITEM * > m_items
void SetDirty(bool aDirty=true)

◆ operator[]()

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

Definition at line 415 of file connectivity_items.h.

References m_items.

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

◆ RemoveInvalidItems()

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

Definition at line 207 of file connectivity_items.cpp.

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

Referenced by CN_CONNECTIVITY_ALGO::searchConnections().

208 {
209  if( !m_hasInvalid )
210  return;
211 
212  auto lastItem = std::remove_if(m_items.begin(), m_items.end(), [&aGarbage] ( CN_ITEM* item )
213  {
214  if( !item->Valid() )
215  {
216  aGarbage.push_back ( item );
217  return true;
218  }
219 
220  return false;
221  } );
222 
223  m_items.resize( lastItem - m_items.begin() );
224 
225  for( auto item : m_items )
226  item->RemoveInvalidRefs();
227 
228  for( auto item : aGarbage )
229  m_index.Remove( item );
230 
231  m_hasInvalid = false;
232 }
std::vector< CN_ITEM * > m_items
void Remove(T aItem)
Function Remove() Removes an item from the tree.
CN_RTREE< CN_ITEM * > m_index

◆ SetDirty()

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

Definition at line 428 of file connectivity_items.h.

References m_dirty.

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

429  {
430  m_dirty = aDirty;
431  }

◆ SetHasInvalid()

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

Definition at line 423 of file connectivity_items.h.

References m_hasInvalid.

Referenced by CN_CONNECTIVITY_ALGO::Remove().

424  {
425  m_hasInvalid = aInvalid;
426  }

◆ Size()

int CN_LIST::Size ( ) const
inline

Definition at line 456 of file connectivity_items.h.

References m_items.

457  {
458  return m_items.size();
459  }
std::vector< CN_ITEM * > m_items

Member Data Documentation

◆ m_dirty

bool CN_LIST::m_dirty
private

Definition at line 381 of file connectivity_items.h.

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

◆ m_hasInvalid

bool CN_LIST::m_hasInvalid
private

Definition at line 382 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 384 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: