KiCad PCB EDA Suite
CN_ZONE_LAYER Class Reference

#include <connectivity_items.h>

Inheritance diagram for CN_ZONE_LAYER:
CN_ITEM

Public Types

using CONNECTED_ITEMS = std::vector< CN_ITEM * >
 

Public Member Functions

 CN_ZONE_LAYER (ZONE *aParent, PCB_LAYER_ID aLayer, bool aCanChangeNet, int aSubpolyIndex)
 
int SubpolyIndex () const
 
PCB_LAYER_ID GetLayer () const
 
bool ContainsAnchor (const CN_ANCHOR_PTR anchor) const
 
bool ContainsPoint (const VECTOR2I &p, int aAccuracy=0) 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)
 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...
 
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
 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

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

Detailed Description

Definition at line 291 of file connectivity_items.h.

Member Typedef Documentation

◆ CONNECTED_ITEMS

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

Definition at line 170 of file connectivity_items.h.

Constructor & Destructor Documentation

◆ CN_ZONE_LAYER()

CN_ZONE_LAYER::CN_ZONE_LAYER ( ZONE aParent,
PCB_LAYER_ID  aLayer,
bool  aCanChangeNet,
int  aSubpolyIndex 
)
inline

Definition at line 294 of file connectivity_items.h.

294  :
295  CN_ITEM( aParent, aCanChangeNet ),
296  m_subpolyIndex( aSubpolyIndex ),
297  m_layer( aLayer )
298  {
299  SHAPE_LINE_CHAIN outline = aParent->GetFilledPolysList( aLayer ).COutline( aSubpolyIndex );
300 
301  outline.SetClosed( true );
302  outline.Simplify();
303 
304  m_cachedPoly = std::make_unique<POLY_GRID_PARTITION>( outline, 16 );
305  }
SHAPE_LINE_CHAIN & Simplify(bool aRemoveColinear=true)
Simplify the line chain by removing colinear adjacent segments and duplicate vertices.
const SHAPE_POLY_SET & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition: zone.h:637
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
PCB_LAYER_ID m_layer
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
CN_ITEM(BOARD_CONNECTED_ITEM *aParent, bool aCanChangeNet, int aAnchorCount=2)
std::unique_ptr< POLY_GRID_PARTITION > m_cachedPoly

References SHAPE_POLY_SET::COutline(), ZONE::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 188 of file connectivity_items.h.

189  {
190  m_anchors.emplace_back( std::make_shared<CN_ANCHOR>( aPos, this ) );
191  }
CN_ANCHORS m_anchors

References CN_ITEM::m_anchors.

Referenced by CN_LIST::Add().

◆ AnchorCount()

int CN_ZONE_LAYER::AnchorCount ( ) const
overridevirtual

Reimplemented from CN_ITEM.

Definition at line 168 of file connectivity_items.cpp.

169 {
170  if( !Valid() )
171  return 0;
172 
173  const ZONE* zone = static_cast<const ZONE*>( Parent() );
175 
176  return outline.PointCount() ? 1 : 0;
177 }
const SHAPE_POLY_SET & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition: zone.h:637
BOARD_CONNECTED_ITEM * Parent() const
int PointCount() const
Return the number of points (vertices) in this line chain.
Handle a list of polygons defining a copper zone.
Definition: zone.h:56
PCB_LAYER_ID m_layer
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
bool Valid() const

References SHAPE_POLY_SET::COutline(), ZONE::GetFilledPolysList(), m_layer, m_subpolyIndex, CN_ITEM::Parent(), SHAPE_LINE_CHAIN::PointCount(), and CN_ITEM::Valid().

◆ Anchors()

CN_ANCHORS& CN_ITEM::Anchors ( )
inlineinherited

Definition at line 193 of file connectivity_items.h.

193 { return m_anchors; }
CN_ANCHORS m_anchors

References CN_ITEM::m_anchors.

◆ BBox()

const BOX2I& CN_ZONE_LAYER::BBox ( )
inline

Definition at line 327 of file connectivity_items.h.

328  {
329  if( m_dirty )
330  m_bbox = m_cachedPoly->BBox();
331 
332  return m_bbox;
333  }
bool m_dirty
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.

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

◆ CanChangeNet()

bool CN_ITEM::CanChangeNet ( ) const
inlineinherited

Definition at line 243 of file connectivity_items.h.

243 { return m_canChangeNet; }
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 238 of file connectivity_items.h.

238 { m_connected.clear(); }
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 245 of file connectivity_items.h.

246  {
247  std::lock_guard<std::mutex> lock( m_listLock );
248 
249  auto i = std::lower_bound( m_connected.begin(), m_connected.end(), b );
250 
251  if( i != m_connected.end() && *i == b )
252  return;
253 
254  m_connected.insert( i, b );
255  }
std::mutex m_listLock
mutex protecting this item's connected_items set to
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()

◆ ContainsAnchor()

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

Definition at line 311 of file connectivity_items.h.

312  {
313  return ContainsPoint( anchor->Pos(), 0 );
314  }
bool ContainsPoint(const VECTOR2I &p, int aAccuracy=0) const

References anchor, and ContainsPoint().

◆ ContainsPoint()

bool CN_ZONE_LAYER::ContainsPoint ( const VECTOR2I p,
int  aAccuracy = 0 
) const
inline

Definition at line 316 of file connectivity_items.h.

