KiCad PCB EDA Suite
CN_ITEM Class Reference

CN_ITEM represents a BOARD_CONNETED_ITEM in the connectivity system (ie: a pad, track/arc/via, or zone). More...

#include <connectivity_items.h>

Inheritance diagram for CN_ITEM:
CN_ZONE_LAYER

Public Member Functions

void Dump ()
 
 CN_ITEM (BOARD_CONNECTED_ITEM *aParent, bool aCanChangeNet, int aAnchorCount=2)
 
virtual ~CN_ITEM ()
 
void AddAnchor (const VECTOR2I &aPos)
 
std::vector< std::shared_ptr< CN_ANCHOR > > & Anchors ()
 
void SetValid (bool aValid)
 
bool Valid () const
 
void SetDirty (bool aDirty)
 
bool Dirty () const
 
void SetLayers (const LAYER_RANGE &aLayers)
 Set the layers spanned by the item to aLayers. More...
 
void SetLayer (int aLayer)
 Set the layers spanned by the item to a single layer aLayer. More...
 
const LAYER_RANGELayers () const
 Return the contiguous set of layers spanned by the item. More...
 
virtual int Layer () const
 Return the item's layer, for single-layered items only. More...
 
const BOX2IBBox ()
 
BOARD_CONNECTED_ITEMParent () const
 
const std::vector< CN_ITEM * > & ConnectedItems () 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 GetAnchorItemCount () const
 
std::shared_ptr< CN_ANCHORGetAnchorItem (int n) const
 
int Net () const
 allow parallel connection threads More...
 

Protected Attributes

bool m_dirty
 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
 
std::vector< CN_ITEM * > m_connected
 list of physically touching items More...
 
std::vector< std::shared_ptr< CN_ANCHOR > > m_anchors
 
bool m_canChangeNet
 can the net propagator modify the netcode? More...
 
bool m_visited
 visited flag for the BFS scan More...
 
bool m_valid
 used to identify garbage items (we use lazy removal) More...
 
std::mutex m_listLock
 mutex protecting this item's connected_items set to More...
 

Detailed Description

CN_ITEM represents a BOARD_CONNETED_ITEM in the connectivity system (ie: a pad, track/arc/via, or zone).

Definition at line 163 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 168 of file connectivity_items.h.

169 {
170 m_parent = aParent;
171 m_canChangeNet = aCanChangeNet;
172 m_visited = false;
173 m_valid = true;
174 m_dirty = true;
175 m_anchors.reserve( std::max( 6, aAnchorCount ) );
177 m_connected.reserve( 8 );
178 }
bool m_visited
visited flag for the BFS scan
std::vector< CN_ITEM * > m_connected
list of physically touching items
BOARD_CONNECTED_ITEM * m_parent
LAYER_RANGE m_layers
layer range over which the item exists
bool m_canChangeNet
can the net propagator modify the netcode?
bool m_dirty
used to identify recently added item not yet scanned into the connectivity search
std::vector< std::shared_ptr< CN_ANCHOR > > m_anchors
bool m_valid
used to identify garbage items (we use lazy removal)
Represent a contiguous set of PCB layers.
Definition: pns_layerset.h:32
@ PCB_LAYER_ID_COUNT
Definition: layer_ids.h:137

References m_anchors, m_canChangeNet, m_connected, 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 180 of file connectivity_items.h.

180{};

Member Function Documentation

◆ AddAnchor()

void CN_ITEM::AddAnchor ( const VECTOR2I aPos)
inline

Definition at line 182 of file connectivity_items.h.

183 {
184 m_anchors.emplace_back( std::make_shared<CN_ANCHOR>( aPos, this ) );
185 }

References m_anchors.

Referenced by CN_LIST::Add(), and RN_NET::optimizeRNEdges().

◆ AnchorCount()

int CN_ITEM::AnchorCount ( ) const
virtual

Reimplemented in CN_ZONE_LAYER.

Definition at line 35 of file connectivity_items.cpp.

