KiCad PCB EDA Suite
CN_ITEM Class Reference

#include <connectivity_items.h>

Inheritance diagram for CN_ITEM:
INTRUSIVE_LIST< CN_ITEM > CN_ZONE

Public Member Functions

void Dump ()
 
 CN_ITEM (BOARD_CONNECTED_ITEM *aParent, bool aCanChangeNet, int aAnchorCount=2)
 
virtual ~CN_ITEM ()
 
void AddAnchor (const VECTOR2I &aPos)
 
CN_ANCHORSAnchors ()
 
void SetValid (bool aValid)
 
bool Valid () const
 
void SetDirty (bool aDirty)
 
bool Dirty () const
 
void SetLayers (const LAYER_RANGE &aLayers)
 Function SetLayers() More...
 
void SetLayer (int aLayer)
 Function SetLayer() More...
 
const LAYER_RANGELayers () const
 Function Layers() More...
 
virtual int Layer () const
 Function Layer() More...
 
const BOX2IBBox ()
 
BOARD_CONNECTED_ITEMParent () const
 
const CONNECTED_ITEMSConnectedItems () const
 
void ClearConnections ()
 
void SetVisited (bool aVisited)
 
bool Visited () const
 
bool CanChangeNet () const
 
void Connect (CN_ITEM *b)
 
void RemoveInvalidRefs ()
 
virtual int AnchorCount () const
 
virtual const VECTOR2I GetAnchor (int n) const
 
int Net () const
 
void ListClear ()
 
CN_ITEMListRemove ()
 
int ListSize () const
 
void ListInsert (CN_ITEM *item)
 
CN_ITEMListNext () const
 
CN_ITEMListPrev () const
 

Protected Attributes

bool m_dirty
 

dirty flag, used to identify recently added item not yet scanned into the connectivity search

More...
 
LAYER_RANGE m_layers
 

layer range over which the item exists

More...
 
BOX2I m_bbox
 

bounding box for the item

More...
 

Private Types

using CONNECTED_ITEMS = std::set< CN_ITEM * >
 

Private Attributes

BOARD_CONNECTED_ITEMm_parent
 
CONNECTED_ITEMS m_connected
 

list of items physically connected (touching)

More...
 
CN_ANCHORS m_anchors
 
bool m_visited
 

visited flag for the BFS scan

More...
 
bool m_canChangeNet
 

can the net propagator modify the netcode?

More...
 
bool m_valid
 

valid flag, used to identify garbage items (we use lazy removal)

More...
 
std::mutex m_listLock
 

mutex protecting this item's connected_items set to allow parallel connection threads

More...
 

Detailed Description

Definition at line 153 of file connectivity_items.h.

Member Typedef Documentation

using CN_ITEM::CONNECTED_ITEMS = std::set<CN_ITEM*>
private

Definition at line 158 of file connectivity_items.h.

Constructor & Destructor Documentation

CN_ITEM::CN_ITEM ( BOARD_CONNECTED_ITEM aParent,
bool  aCanChangeNet,
int  aAnchorCount = 2 
)
inline

Definition at line 190 of file connectivity_items.h.

References PCB_LAYER_ID_COUNT.

Referenced by CN_LIST::Add().

191  {
192  m_parent = aParent;
193  m_canChangeNet = aCanChangeNet;
194  m_visited = false;
195  m_valid = true;
196  m_dirty = true;
197  m_anchors.reserve( 2 );
199  }
BOARD_CONNECTED_ITEM * m_parent
bool m_valid
valid flag, used to identify garbage items (we use lazy removal)
LAYER_RANGE m_layers
layer range over which the item exists
bool m_visited
visited flag for the BFS scan
bool m_dirty
dirty flag, used to identify recently added item not yet scanned into the connectivity search ...
bool m_canChangeNet
can the net propagator modify the netcode?
Class LAYER_RANGE.
Definition: pns_layerset.h:32
CN_ANCHORS m_anchors
virtual CN_ITEM::~CN_ITEM ( )
inlinevirtual

Definition at line 201 of file connectivity_items.h.

201 {};

Member Function Documentation

void CN_ITEM::AddAnchor ( const VECTOR2I aPos)
inline

Definition at line 203 of file connectivity_items.h.

Referenced by CN_LIST::Add().

204  {
205  m_anchors.emplace_back( std::make_unique<CN_ANCHOR>( aPos, this ) );
206  }
CN_ANCHORS m_anchors
int CN_ITEM::AnchorCount ( ) const
virtual

Reimplemented in CN_ZONE.

Definition at line 29 of file connectivity_items.cpp.