317  {
318  ZONE* zone = static_cast<ZONE*>( Parent() );
319  int clearance = aAccuracy;
320 
321  if( zone->GetFilledPolysUseThickness() )
322  clearance += ( zone->GetMinThickness() + 1 ) / 2;
323 
324  return m_cachedPoly->ContainsPoint( p, clearance );
325  }
BOARD_CONNECTED_ITEM * Parent() const
int GetMinThickness() const
Definition: zone.h:244
Handle a list of polygons defining a copper zone.
Definition: zone.h:56
std::unique_ptr< POLY_GRID_PARTITION > m_cachedPoly
bool GetFilledPolysUseThickness() const
Definition: zone.h:691

References ZONE::GetFilledPolysUseThickness(), ZONE::GetMinThickness(), m_cachedPoly, and CN_ITEM::Parent().

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

◆ Dirty()

bool CN_ITEM::Dirty ( ) const
inlineinherited

Definition at line 199 of file connectivity_items.h.

199 { return m_dirty; }
bool m_dirty
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 156 of file connectivity_items.cpp.

157 {
158  wxLogDebug(" valid: %d, connected: \n", !!Valid());
159 
160  for( CN_ITEM* i : m_connected )
161  {
162  PCB_TRACK* t = static_cast<PCB_TRACK*>( i->Parent() );
163  wxLogDebug( wxT( " - %p %d\n" ), t, t->Type() );
164  }
165 }
CN_ITEM represents a BOARD_CONNETED_ITEM in the connectivity system (ie: a pad, track/arc/via,...
CONNECTED_ITEMS m_connected
list of items physically connected (touching)
bool Valid() const
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

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

◆ GetAnchor()

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

Reimplemented from CN_ITEM.

Definition at line 180 of file connectivity_items.cpp.

181 {
182  if( !Valid() )
183  return VECTOR2I();
184 
185  const ZONE* zone = static_cast<const ZONE*>( Parent() );
187 
188  return outline.CPoint( 0 );
189 }
const SHAPE_POLY_SET & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition: zone.h:637
BOARD_CONNECTED_ITEM * Parent() const
VECTOR2< int > VECTOR2I
Definition: vector2d.h:622
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
Handle a list of polygons defining a copper zone.
Definition: zone.h:56
PCB_LAYER_ID m_layer
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
bool Valid() const

References SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CPoint(), ZONE::GetFilledPolysList(), m_layer, m_subpolyIndex, CN_ITEM::Parent(), and CN_ITEM::Valid().

◆ GetLayer()

PCB_LAYER_ID CN_ZONE_LAYER::GetLayer ( ) const
inline

Definition at line 309 of file connectivity_items.h.

309 { return m_layer; }
PCB_LAYER_ID m_layer

References m_layer.

◆ Layer()

virtual int CN_ITEM::Layer ( ) const
inlinevirtualinherited

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

Definition at line 219 of file connectivity_items.h.

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

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

Referenced by CN_VISITOR::checkZoneZoneConnection().

◆ Layers()

const LAYER_RANGE& CN_ITEM::Layers ( ) const
inlineinherited

Return the contiguous set of layers spanned by the item.

Definition at line 214 of file connectivity_items.h.

214 { return m_layers; }
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().

◆ Net()

◆ Parent()

◆ RemoveInvalidRefs()

void CN_ITEM::RemoveInvalidRefs ( )
inherited

Definition at line 192 of file connectivity_items.cpp.

193 {
194  for( auto it = m_connected.begin(); it != m_connected.end(); )
195  {
196  if( !(*it)->Valid() )
197  it = m_connected.erase( it );
198  else
199  ++it;
200  }
201 }
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 198 of file connectivity_items.h.

198 { m_dirty = aDirty; }
bool m_dirty
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

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

Definition at line 209 of file connectivity_items.h.

209 { m_layers = LAYER_RANGE( aLayer, aLayer ); }
LAYER_RANGE m_layers
layer range over which the item exists
Represent a contiguous set of PCB layers.
Definition: pns_layerset.h:31

References CN_ITEM::m_layers.

Referenced by CN_LIST::Add().

◆ SetLayers()

void CN_ITEM::SetLayers ( const LAYER_RANGE aLayers)
inlineinherited

Set the layers spanned by the item to aLayers.

Definition at line 204 of file connectivity_items.h.

204 { m_layers = aLayers; }
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 195 of file connectivity_items.h.

195 { m_valid = aValid; }
bool m_valid
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 240 of file connectivity_items.h.

240 { m_visited = aVisited; }
bool m_visited
visited flag for the BFS scan

References CN_ITEM::m_visited.

Referenced by CN_CONNECTIVITY_ALGO::SearchClusters().

◆ SubpolyIndex()

int CN_ZONE_LAYER::SubpolyIndex ( ) const
inline

Definition at line 307 of file connectivity_items.h.

307 { return m_subpolyIndex; }

References m_subpolyIndex.

Referenced by CN_VISITOR::checkZoneZoneConnection().

◆ Valid()

bool CN_ITEM::Valid ( ) const
inlineinherited

◆ Visited()

bool CN_ITEM::Visited ( ) const
inlineinherited

Definition at line 241 of file connectivity_items.h.

241 { return m_visited; }
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 271 of file connectivity_items.h.

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

◆ m_cachedPoly

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

Definition at line 340 of file connectivity_items.h.

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

◆ m_dirty

bool CN_ITEM::m_dirty
protectedinherited

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

Definition at line 268 of file connectivity_items.h.

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

◆ m_layer

PCB_LAYER_ID CN_ZONE_LAYER::m_layer
private

Definition at line 342 of file connectivity_items.h.

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

◆ m_layers

LAYER_RANGE CN_ITEM::m_layers
protectedinherited

layer range over which the item exists

Definition at line 270 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_LAYER::m_subpolyIndex
private

Definition at line 341 of file connectivity_items.h.

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

◆ m_testOutlinePoints

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

Definition at line 339 of file connectivity_items.h.


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