36{
37 if( !m_valid )
38 return 0;
39
40 switch( m_parent->Type() )
41 {
42 case PCB_TRACE_T:
43 case PCB_ARC_T:
44 return 2; // start and end
45 default:
46 return 1;
47 }
48}
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:103
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:101

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

Referenced by CN_VISITOR::checkZoneItemConnection(), and CN_ANCHOR::IsDangling().

◆ Anchors()

std::vector< std::shared_ptr< CN_ANCHOR > > & CN_ITEM::Anchors ( )
inline

Definition at line 187 of file connectivity_items.h.

187{ return m_anchors; }

References m_anchors.

Referenced by TRACKS_CLEANER::testTrackEndpointIsNode().

◆ BBox()

const BOX2I & CN_ITEM::BBox ( )
inline

Definition at line 218 of file connectivity_items.h.

219 {
220 if( m_dirty && m_valid )
222
223 return m_bbox;
224 }
BOX2I m_bbox
bounding box for the item
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition: eda_item.cpp:74

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

Referenced by CN_VISITOR::checkZoneZoneConnection(), and CN_LIST::FindNearby().

◆ CanChangeNet()

bool CN_ITEM::CanChangeNet ( ) const
inline

Definition at line 234 of file connectivity_items.h.

234{ return m_canChangeNet; }

References m_canChangeNet.

Referenced by CN_VISITOR::checkZoneItemConnection().

◆ ClearConnections()

void CN_ITEM::ClearConnections ( )
inline

Definition at line 229 of file connectivity_items.h.

229{ m_connected.clear(); }

References m_connected.

◆ Connect()

void CN_ITEM::Connect ( CN_ITEM b)
inline

Definition at line 236 of file connectivity_items.h.

237 {
238 std::lock_guard<std::mutex> lock( m_listLock );
239
240 auto i = std::lower_bound( m_connected.begin(), m_connected.end(), b );
241
242 if( i != m_connected.end() && *i == b )
243 return;
244
245 m_connected.insert( i, b );
246 }
std::mutex m_listLock
mutex protecting this item's connected_items set to

References m_connected, and m_listLock.

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

◆ ConnectedItems()

◆ Dirty()

bool CN_ITEM::Dirty ( ) const
inline

Definition at line 193 of file connectivity_items.h.

193{ return m_dirty; }

References m_dirty.

Referenced by CN_VISITOR::operator()().

◆ Dump()

void CN_ITEM::Dump ( )

Definition at line 78 of file connectivity_items.cpp.

79{
80 wxLogDebug(" valid: %d, connected: \n", !!Valid());
81
82 for( CN_ITEM* i : m_connected )
83 {
84 PCB_TRACK* t = static_cast<PCB_TRACK*>( i->Parent() );
85 wxLogDebug( wxT( " - %p %d\n" ), t, t->Type() );
86 }
87}
CN_ITEM represents a BOARD_CONNETED_ITEM in the connectivity system (ie: a pad, track/arc/via,...
bool Valid() const

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

◆ GetAnchor()

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

Reimplemented in CN_ZONE_LAYER.

Definition at line 51 of file connectivity_items.cpp.

52{
53 if( !m_valid )
54 return VECTOR2I();
55
56 switch( m_parent->Type() )
57 {
58 case PCB_PAD_T:
59 return static_cast<PAD*>( m_parent )->GetPosition();
60
61 case PCB_TRACE_T:
62 case PCB_ARC_T:
63 if( n == 0 )
64 return static_cast<const PCB_TRACK*>( m_parent )->GetStart();
65 else
66 return static_cast<const PCB_TRACK*>( m_parent )->GetEnd();
67
68 case PCB_VIA_T:
69 return static_cast<const PCB_VIA*>( m_parent )->GetStart();
70
71 default:
73 return VECTOR2I();
74 }
75}
virtual wxString GetClass() const =0
Return the class name.
Definition: pad.h:58
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:120
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:102
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618

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

Referenced by CN_VISITOR::checkZoneItemConnection().

◆ GetAnchorItem()

std::shared_ptr< CN_ANCHOR > CN_ITEM::GetAnchorItem ( int  n) const
inline

Definition at line 254 of file connectivity_items.h.

254{ return m_anchors[n]; }

References m_anchors.

Referenced by RN_NET::optimizeRNEdges().

◆ GetAnchorItemCount()

int CN_ITEM::GetAnchorItemCount ( ) const
inline

Definition at line 253 of file connectivity_items.h.

253{ return m_anchors.size(); }

References m_anchors.

Referenced by RN_NET::optimizeRNEdges().

◆ Layer()

virtual int CN_ITEM::Layer ( ) const
inlinevirtual

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

Definition at line 213 of file connectivity_items.h.

214 {
215 return Layers().Start();
216 }
const LAYER_RANGE & Layers() const
Return the contiguous set of layers spanned by the item.
int Start() const
Definition: pns_layerset.h:82

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

Referenced by RN_NET::optimizeRNEdges().

◆ Layers()

const LAYER_RANGE & CN_ITEM::Layers ( ) const
inline

Return the contiguous set of layers spanned by the item.

Definition at line 208 of file connectivity_items.h.

208{ return m_layers; }

References m_layers.

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

◆ Net()

◆ 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(); /* increment in loop */ )
115 {
116 if( !(*it)->Valid() )
117 it = m_connected.erase( it );
118 else
119 ++it;
120 }
121}

