KiCad PCB EDA Suite
CN_ITEM Class Reference

#include <connectivity_items.h>

Inheritance diagram for CN_ITEM:
INTRUSIVE_LIST< CN_ITEM > CN_ZONE

Public Types

using CONNECTED_ITEMS = std::set< CN_ITEM * >
 

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

Member Typedef Documentation

◆ CONNECTED_ITEMS

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

Definition at line 162 of file connectivity_items.h.

Constructor & Destructor Documentation

◆ CN_ITEM()

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

Definition at line 197 of file connectivity_items.h.

198  {
199  m_parent = aParent;
200  m_canChangeNet = aCanChangeNet;
201  m_visited = false;
202  m_valid = true;
203  m_dirty = true;
204  m_anchors.reserve( 2 );
206  }
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

References m_anchors, m_canChangeNet, m_dirty, m_layers, m_parent, m_valid, m_visited, and PCB_LAYER_ID_COUNT.

◆ ~CN_ITEM()

virtual CN_ITEM::~CN_ITEM ( )
inlinevirtual

Definition at line 208 of file connectivity_items.h.

208 {};

Member Function Documentation

◆ AddAnchor()

void CN_ITEM::AddAnchor ( const VECTOR2I aPos)
inline

Definition at line 210 of file connectivity_items.h.

211  {
212  m_anchors.emplace_back( std::make_unique<CN_ANCHOR>( aPos, this ) );
213  }
CN_ANCHORS m_anchors

References m_anchors.

Referenced by CN_LIST::Add().

◆ AnchorCount()

int CN_ITEM::AnchorCount ( ) const
virtual

Reimplemented in CN_ZONE.

Definition at line 29 of file connectivity_items.cpp.

30 {
31  if( !m_valid )
32  return 0;
33 
34  return m_parent->Type() == PCB_TRACE_T ? 2 : 1;
35 }
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
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210

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

Referenced by CN_ANCHOR::IsDangling().

◆ Anchors()

CN_ANCHORS& CN_ITEM::Anchors ( )
inline

Definition at line 215 of file connectivity_items.h.

216  {
217  return m_anchors;
218  }
CN_ANCHORS m_anchors

References m_anchors.

Referenced by CN_CONNECTIVITY_ALGO::ForEachAnchor().

◆ BBox()

const BOX2I& CN_ITEM::BBox ( )
inline

Definition at line 280 of file connectivity_items.h.

281  {
282  if( m_dirty && m_valid )
283  {
285  m_bbox = BOX2I( box.GetPosition(), box.GetSize() );
286  }
287  return m_bbox;
288  }
BOX2< VECTOR2I > BOX2I
Definition: box2.h:520
BOARD_CONNECTED_ITEM * m_parent
bool m_valid
valid flag, used to identify garbage items (we use lazy removal)
const wxPoint GetPosition() const
Definition: eda_rect.h:113
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
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
virtual const EDA_RECT GetBoundingBox() const
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
const wxSize GetSize() const
Definition: eda_rect.h:101

References EDA_ITEM::GetBoundingBox(), EDA_RECT::GetPosition(), EDA_RECT::GetSize(), m_bbox, m_dirty, m_parent, and m_valid.

Referenced by CN_LIST::FindNearby().

◆ CanChangeNet()

bool CN_ITEM::CanChangeNet ( ) const
inline

Definition at line 315 of file connectivity_items.h.

316  {
317  return m_canChangeNet;
318  }
bool m_canChangeNet
can the net propagator modify the netcode?

References m_canChangeNet.

Referenced by CN_VISITOR::checkZoneItemConnection().

◆ ClearConnections()

void CN_ITEM::ClearConnections ( )
inline

Definition at line 300 of file connectivity_items.h.

301  {
302  m_connected.clear();
303  }
CONNECTED_ITEMS m_connected
list of items physically connected (touching)

References m_connected.

◆ Connect()

void CN_ITEM::Connect ( CN_ITEM b)
inline

Definition at line 320 of file connectivity_items.h.

321  {
322  std::lock_guard<std::mutex> lock( m_listLock );
323  m_connected.insert( b );
324  }
std::mutex m_listLock
mutex protecting this item's connected_items set to allow parallel connection threads
CONNECTED_ITEMS m_connected
list of items physically connected (touching)

References m_connected, and m_listLock.

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

◆ ConnectedItems()

