KiCad PCB EDA Suite
CN_ZONE Class Reference

#include <connectivity_items.h>

Inheritance diagram for CN_ZONE:
CN_ITEM INTRUSIVE_LIST< CN_ITEM >

Public Types

using CONNECTED_ITEMS = std::set< CN_ITEM * >
 

Public Member Functions

 CN_ZONE (ZONE_CONTAINER *aParent, bool aCanChangeNet, int aSubpolyIndex)
 
int SubpolyIndex () const
 
bool ContainsAnchor (const CN_ANCHOR_PTR anchor) const
 
bool ContainsPoint (const VECTOR2I p) const
 
const BOX2IBBox ()
 
virtual int AnchorCount () const override
 
virtual const VECTOR2I GetAnchor (int n) const override
 
void Dump ()
 
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...
 
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 ()
 
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

std::vector< VECTOR2Im_testOutlinePoints
 
std::unique_ptr< POLY_GRID_PARTITIONm_cachedPoly
 
int m_subpolyIndex
 

Detailed Description

Definition at line 336 of file connectivity_items.h.

Member Typedef Documentation

◆ CONNECTED_ITEMS

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

Definition at line 162 of file connectivity_items.h.

Constructor & Destructor Documentation

◆ CN_ZONE()

CN_ZONE::CN_ZONE ( ZONE_CONTAINER aParent,
bool  aCanChangeNet,
int  aSubpolyIndex 
)
inline

Definition at line 339 of file connectivity_items.h.

339  :
340  CN_ITEM( aParent, aCanChangeNet ),
341  m_subpolyIndex( aSubpolyIndex )
342  {
343  SHAPE_LINE_CHAIN outline = aParent->GetFilledPolysList().COutline( aSubpolyIndex );
344 
345  outline.SetClosed( true );
346  outline.Simplify();
347 
348  m_cachedPoly.reset( new POLY_GRID_PARTITION( outline, 16 ) );
349  }
SHAPE_LINE_CHAIN & Simplify()
Function Simplify()
void SetClosed(bool aClosed)
Function SetClosed()
std::unique_ptr< POLY_GRID_PARTITION > m_cachedPoly
Class SHAPE_LINE_CHAIN.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
CN_ITEM(BOARD_CONNECTED_ITEM *aParent, bool aCanChangeNet, int aAnchorCount=2)
Class POLY_GRID_PARTITION.
const SHAPE_POLY_SET & GetFilledPolysList() const
Function GetFilledPolysList returns a reference to the list of filled polygons.
Definition: class_zone.h:543

References SHAPE_POLY_SET::COutline(), ZONE_CONTAINER::GetFilledPolysList(), m_cachedPoly, SHAPE_LINE_CHAIN::SetClosed(), and SHAPE_LINE_CHAIN::Simplify().

Member Function Documentation

◆ AddAnchor()

void CN_ITEM::AddAnchor ( const VECTOR2I aPos)
inlineinherited

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 CN_ITEM::m_anchors.

Referenced by CN_LIST::Add().

◆ AnchorCount()

int CN_ZONE::AnchorCount ( ) const
overridevirtual

Reimplemented from CN_ITEM.

Definition at line 88 of file connectivity_items.cpp.

89 {
90  if( !Valid() )
91  return 0;
92 
93  const auto zone = static_cast<const ZONE_CONTAINER*>( Parent() );
94  const auto& outline = zone->GetFilledPolysList().COutline( m_subpolyIndex );
95 
96  return outline.PointCount() ? 1 : 0;
97 }
BOARD_CONNECTED_ITEM * Parent() const
bool Valid() const

References m_subpolyIndex, CN_ITEM::Parent(), and CN_ITEM::Valid().

◆ Anchors()

CN_ANCHORS& CN_ITEM::Anchors ( )
inlineinherited

Definition at line 215 of file connectivity_items.h.

216  {
217  return m_anchors;
218  }
CN_ANCHORS m_anchors

References CN_ITEM::m_anchors.

Referenced by CN_CONNECTIVITY_ALGO::ForEachAnchor().

◆ BBox()

const BOX2I& CN_ZONE::BBox ( )
inline

Definition at line 368 of file connectivity_items.h.

369  {
370  if( m_dirty )
371  m_bbox = m_cachedPoly->BBox();
372 
373  return m_bbox;
374  }
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
std::unique_ptr< POLY_GRID_PARTITION > m_cachedPoly

References CN_ITEM::m_bbox, m_cachedPoly, and CN_ITEM::m_dirty.

◆ CanChangeNet()

bool CN_ITEM::CanChangeNet ( ) const
inlineinherited

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 CN_ITEM::m_canChangeNet.

Referenced by CN_VISITOR::checkZoneItemConnection().

◆ ClearConnections()

void CN_ITEM::ClearConnections ( )
inlineinherited

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 CN_ITEM::m_connected.

◆ Connect()

void CN_ITEM::Connect ( CN_ITEM b)
inlineinherited

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 CN_ITEM::m_connected, and CN_ITEM::m_listLock.

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

◆ ConnectedItems()

const CONNECTED_ITEMS& CN_ITEM::ConnectedItems ( ) const
inlineinherited

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 CN_ITEM::m_connected.

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

◆ ContainsAnchor()

