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

Member Typedef Documentation

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

Definition at line 409 of file connectivity_items.h.

Constructor & Destructor Documentation

CN_LIST::CN_LIST ( )
inline

Definition at line 394 of file connectivity_items.h.

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

Member Function Documentation

CN_ITEM * CN_LIST::Add ( D_PAD pad)

Definition at line 124 of file connectivity_items.cpp.

References B_Cu, CN_ITEM::CN_ITEM(), F_Cu, D_PAD::GetAttribute(), D_PAD::GetLayerSet(), i, MAX_CU_LAYERS, PAD_ATTRIB_CONN, PAD_ATTRIB_HOLE_NOT_PLATED, PAD_ATTRIB_SMD, CN_ITEM::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
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:405
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)
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:402
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:517
Class LAYER_RANGE.
Definition: pns_layerset.h:32
CN_ITEM * CN_LIST::Add ( TRACK track)

Definition at line 158 of file connectivity_items.cpp.

References CN_ITEM::CN_ITEM(), TRACK::GetEnd(), BOARD_ITEM::GetLayer(), TRACK::GetStart(), and CN_ITEM::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
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
void addItemtoTree(CN_ITEM *item)
void SetDirty(bool aDirty=true)
const wxPoint & GetEnd() const
Definition: class_track.h:119
const wxPoint & GetStart() const
Definition: class_track.h:122
CN_ITEM * CN_LIST::Add ( VIA via)

Definition at line 170 of file connectivity_items.cpp.

References B_Cu, CN_ITEM::CN_ITEM(), F_Cu, TRACK::GetStart(), and CN_ITEM::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
void addItemtoTree(CN_ITEM *item)
void SetDirty(bool aDirty=true)
const wxPoint & GetStart() const
Definition: class_track.h:122
Class LAYER_RANGE.
Definition: pns_layerset.h:32
const std::vector< CN_ITEM * > CN_LIST::Add ( ZONE_CONTAINER zone)

Definition at line 182 of file connectivity_items.cpp.

References CN_ITEM::AddAnchor(), SHAPE_POLY_SET::COutline(), ZONE_CONTAINER::GetFilledPolysList(), ZONE_CONTAINER::GetLayer(), CN_ITEM::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)
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:540
void AddAnchor(const VECTOR2I &aPos)
void SetLayer(int aLayer)
Function SetLayer()
void CN_LIST::addItemtoTree ( CN_ITEM item)
inlineprotected

Definition at line 388 of file connectivity_items.h.

References CN_RTREE< T >::Insert().

389  {
390  m_index.Insert( item );
391  }
void Insert(T aItem)
Function Insert() Inserts an item into the tree.
CN_RTREE< CN_ITEM * > m_index
ITER CN_LIST::begin ( )
inline

Definition at line 411 of file connectivity_items.h.

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

411 { return m_items.begin(); };
std::vector< CN_ITEM * > m_items
void CN_LIST::Clear ( )
inline

Definition at line 400 of file connectivity_items.h.

References CN_RTREE< T >::RemoveAll().

Referenced by CN_CONNECTIVITY_ALGO::Clear().

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

Definition at line 439 of file connectivity_items.h.

Referenced by CN_CONNECTIVITY_ALGO::searchConnections().

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

Definition at line 412 of file connectivity_items.h.

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

412 { return m_items.end(); };
std::vector< CN_ITEM * > m_items
template<class T >
void CN_LIST::FindNearby ( CN_ITEM aItem,
aFunc 
)
inline

Definition at line 417 of file connectivity_items.h.

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

418  {
419  m_index.Query( aItem->BBox(), aItem->Layers(), aFunc );
420  }
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
bool CN_LIST::IsDirty ( ) const
inline

Definition at line 432 of file connectivity_items.h.

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

433  {
434  return m_dirty;
435  }
void CN_LIST::MarkAllAsDirty ( )
inline

Definition at line 447 of file connectivity_items.h.

448  {
449  for( auto item : m_items )
450  item->SetDirty( true );
451 
452  SetDirty( true );
453  }
std::vector< CN_ITEM * > m_items
void SetDirty(bool aDirty=true)
CN_ITEM* CN_LIST::operator[] ( int  aIndex)
inline

Definition at line 414 of file connectivity_items.h.

414 { return m_items[aIndex]; }
std::vector< CN_ITEM * > m_items
void CN_LIST::RemoveInvalidItems ( std::vector< CN_ITEM * > &  aGarbage)

Definition at line 207 of file connectivity_items.cpp.

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
void CN_LIST::SetDirty ( bool  aDirty = true)
inline

Definition at line 427 of file connectivity_items.h.

Referenced by CN_CONNECTIVITY_ALGO::Remove().

428  {
429  m_dirty = aDirty;
430  }
void CN_LIST::SetHasInvalid ( bool  aInvalid = true)
inline

Definition at line 422 of file connectivity_items.h.

Referenced by CN_CONNECTIVITY_ALGO::Remove().

423  {
424  m_hasInvalid = aInvalid;
425  }
int CN_LIST::Size ( ) const
inline

Definition at line 455 of file connectivity_items.h.

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

Member Data Documentation

bool CN_LIST::m_dirty
private

Definition at line 380 of file connectivity_items.h.

bool CN_LIST::m_hasInvalid
private

Definition at line 381 of file connectivity_items.h.

CN_RTREE<CN_ITEM*> CN_LIST::m_index
private

Definition at line 383 of file connectivity_items.h.

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

Definition at line 386 of file connectivity_items.h.


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