const CONNECTED_ITEMS& CN_ITEM::ConnectedItems ( ) const
inline

Definition at line 295 of file connectivity_items.h.

296  {
297  return m_connected;
298  }
CONNECTED_ITEMS m_connected
list of items physically connected (touching)

References m_connected.

Referenced by CN_ANCHOR::ConnectedItemsCount(), CN_ANCHOR::IsDangling(), and CN_CONNECTIVITY_ALGO::SearchClusters().

◆ Dirty()

bool CN_ITEM::Dirty ( ) const
inline

Definition at line 235 of file connectivity_items.h.

236  {
237  return m_dirty;
238  }
bool m_dirty
dirty flag, used to identify recently added item not yet scanned into the connectivity search

References m_dirty.

Referenced by CN_VISITOR::operator()().

◆ Dump()

void CN_ITEM::Dump ( )

Definition at line 76 of file connectivity_items.cpp.

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 }
size_t i
Definition: json11.cpp:597
CONNECTED_ITEMS m_connected
list of items physically connected (touching)
bool Valid() const
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210

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

Referenced by CN_CONNECTIVITY_ALGO::SearchClusters().

◆ GetAnchor()

const VECTOR2I CN_ITEM::GetAnchor ( int  n) const
virtual

Reimplemented in CN_ZONE.

Definition at line 38 of file connectivity_items.cpp.

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 }
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
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210

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()().

◆ Layer()

virtual int CN_ITEM::Layer ( ) const
inlinevirtual

Function Layer()

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

Definition at line 275 of file connectivity_items.h.

276  {
277  return Layers().Start();
278  }
int Start() const
Definition: pns_layerset.h:83
const LAYER_RANGE & Layers() const
Function Layers()

References Layers(), and LAYER_RANGE::Start().

◆ Layers()

const LAYER_RANGE& CN_ITEM::Layers ( ) const
inline

Function Layers()

Returns the contiguous set of layers spanned by the item.

Definition at line 265 of file connectivity_items.h.

266  {
267  return m_layers;
268  }
LAYER_RANGE m_layers
layer range over which the item exists

References m_layers.

Referenced by CN_LIST::FindNearby(), and Layer().

◆ ListClear()

void INTRUSIVE_LIST< CN_ITEM >::ListClear ( )
inlineinherited

Definition at line 38 of file intrusive_list.h.

39  {
40  m_prev = nullptr;
41  m_next = nullptr;
42  m_root = (T*) this;
43  m_count = 1;
44  }

◆ ListInsert()

void INTRUSIVE_LIST< CN_ITEM >::ListInsert ( CN_ITEM item)
inlineinherited

Definition at line 74 of file intrusive_list.h.

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  }

◆ ListNext()

CN_ITEM * INTRUSIVE_LIST< CN_ITEM >::ListNext ( ) const
inlineinherited

Definition at line 90 of file intrusive_list.h.

90 { return m_next; };

◆ ListPrev()

CN_ITEM * INTRUSIVE_LIST< CN_ITEM >::ListPrev ( ) const
inlineinherited

Definition at line 91 of file intrusive_list.h.

91 { return m_prev; };

◆ ListRemove()

CN_ITEM * INTRUSIVE_LIST< CN_ITEM >::ListRemove ( )
inlineinherited

Definition at line 46 of file intrusive_list.h.

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  }

◆ ListSize()

int INTRUSIVE_LIST< CN_ITEM >::ListSize ( ) const
inlineinherited

Definition at line 69 of file intrusive_list.h.

70  {
71  return m_root ? m_root->m_count : 0;
72  }

◆ Net()

int CN_ITEM::Net ( ) const

Definition at line 67 of file connectivity_items.cpp.

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

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().

◆ Parent()

◆ RemoveInvalidRefs()

void CN_ITEM::RemoveInvalidRefs ( )

Definition at line 112 of file connectivity_items.cpp.

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)

References m_connected.

◆ SetDirty()

void CN_ITEM::SetDirty ( bool  aDirty)
inline

Definition at line 230 of file connectivity_items.h.

231  {
232  m_dirty = aDirty;
233  }
bool m_dirty
dirty flag, used to identify recently added item not yet scanned into the connectivity search

References m_dirty.

◆ SetLayer()

void CN_ITEM::SetLayer ( int  aLayer)
inline

Function SetLayer()

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

Definition at line 255 of file connectivity_items.h.