bool CN_ZONE::ContainsAnchor ( const CN_ANCHOR_PTR  anchor) const
inline

Definition at line 356 of file connectivity_items.h.

357  {
358  return ContainsPoint( anchor->Pos() );
359  }
bool ContainsPoint(const VECTOR2I p) const

References ContainsPoint().

◆ ContainsPoint()

bool CN_ZONE::ContainsPoint ( const VECTOR2I  p) const
inline

Definition at line 361 of file connectivity_items.h.

362  {
363  auto zone = static_cast<ZONE_CONTAINER*> ( Parent() );
364  int clearance = zone->GetFilledPolysUseThickness() ? zone->GetMinThickness() : 0;
365  return m_cachedPoly->ContainsPoint( p, clearance );
366  }
BOARD_CONNECTED_ITEM * Parent() const
std::unique_ptr< POLY_GRID_PARTITION > m_cachedPoly

References m_cachedPoly, and CN_ITEM::Parent().

Referenced by CN_VISITOR::checkZoneZoneConnection(), and ContainsAnchor().

◆ Dirty()

bool CN_ITEM::Dirty ( ) const
inlineinherited

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 CN_ITEM::m_dirty.

Referenced by CN_VISITOR::operator()().

◆ Dump()

void CN_ITEM::Dump ( )
inherited

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, CN_ITEM::m_connected, EDA_ITEM::Type(), and CN_ITEM::Valid().

Referenced by CN_CONNECTIVITY_ALGO::SearchClusters().

◆ GetAnchor()

const VECTOR2I CN_ZONE::GetAnchor ( int  n) const
overridevirtual

Reimplemented from CN_ITEM.

Definition at line 100 of file connectivity_items.cpp.

101 {
102  if( !Valid() )
103  return VECTOR2I();
104 
105  const auto zone = static_cast<const ZONE_CONTAINER*> ( Parent() );
106  const auto& outline = zone->GetFilledPolysList().COutline( m_subpolyIndex );
107 
108  return outline.CPoint( 0 );
109 }
BOARD_CONNECTED_ITEM * Parent() const
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
bool Valid() const

References m_subpolyIndex, CN_ITEM::Parent(), and CN_ITEM::Valid().

◆ Layer()

virtual int CN_ITEM::Layer ( ) const
inlinevirtualinherited

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 CN_ITEM::Layers(), and LAYER_RANGE::Start().

◆ Layers()

const LAYER_RANGE& CN_ITEM::Layers ( ) const
inlineinherited

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 CN_ITEM::m_layers.

Referenced by CN_LIST::FindNearby(), and CN_ITEM::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
inherited

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(), CN_ITEM::m_parent, and CN_ITEM::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 ( )
inherited

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 CN_ITEM::m_connected.

◆ SetDirty()

void CN_ITEM::SetDirty ( bool  aDirty)
inlineinherited

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 CN_ITEM::m_dirty.

◆ SetLayer()

void CN_ITEM::SetLayer ( int  aLayer)
inlineinherited

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 CN_ITEM::m_layers.

Referenced by CN_LIST::Add().

◆ SetLayers()

void CN_ITEM::SetLayers ( const LAYER_RANGE aLayers)
inlineinherited

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 CN_ITEM::m_layers.

◆ SetValid()

void CN_ITEM::SetValid ( bool  aValid)
inlineinherited

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 CN_ITEM::m_valid.

◆ SetVisited()

void CN_ITEM::SetVisited ( bool  aVisited)
inlineinherited

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 CN_ITEM::m_visited.

Referenced by CN_CONNECTIVITY_ALGO::SearchClusters().

◆ SubpolyIndex()

int CN_ZONE::SubpolyIndex ( ) const
inline

Definition at line 351 of file connectivity_items.h.

352  {
353  return m_subpolyIndex;
354  }

References m_subpolyIndex.

Referenced by CN_VISITOR::checkZoneZoneConnection().

◆ Valid()

bool CN_ITEM::Valid ( ) const
inlineinherited

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 CN_ITEM::m_valid.

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

◆ Visited()

bool CN_ITEM::Visited ( ) const
inlineinherited

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 CN_ITEM::m_visited.

Member Data Documentation

◆ m_bbox

BOX2I CN_ITEM::m_bbox
protectedinherited

bounding box for the item

Definition at line 192 of file connectivity_items.h.

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

◆ m_cachedPoly

std::unique_ptr<POLY_GRID_PARTITION> CN_ZONE::m_cachedPoly
private

Definition at line 381 of file connectivity_items.h.

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

◆ m_dirty

bool CN_ITEM::m_dirty
protectedinherited

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 CN_ITEM::BBox(), BBox(), CN_ITEM::CN_ITEM(), CN_ITEM::Dirty(), and CN_ITEM::SetDirty().

◆ m_layers

LAYER_RANGE CN_ITEM::m_layers
protectedinherited

layer range over which the item exists

Definition at line 189 of file connectivity_items.h.

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

◆ m_subpolyIndex

int CN_ZONE::m_subpolyIndex
private

Definition at line 382 of file connectivity_items.h.

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

◆ m_testOutlinePoints

std::vector<VECTOR2I> CN_ZONE::m_testOutlinePoints
private

Definition at line 380 of file connectivity_items.h.


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