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

Member Typedef Documentation

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

Definition at line 156 of file connectivity_items.h.

Constructor & Destructor Documentation

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

Definition at line 333 of file connectivity_items.h.

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

333  :
334  CN_ITEM( aParent, aCanChangeNet ),
335  m_subpolyIndex( aSubpolyIndex )
336  {
337  SHAPE_LINE_CHAIN outline = aParent->GetFilledPolysList().COutline( aSubpolyIndex );
338 
339  outline.SetClosed( true );
340  outline.Simplify();
341 
342  m_cachedPoly.reset( new POLY_GRID_PARTITION( outline, 16 ) );
343  }
SHAPE_LINE_CHAIN & Simplify()
Function Simplify()
void SetClosed(bool aClosed)
Function SetClosed()
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:559
std::unique_ptr< POLY_GRID_PARTITION > m_cachedPoly
Class SHAPE_LINE_CHAIN.
CN_ITEM(BOARD_CONNECTED_ITEM *aParent, bool aCanChangeNet, int aAnchorCount=2)
Class POLY_GRID_PARTITION.

Member Function Documentation

void CN_ITEM::AddAnchor ( const VECTOR2I aPos)
inlineinherited

Definition at line 204 of file connectivity_items.h.

Referenced by CN_LIST::Add().

205  {
206  m_anchors.emplace_back( std::make_unique<CN_ANCHOR>( aPos, this ) );
207  }
CN_ANCHORS m_anchors
int CN_ZONE::AnchorCount ( ) const
overridevirtual

Reimplemented from CN_ITEM.

Definition at line 88 of file connectivity_items.cpp.

References SHAPE_POLY_SET::COutline(), ZONE_CONTAINER::GetFilledPolysList(), CN_ITEM::Parent(), SHAPE_LINE_CHAIN::PointCount(), and CN_ITEM::Valid().

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 }
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:59
int PointCount() const
Function PointCount()
bool Valid() const
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:559
BOARD_CONNECTED_ITEM * Parent() const
CN_ANCHORS& CN_ITEM::Anchors ( )
inlineinherited

Definition at line 209 of file connectivity_items.h.

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

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

Definition at line 361 of file connectivity_items.h.

362  {
363  if( m_dirty )
364  m_bbox = m_cachedPoly->BBox();
365 
366  return m_bbox;
367  }
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
bool CN_ITEM::CanChangeNet ( ) const
inlineinherited

Definition at line 309 of file connectivity_items.h.

Referenced by CN_VISITOR::checkZoneItemConnection().

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

Definition at line 294 of file connectivity_items.h.

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

Definition at line 314 of file connectivity_items.h.

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

315  {
316  std::lock_guard<std::mutex> lock( m_listLock );
317  m_connected.insert( b );
318  }
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
inlineinherited

Definition at line 289 of file connectivity_items.h.

Referenced by CN_CONNECTIVITY_ALGO::SearchClusters().

290  {
291  return m_connected;
292  }
CONNECTED_ITEMS m_connected
list of items physically connected (touching)
bool CN_ZONE::ContainsAnchor ( const CN_ANCHOR_PTR  anchor) const
inline

Definition at line 350 of file connectivity_items.h.

351  {
352  return ContainsPoint( anchor->Pos() );
353  }
bool ContainsPoint(const VECTOR2I p) const
bool CN_ZONE::ContainsPoint ( const VECTOR2I  p) const
inline

Definition at line 355 of file connectivity_items.h.

References CN_ANCHOR::Parent().

Referenced by CN_VISITOR::checkZoneZoneConnection().

356  {
357  auto zone = static_cast<ZONE_CONTAINER*> ( Parent() );
358  return m_cachedPoly->ContainsPoint( p, zone->GetMinThickness() );
359  }
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:59
std::unique_ptr< POLY_GRID_PARTITION > m_cachedPoly
BOARD_CONNECTED_ITEM * Parent() const
bool CN_ITEM::Dirty ( ) const
inlineinherited

Definition at line 229 of file connectivity_items.h.

Referenced by CN_VISITOR::operator()().

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

Definition at line 76 of file connectivity_items.cpp.

References i, CN_ITEM::m_connected, EDA_ITEM::Type(), and CN_ITEM::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_ZONE::GetAnchor ( int  n) const
overridevirtual

Reimplemented from CN_ITEM.

Definition at line 100 of file connectivity_items.cpp.

References SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CPoint(), ZONE_CONTAINER::GetFilledPolysList(), CN_ITEM::Parent(), and CN_ITEM::Valid().

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 }
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:59
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
bool Valid() const
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:559
BOARD_CONNECTED_ITEM * Parent() const
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
virtual int CN_ITEM::Layer ( ) const
inlinevirtualinherited

Function Layer()

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

Definition at line 269 of file connectivity_items.h.

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

Function Layers()

Returns the contiguous set of layers spanned by the item.

Definition at line 259 of file connectivity_items.h.

Referenced by CN_LIST::FindNearby().

260  {
261  return m_layers;
262  }
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
inherited

Definition at line 67 of file connectivity_items.cpp.

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

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

Definition at line 112 of file connectivity_items.cpp.

References CN_ITEM::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)
inlineinherited

Definition at line 224 of file connectivity_items.h.

Referenced by CN_LIST::Add().

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

Function SetLayer()

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

Definition at line 249 of file connectivity_items.h.

Referenced by CN_LIST::Add().

250  {
251  m_layers = LAYER_RANGE( aLayer, aLayer );
252  }
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)
inlineinherited

Function SetLayers()

Sets the layers spanned by the item to aLayers.

Definition at line 239 of file connectivity_items.h.

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

Definition at line 214 of file connectivity_items.h.

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

Definition at line 299 of file connectivity_items.h.

Referenced by CN_CONNECTIVITY_ALGO::SearchClusters().

300  {
301  m_visited = aVisited;
302  }
bool m_visited
visited flag for the BFS scan
int CN_ZONE::SubpolyIndex ( ) const
inline

Definition at line 345 of file connectivity_items.h.

Referenced by CN_VISITOR::checkZoneZoneConnection().

346  {
347  return m_subpolyIndex;
348  }
bool CN_ITEM::Valid ( ) const
inlineinherited

Definition at line 219 of file connectivity_items.h.

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

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

Definition at line 304 of file connectivity_items.h.

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

Member Data Documentation

BOX2I CN_ITEM::m_bbox
protectedinherited

bounding box for the item

Definition at line 186 of file connectivity_items.h.

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

Definition at line 374 of file connectivity_items.h.

bool CN_ITEM::m_dirty
protectedinherited

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

Definition at line 180 of file connectivity_items.h.

LAYER_RANGE CN_ITEM::m_layers
protectedinherited

layer range over which the item exists

Definition at line 183 of file connectivity_items.h.

int CN_ZONE::m_subpolyIndex
private

Definition at line 375 of file connectivity_items.h.

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

Definition at line 373 of file connectivity_items.h.


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