References m_parent, m_valid, PCB_TRACE_T, and EDA_ITEM::Type().

30 {
31  if( !m_valid )
32  return 0;
33 
34  return m_parent->Type() == PCB_TRACE_T ? 2 : 1;
35 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
BOARD_CONNECTED_ITEM * m_parent
bool m_valid
valid flag, used to identify garbage items (we use lazy removal)
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
CN_ANCHORS& CN_ITEM::Anchors ( )
inline

Definition at line 208 of file connectivity_items.h.

Referenced by RN_NET::AddCluster(), and CN_CONNECTIVITY_ALGO::ForEachAnchor().

209  {
210  return m_anchors;
211  }
CN_ANCHORS m_anchors
const BOX2I& CN_ITEM::BBox ( )
inline

Definition at line 273 of file connectivity_items.h.

References EDA_ITEM::GetBoundingBox(), EDA_RECT::GetPosition(), and EDA_RECT::GetSize().

Referenced by CN_LIST::FindNearby().

274  {
275  if( m_dirty && m_valid )
276  {
278  m_bbox = BOX2I( box.GetPosition(), box.GetSize() );
279  }
280  return m_bbox;
281  }
virtual const EDA_RECT GetBoundingBox() const
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
BOX2< VECTOR2I > BOX2I
Definition: box2.h:520
BOARD_CONNECTED_ITEM * m_parent
const wxSize GetSize() const
Definition: eda_rect.h:101
bool m_valid
valid flag, used to identify garbage items (we use lazy removal)
bool m_dirty
dirty flag, used to identify recently added item not yet scanned into the connectivity search ...
BOX2I m_bbox
bounding box for the item
const wxPoint GetPosition() const
Definition: eda_rect.h:113
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
bool CN_ITEM::CanChangeNet ( ) const
inline

Definition at line 308 of file connectivity_items.h.

Referenced by CN_VISITOR::checkZoneItemConnection().

309  {
310  return m_canChangeNet;
311  }
bool m_canChangeNet
can the net propagator modify the netcode?
void CN_ITEM::ClearConnections ( )
inline

Definition at line 293 of file connectivity_items.h.

294  {
295  m_connected.clear();
296  }
CONNECTED_ITEMS m_connected
list of items physically connected (touching)
void CN_ITEM::Connect ( CN_ITEM b)
inline

Definition at line 313 of file connectivity_items.h.

Referenced by CN_VISITOR::checkZoneItemConnection(), CN_VISITOR::checkZoneZoneConnection(), and CN_VISITOR::operator()().

314  {
315  std::lock_guard<std::mutex> lock( m_listLock );
316  m_connected.insert( b );
317  }
std::mutex m_listLock
mutex protecting this item&#39;s connected_items set to allow parallel connection threads ...
CONNECTED_ITEMS m_connected
list of items physically connected (touching)
const CONNECTED_ITEMS& CN_ITEM::ConnectedItems ( ) const
inline

Definition at line 288 of file connectivity_items.h.

Referenced by CN_CONNECTIVITY_ALGO::SearchClusters().

289  {
290  return m_connected;
291  }
CONNECTED_ITEMS m_connected
list of items physically connected (touching)
bool CN_ITEM::Dirty ( ) const
inline

Definition at line 228 of file connectivity_items.h.

Referenced by CN_VISITOR::operator()().

229  {
230  return m_dirty;
231  }
bool m_dirty
dirty flag, used to identify recently added item not yet scanned into the connectivity search ...
void CN_ITEM::Dump ( )

Definition at line 76 of file connectivity_items.cpp.

References i, m_connected, EDA_ITEM::Type(), and Valid().

Referenced by CN_CONNECTIVITY_ALGO::SearchClusters().

77 {
78  printf(" valid: %d, connected: \n", !!Valid());
79 
80  for( auto i : m_connected )
81  {
82  TRACK* t = static_cast<TRACK*>( i->Parent() );
83  printf( " - %p %d\n", t, t->Type() );
84  }
85 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
bool Valid() const
size_t i
Definition: json11.cpp:597
CONNECTED_ITEMS m_connected
list of items physically connected (touching)
const VECTOR2I CN_ITEM::GetAnchor ( int  n) const
virtual

Reimplemented in CN_ZONE.

Definition at line 38 of file connectivity_items.cpp.

References m_parent, m_valid, PCB_PAD_T, PCB_TRACE_T, PCB_VIA_T, and EDA_ITEM::Type().

Referenced by CN_VISITOR::checkZoneItemConnection(), and CN_VISITOR::operator()().

39 {
40  if( !m_valid )
41  return VECTOR2I();
42 
43  switch( m_parent->Type() )
44  {
45  case PCB_PAD_T:
46  return static_cast<const D_PAD*>( m_parent )->ShapePos();
47  break;
48 
49  case PCB_TRACE_T:
50  {
51  auto tr = static_cast<const TRACK*>( m_parent );
52  return ( n == 0 ? tr->GetStart() : tr->GetEnd() );
53 
54  break;
55  }
56 
57  case PCB_VIA_T:
58  return static_cast<const VIA*>( m_parent )->GetStart();
59 
60  default:
61  assert( false );
62  return VECTOR2I();
63  }
64 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
BOARD_CONNECTED_ITEM * m_parent
bool m_valid
valid flag, used to identify garbage items (we use lazy removal)
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
virtual int CN_ITEM::Layer ( ) const
inlinevirtual

Function Layer()

Returns the item's layer, for single-layered items only.

Definition at line 268 of file connectivity_items.h.

269  {
270  return Layers().Start();
271  }
int Start() const
Definition: pns_layerset.h:83
const LAYER_RANGE & Layers() const
Function Layers()
const LAYER_RANGE& CN_ITEM::Layers ( ) const
inline

Function Layers()

Returns the contiguous set of layers spanned by the item.

Definition at line 258 of file connectivity_items.h.

Referenced by CN_LIST::FindNearby().

259  {
260  return m_layers;
261  }
LAYER_RANGE m_layers
layer range over which the item exists
void INTRUSIVE_LIST< CN_ITEM >::ListClear ( )
inlineinherited

Definition at line 38 of file intrusive_list.h.

References INTRUSIVE_LIST< T >::m_count, INTRUSIVE_LIST< T >::m_next, INTRUSIVE_LIST< T >::m_prev, and INTRUSIVE_LIST< T >::m_root.

39  {
40  m_prev = nullptr;
41  m_next = nullptr;
42  m_root = (T*) this;
43  m_count = 1;
44  }
void INTRUSIVE_LIST< CN_ITEM >::ListInsert ( CN_ITEM item)
inlineinherited

Definition at line 74 of file intrusive_list.h.

References INTRUSIVE_LIST< T >::m_next, and INTRUSIVE_LIST< T >::m_root.

75  {
76  if( !m_root )
77  m_root = item;
78 
79  if( m_next )
80  m_next->m_prev = item;
81 
82  item->m_prev = (T*) this;
83  item->m_next = m_next;
84  item->m_root = m_root;
85  m_root->m_count++;
86 
87  m_next = item;
88  }
CN_ITEM * INTRUSIVE_LIST< CN_ITEM >::ListNext ( ) const
inlineinherited

Definition at line 90 of file intrusive_list.h.

References INTRUSIVE_LIST< T >::m_next.

90 { return m_next; };
CN_ITEM * INTRUSIVE_LIST< CN_ITEM >::ListPrev ( ) const
inlineinherited

Definition at line 91 of file intrusive_list.h.

91 { return m_prev; };
CN_ITEM * INTRUSIVE_LIST< CN_ITEM >::ListRemove ( )
inlineinherited

Definition at line 46 of file intrusive_list.h.

References INTRUSIVE_LIST< T >::m_next, INTRUSIVE_LIST< T >::m_prev, and INTRUSIVE_LIST< T >::m_root.

47  {
48  if( m_prev )
49  m_prev->m_next = m_next;
50 
51  if( m_next )
52  m_next->m_prev = m_prev;
53 
54  m_root->m_count--;
55 
56  T* rv = nullptr;
57 
58  if( m_prev )
59  rv = m_prev;
60  else if( m_next )
61  rv = m_next;
62 
63  m_root = nullptr;
64  m_prev = nullptr;
65  m_next = nullptr;
66  return rv;
67  }
int INTRUSIVE_LIST< CN_ITEM >::ListSize ( ) const
inlineinherited

Definition at line 69 of file intrusive_list.h.

References INTRUSIVE_LIST< T >::m_root.

70  {
71  return m_root ? m_root->m_count : 0;
72  }
int CN_ITEM::Net ( ) const

Definition at line 67 of file connectivity_items.cpp.

References BOARD_CONNECTED_ITEM::GetNetCode(), m_parent, and m_valid.

Referenced by CN_CLUSTER::Add(), CN_VISITOR::checkZoneItemConnection(), CN_VISITOR::checkZoneZoneConnection(), CONNECTIVITY_DATA::GetNetItems(), and CN_CONNECTIVITY_ALGO::SearchClusters().

68 {
69  if( !m_parent || !m_valid )
70  return -1;
71 
72  return m_parent->GetNetCode();
73 }
BOARD_CONNECTED_ITEM * m_parent
bool m_valid
valid flag, used to identify garbage items (we use lazy removal)
int GetNetCode() const
Function GetNetCode.
void CN_ITEM::RemoveInvalidRefs ( )

Definition at line 112 of file connectivity_items.cpp.

References m_connected.

113 {
114  for( auto it = m_connected.begin(); it != m_connected.end(); )
115  {
116  if( !(*it)->Valid() )
117  it = m_connected.erase( it );
118  else
119  ++it;
120  }
121 }
CONNECTED_ITEMS m_connected
list of items physically connected (touching)
void CN_ITEM::SetDirty ( bool  aDirty)
inline

Definition at line 223 of file connectivity_items.h.

Referenced by CN_LIST::Add().

224  {
225  m_dirty = aDirty;
226  }
bool m_dirty
dirty flag, used to identify recently added item not yet scanned into the connectivity search ...
void CN_ITEM::SetLayer ( int  aLayer)
inline

Function SetLayer()

Sets the layers spanned by the item to a single layer aLayer.

Definition at line 248 of file connectivity_items.h.

Referenced by CN_LIST::Add().

249  {
250  m_layers = LAYER_RANGE( aLayer, aLayer );
251  }
LAYER_RANGE m_layers
layer range over which the item exists
Class LAYER_RANGE.
Definition: pns_layerset.h:32
void CN_ITEM::SetLayers ( const LAYER_RANGE aLayers)
inline

Function SetLayers()

Sets the layers spanned by the item to aLayers.

Definition at line 238 of file connectivity_items.h.

239  {
240  m_layers = aLayers;
241  }
LAYER_RANGE m_layers
layer range over which the item exists
void CN_ITEM::SetValid ( bool  aValid)
inline

Definition at line 213 of file connectivity_items.h.

214  {
215  m_valid = aValid;
216  }
bool m_valid
valid flag, used to identify garbage items (we use lazy removal)
void CN_ITEM::SetVisited ( bool  aVisited)
inline

Definition at line 298 of file connectivity_items.h.

Referenced by CN_CONNECTIVITY_ALGO::SearchClusters().

299  {
300  m_visited = aVisited;
301  }
bool m_visited
visited flag for the BFS scan
bool CN_ITEM::Valid ( ) const
inline

Definition at line 218 of file connectivity_items.h.

Referenced by CN_ZONE::AnchorCount(), Dump(), CN_ZONE::GetAnchor(), CONNECTIVITY_DATA::GetNetItems(), and CN_VISITOR::operator()().

219  {
220  return m_valid;
221  }
bool m_valid
valid flag, used to identify garbage items (we use lazy removal)
bool CN_ITEM::Visited ( ) const
inline

Definition at line 303 of file connectivity_items.h.

304  {
305  return m_visited;
306  }
bool m_visited
visited flag for the BFS scan

Member Data Documentation

CN_ANCHORS CN_ITEM::m_anchors
private

Definition at line 163 of file connectivity_items.h.

BOX2I CN_ITEM::m_bbox
protected

bounding box for the item

Definition at line 185 of file connectivity_items.h.

bool CN_ITEM::m_canChangeNet
private

can the net propagator modify the netcode?

Definition at line 169 of file connectivity_items.h.

CONNECTED_ITEMS CN_ITEM::m_connected
private

list of items physically connected (touching)

Definition at line 161 of file connectivity_items.h.

Referenced by Dump(), and RemoveInvalidRefs().

bool CN_ITEM::m_dirty
protected

dirty flag, used to identify recently added item not yet scanned into the connectivity search

Definition at line 179 of file connectivity_items.h.

LAYER_RANGE CN_ITEM::m_layers
protected

layer range over which the item exists

Definition at line 182 of file connectivity_items.h.

std::mutex CN_ITEM::m_listLock
private

mutex protecting this item's connected_items set to allow parallel connection threads

Definition at line 175 of file connectivity_items.h.

BOARD_CONNECTED_ITEM* CN_ITEM::m_parent
private

Definition at line 156 of file connectivity_items.h.

Referenced by AnchorCount(), GetAnchor(), and Net().

bool CN_ITEM::m_valid
private

valid flag, used to identify garbage items (we use lazy removal)

Definition at line 172 of file connectivity_items.h.

Referenced by AnchorCount(), GetAnchor(), and Net().

bool CN_ITEM::m_visited
private

visited flag for the BFS scan

Definition at line 166 of file connectivity_items.h.


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