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

303  :
304  CN_ITEM( aParent, aCanChangeNet ),
305  m_subpolyIndex( aSubpolyIndex ),
306  m_layer( aLayer )
307  {
308  SHAPE_LINE_CHAIN outline = aParent->GetFilledPolysList( aLayer ).COutline( aSubpolyIndex );
309 
310  outline.SetClosed( true );
311  outline.Simplify();
312 
313  m_cachedPoly = std::make_unique<POLY_GRID_PARTITION>( outline, 16 );
314  }
SHAPE_LINE_CHAIN & Simplify(bool aRemoveColinear=true)
Function Simplify()
const SHAPE_POLY_SET & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition: zone.h:632
void SetClosed(bool aClosed)
Function SetClosed()
PCB_LAYER_ID m_layer
SHAPE_LINE_CHAIN.
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 169 of file connectivity_items.cpp.

170 {
171  if( !Valid() )
172  return 0;
173 
174  const ZONE* zone = static_cast<const ZONE*>( Parent() );
176 
177  return outline.PointCount() ? 1 : 0;
178 }
const SHAPE_POLY_SET & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition: zone.h:632
BOARD_CONNECTED_ITEM * Parent() const
int PointCount() const
Function PointCount()
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
PCB_LAYER_ID m_layer
SHAPE_LINE_CHAIN.
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.

Referenced by CONNECTIVITY_DATA::TestTrackEndpointDangling().

◆ BBox()

const BOX2I& CN_ZONE_LAYER::BBox ( )
inline

Definition at line 337 of file connectivity_items.h.

338  {
339  if( m_dirty )
340  m_bbox = m_cachedPoly->BBox();
341 
342  return m_bbox;
343  }
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 254 of file connectivity_items.h.

254 { 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 249 of file connectivity_items.h.

249 { 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 256 of file connectivity_items.h.

257  {
258  std::lock_guard<std::mutex> lock( m_listLock );
259 
260  auto i = std::lower_bound( m_connected.begin(), m_connected.end(), b );
261 
262  if( i != m_connected.end() && *i == b )
263  return;
264 
265  m_connected.insert( i, b );
266  }
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 321 of file connectivity_items.h.

322  {
323  return ContainsPoint( anchor->Pos(), 0 );
324  }
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 326 of file connectivity_items.h.

327  {
328  ZONE* zone = static_cast<ZONE*>( Parent() );
329  int clearance = aAccuracy;
330 
331  if( zone->GetFilledPolysUseThickness() )
332  clearance += ( zone->GetMinThickness() + 1 ) / 2;
333 
334  return m_cachedPoly->ContainsPoint( p, clearance );
335  }
BOARD_CONNECTED_ITEM * Parent() const
int GetMinThickness() const
Definition: zone.h:241
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
std::unique_ptr< POLY_GRID_PARTITION > m_cachedPoly
bool GetFilledPolysUseThickness() const
Definition: zone.h:686

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 157 of file connectivity_items.cpp.

158 {
159  wxLogDebug(" valid: %d, connected: \n", !!Valid());
160 
161  for( CN_ITEM* i : m_connected )
162  {
163  PCB_TRACK* t = static_cast<PCB_TRACK*>( i->Parent() );
164  wxLogDebug( " - %p %d\n", t, t->Type() );
165  }
166 }
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:113

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 181 of file connectivity_items.cpp.

182 {
183  if( !Valid() )
184  return VECTOR2I();
185 
186  const ZONE* zone = static_cast<const ZONE*>( Parent() );
188 
189  return outline.CPoint( 0 );
190 }
const SHAPE_POLY_SET & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition: zone.h:632
BOARD_CONNECTED_ITEM * Parent() const
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
const VECTOR2I & CPoint(int aIndex) const
Function Point()
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
PCB_LAYER_ID m_layer
SHAPE_LINE_CHAIN.
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().

◆ Layer()

virtual int CN_ITEM::Layer ( ) const
inlinevirtualinherited

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

Definition at line 228 of file connectivity_items.h.

229  {
230  return Layers().Start();
231  }
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 220 of file connectivity_items.h.

221  {
222  return m_layers;
223  }
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 193 of file connectivity_items.cpp.

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

213  {
214  m_layers = LAYER_RANGE( aLayer, aLayer );
215  }
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.

205  {
206  m_layers = aLayers;
207  }
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 251 of file connectivity_items.h.

251 { 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 316 of file connectivity_items.h.

317  {
318  return m_subpolyIndex;
319  }

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

252 { 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 282 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 350 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 279 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 352 of file connectivity_items.h.

Referenced by AnchorCount(), and GetAnchor().

◆ m_layers

LAYER_RANGE CN_ITEM::m_layers
protectedinherited

layer range over which the item exists

Definition at line 281 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 351 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 349 of file connectivity_items.h.


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