256  {
257  m_layers = LAYER_RANGE( aLayer, aLayer );
258  }
LAYER_RANGE m_layers
layer range over which the item exists
Class LAYER_RANGE.
Definition: pns_layerset.h:32

References m_layers.

Referenced by CN_LIST::Add().

◆ SetLayers()

void CN_ITEM::SetLayers ( const LAYER_RANGE aLayers)
inline

Function SetLayers()

Sets the layers spanned by the item to aLayers.

Definition at line 245 of file connectivity_items.h.

246  {
247  m_layers = aLayers;
248  }
LAYER_RANGE m_layers
layer range over which the item exists

References m_layers.

◆ SetValid()

void CN_ITEM::SetValid ( bool  aValid)
inline

Definition at line 220 of file connectivity_items.h.

221  {
222  m_valid = aValid;
223  }
bool m_valid
valid flag, used to identify garbage items (we use lazy removal)

References m_valid.

◆ SetVisited()

void CN_ITEM::SetVisited ( bool  aVisited)
inline

Definition at line 305 of file connectivity_items.h.

306  {
307  m_visited = aVisited;
308  }
bool m_visited
visited flag for the BFS scan

References m_visited.

Referenced by CN_CONNECTIVITY_ALGO::SearchClusters().

◆ Valid()

bool CN_ITEM::Valid ( ) const
inline

Definition at line 225 of file connectivity_items.h.

226  {
227  return m_valid;
228  }
bool m_valid
valid flag, used to identify garbage items (we use lazy removal)

References m_valid.

Referenced by CN_ZONE::AnchorCount(), Dump(), CN_ZONE::GetAnchor(), CONNECTIVITY_DATA::GetNetItems(), CN_VISITOR::operator()(), CN_CLUSTER::OriginNetName(), CN_ANCHOR::Parent(), and CN_ANCHOR::Valid().

◆ Visited()

bool CN_ITEM::Visited ( ) const
inline

Definition at line 310 of file connectivity_items.h.

311  {
312  return m_visited;
313  }
bool m_visited
visited flag for the BFS scan

References m_visited.

Member Data Documentation

◆ m_anchors

CN_ANCHORS CN_ITEM::m_anchors
private

Definition at line 170 of file connectivity_items.h.

Referenced by AddAnchor(), Anchors(), and CN_ITEM().

◆ m_bbox

BOX2I CN_ITEM::m_bbox
protected

bounding box for the item

Definition at line 192 of file connectivity_items.h.

Referenced by BBox(), and CN_ZONE::BBox().

◆ m_canChangeNet

bool CN_ITEM::m_canChangeNet
private

can the net propagator modify the netcode?

Definition at line 176 of file connectivity_items.h.

Referenced by CanChangeNet(), and CN_ITEM().

◆ m_connected

CONNECTED_ITEMS CN_ITEM::m_connected
private

list of items physically connected (touching)

Definition at line 168 of file connectivity_items.h.

Referenced by ClearConnections(), Connect(), ConnectedItems(), Dump(), and RemoveInvalidRefs().

◆ m_dirty

bool CN_ITEM::m_dirty
protected

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

Definition at line 186 of file connectivity_items.h.

Referenced by BBox(), CN_ZONE::BBox(), CN_ITEM(), Dirty(), and SetDirty().

◆ m_layers

LAYER_RANGE CN_ITEM::m_layers
protected

layer range over which the item exists

Definition at line 189 of file connectivity_items.h.

Referenced by CN_ITEM(), Layers(), SetLayer(), and SetLayers().

◆ m_listLock

std::mutex CN_ITEM::m_listLock
private

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

Definition at line 182 of file connectivity_items.h.

Referenced by Connect().

◆ m_parent

BOARD_CONNECTED_ITEM* CN_ITEM::m_parent
private

Definition at line 165 of file connectivity_items.h.

Referenced by AnchorCount(), BBox(), CN_ITEM(), GetAnchor(), Net(), and Parent().

◆ m_valid

bool CN_ITEM::m_valid
private

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

Definition at line 179 of file connectivity_items.h.

Referenced by AnchorCount(), BBox(), CN_ITEM(), GetAnchor(), Net(), SetValid(), and Valid().

◆ m_visited

bool CN_ITEM::m_visited
private

visited flag for the BFS scan

Definition at line 173 of file connectivity_items.h.

Referenced by CN_ITEM(), SetVisited(), and Visited().


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