KiCad PCB EDA Suite
CN_ZONE Class Reference

#include <connectivity_items.h>

Inheritance diagram for CN_ZONE:
CN_ITEM INTRUSIVE_LIST< 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 329 of file connectivity_items.h.

Constructor & Destructor Documentation

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

Definition at line 332 of file connectivity_items.h.

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

332  :
333  CN_ITEM( aParent, aCanChangeNet ),
334  m_subpolyIndex( aSubpolyIndex )
335  {
336  SHAPE_LINE_CHAIN outline = aParent->GetFilledPolysList().COutline( aSubpolyIndex );
337 
338  outline.SetClosed( true );
339  outline.Simplify();
340 
341  m_cachedPoly.reset( new POLY_GRID_PARTITION( outline, 16 ) );
342  }
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:555
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 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_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:60
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:555
BOARD_CONNECTED_ITEM * Parent() const
CN_ANCHORS& CN_ITEM::Anchors ( )
inlineinherited

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_ZONE::BBox ( )
inline

Definition at line 360 of file connectivity_items.h.

361  {
362  if( m_dirty )
363  m_bbox = m_cachedPoly->BBox();
364 
365  return m_bbox;
366  }
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 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 ( )
inlineinherited

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)
inlineinherited

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
inlineinherited

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_ZONE::ContainsAnchor ( const CN_ANCHOR_PTR  anchor) const
inline

Definition at line 349 of file connectivity_items.h.

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

Definition at line 354 of file connectivity_items.h.

References CN_ANCHOR::Parent().

Referenced by CN_VISITOR::checkZoneZoneConnection().

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

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 ( )
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:60
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:555
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 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
inlineinherited

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
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 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)
inlineinherited

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)
inlineinherited

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)
inlineinherited

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)
inlineinherited

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
int CN_ZONE::SubpolyIndex ( ) const
inline

Definition at line 344 of file connectivity_items.h.

Referenced by CN_VISITOR::checkZoneZoneConnection().

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

Definition at line 218 of file connectivity_items.h.

Referenced by AnchorCount(), CN_ITEM::Dump(), 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
inlineinherited

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

BOX2I CN_ITEM::m_bbox
protectedinherited

bounding box for the item

Definition at line 185 of file connectivity_items.h.

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

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

LAYER_RANGE CN_ITEM::m_layers
protectedinherited

layer range over which the item exists

Definition at line 182 of file connectivity_items.h.

int CN_ZONE::m_subpolyIndex
private

Definition at line 374 of file connectivity_items.h.

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

Definition at line 372 of file connectivity_items.h.


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