References m_connected.

◆ SetDirty()

void CN_ITEM::SetDirty ( bool  aDirty)
inline

Definition at line 192 of file connectivity_items.h.

192{ m_dirty = aDirty; }

References m_dirty.

◆ SetLayer()

void CN_ITEM::SetLayer ( int  aLayer)
inline

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

Definition at line 203 of file connectivity_items.h.

203{ m_layers = LAYER_RANGE( aLayer, aLayer ); }

References m_layers.

Referenced by CN_LIST::Add().

◆ SetLayers()

void CN_ITEM::SetLayers ( const LAYER_RANGE aLayers)
inline

Set the layers spanned by the item to aLayers.

Definition at line 198 of file connectivity_items.h.

198{ m_layers = aLayers; }

References m_layers.

Referenced by CN_LIST::Add(), and CN_ZONE_LAYER::CN_ZONE_LAYER().

◆ SetValid()

void CN_ITEM::SetValid ( bool  aValid)
inline

Definition at line 189 of file connectivity_items.h.

189{ m_valid = aValid; }

References m_valid.

◆ SetVisited()

void CN_ITEM::SetVisited ( bool  aVisited)
inline

Definition at line 231 of file connectivity_items.h.

231{ m_visited = aVisited; }

References m_visited.

Referenced by CN_CONNECTIVITY_ALGO::SearchClusters().

◆ Valid()

◆ Visited()

bool CN_ITEM::Visited ( ) const
inline

Definition at line 232 of file connectivity_items.h.

232{ return m_visited; }

References m_visited.

Member Data Documentation

◆ m_anchors

std::vector<std::shared_ptr<CN_ANCHOR> > CN_ITEM::m_anchors
private

Definition at line 271 of file connectivity_items.h.

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

◆ m_bbox

BOX2I CN_ITEM::m_bbox
protected

bounding box for the item

Definition at line 265 of file connectivity_items.h.

Referenced by BBox().

◆ m_canChangeNet

bool CN_ITEM::m_canChangeNet
private

can the net propagator modify the netcode?

Definition at line 273 of file connectivity_items.h.

Referenced by CanChangeNet(), and CN_ITEM().

◆ m_connected

std::vector<CN_ITEM*> CN_ITEM::m_connected
private

list of physically touching items

Definition at line 270 of file connectivity_items.h.

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

◆ m_dirty

bool CN_ITEM::m_dirty
protected

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

Definition at line 262 of file connectivity_items.h.

Referenced by 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 264 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

Definition at line 278 of file connectivity_items.h.

Referenced by Connect().

◆ m_parent

BOARD_CONNECTED_ITEM* CN_ITEM::m_parent
private

Definition at line 268 of file connectivity_items.h.

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

◆ m_valid

bool CN_ITEM::m_valid
private

used to identify garbage items (we use lazy removal)

Definition at line 276 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 275 of file connectivity_items.h.

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


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