KiCad PCB EDA Suite
CN_ZONE_LAYER Class Reference

#include <connectivity_items.h>

Inheritance diagram for CN_ZONE_LAYER:
CN_ITEM

Public Member Functions

 CN_ZONE_LAYER (ZONE *aParent, PCB_LAYER_ID aLayer, int aSubpolyIndex)
 
void BuildRTree ()
 
int SubpolyIndex () const
 
PCB_LAYER_ID GetLayer () const
 
bool ContainsPoint (const VECTOR2I &p) const
 
PCB_LAYER_ID GetLayer ()
 
virtual int AnchorCount () const override
 
virtual const VECTOR2I GetAnchor (int n) const override
 
const SHAPE_LINE_CHAINGetOutline () const
 
VECTOR2I ClosestPoint (const VECTOR2I aPt)
 
bool Collide (SHAPE *aRefShape) const
 
void Dump ()
 
std::shared_ptr< CN_ANCHORAddAnchor (const VECTOR2I &aPos)
 
std::vector< std::shared_ptr< CN_ANCHOR > > & Anchors ()
 
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...
 
const BOX2IBBox ()
 
BOARD_CONNECTED_ITEMParent () const
 
const std::vector< CN_ITEM * > & ConnectedItems () const
 
void ClearConnections ()
 
void SetVisited (bool aVisited)
 
bool Visited () const
 
bool CanChangeNet () const
 
void Connect (CN_ITEM *b)
 
void RemoveInvalidRefs ()
 
int GetAnchorItemCount () const
 
std::shared_ptr< CN_ANCHORGetAnchorItem (int n) const
 
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

int m_subpolyIndex
 
PCB_LAYER_ID m_layer
 
std::shared_ptr< SHAPE_POLY_SETm_triangulatedPoly
 
RTree< const SHAPE *, int, 2, double > m_rTree
 
BOARD_CONNECTED_ITEMm_parent
 
std::vector< CN_ITEM * > m_connected
 list of physically touching items More...
 
std::vector< std::shared_ptr< CN_ANCHOR > > m_anchors
 
bool m_canChangeNet
 can the net propagator modify the netcode? More...
 
bool m_visited
 visited flag for the BFS scan More...
 
bool m_valid
 used to identify garbage items (we use lazy removal) More...
 
std::mutex m_listLock
 mutex protecting this item's connected_items set to More...
 

Detailed Description

Definition at line 286 of file connectivity_items.h.

Constructor & Destructor Documentation

◆ CN_ZONE_LAYER()

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

Definition at line 289 of file connectivity_items.h.

289 :
290 CN_ITEM( aParent, false ),
291 m_subpolyIndex( aSubpolyIndex ),
292 m_layer( aLayer )
293 {
294 m_triangulatedPoly = aParent->GetFilledPolysList( aLayer );
295 SetLayers( aLayer );
296 }
void SetLayers(const LAYER_RANGE &aLayers)
Set the layers spanned by the item to aLayers.
CN_ITEM(BOARD_CONNECTED_ITEM *aParent, bool aCanChangeNet, int aAnchorCount=2)
std::shared_ptr< SHAPE_POLY_SET > m_triangulatedPoly
PCB_LAYER_ID m_layer
const std::shared_ptr< SHAPE_POLY_SET > & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition: zone.h:602

References ZONE::GetFilledPolysList(), m_triangulatedPoly, and CN_ITEM::SetLayers().

Member Function Documentation

◆ AddAnchor()

std::shared_ptr< CN_ANCHOR > CN_ITEM::AddAnchor ( const VECTOR2I aPos)
inlineinherited

Definition at line 182 of file connectivity_items.h.

183 {
184 m_anchors.emplace_back( std::make_shared<CN_ANCHOR>( aPos, this ) );
185 return m_anchors.at( m_anchors.size() - 1 );
186 }
std::vector< std::shared_ptr< CN_ANCHOR > > 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 90 of file connectivity_items.cpp.

91{
92 if( !Valid() )
93 return 0;
94
95 const ZONE* zone = static_cast<const ZONE*>( Parent() );
96
97 return zone->GetFilledPolysList( m_layer )->COutline( m_subpolyIndex ).PointCount() ? 1 : 0;
98}
bool Valid() const
BOARD_CONNECTED_ITEM * Parent() const
Handle a list of polygons defining a copper zone.
Definition: zone.h:57

References ZONE::GetFilledPolysList(), m_layer, m_subpolyIndex, CN_ITEM::Parent(), and CN_ITEM::Valid().

◆ Anchors()

std::vector< std::shared_ptr< CN_ANCHOR > > & CN_ITEM::Anchors ( )
inlineinherited

Definition at line 188 of file connectivity_items.h.

188{ return m_anchors; }

References CN_ITEM::m_anchors.

Referenced by TRACKS_CLEANER::testTrackEndpointIsNode().

◆ BBox()

const BOX2I & CN_ITEM::BBox ( )
inlineinherited

Definition at line 219 of file connectivity_items.h.

220 {
221 if( m_dirty && m_valid )
223
224 return m_bbox;
225 }
BOARD_CONNECTED_ITEM * m_parent
BOX2I m_bbox
bounding box for the item
bool m_dirty
used to identify recently added item not yet scanned into the connectivity search
bool m_valid
used to identify garbage items (we use lazy removal)
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition: eda_item.cpp:74

References EDA_ITEM::GetBoundingBox(), CN_ITEM::m_bbox, CN_ITEM::m_dirty, CN_ITEM::m_parent, and CN_ITEM::m_valid.

Referenced by CN_VISITOR::checkZoneZoneConnection(), and CN_LIST::FindNearby().

◆ BuildRTree()

void CN_ZONE_LAYER::BuildRTree ( )
inline

Definition at line 298 of file connectivity_items.h.

299 {
300 for( unsigned int ii = 0; ii < m_triangulatedPoly->TriangulatedPolyCount(); ++ii )
301 {
302 const auto* triangleSet = m_triangulatedPoly->TriangulatedPolygon( ii );
303
304 if( triangleSet->GetSourceOutlineIndex() != m_subpolyIndex )
305 continue;
306
307 for( const SHAPE_POLY_SET::TRIANGULATED_POLYGON::TRI& tri : triangleSet->Triangles() )
308 {
309 BOX2I bbox = tri.BBox();
310 const int mmin[2] = { bbox.GetX(), bbox.GetY() };
311 const int mmax[2] = { bbox.GetRight(), bbox.GetBottom() };
312
313 m_rTree.Insert( mmin, mmax, &tri );
314 }
315 }
316 }
coord_type GetY() const
Definition: box2.h:181
coord_type GetX() const
Definition: box2.h:180
coord_type GetRight() const
Definition: box2.h:189
coord_type GetBottom() const
Definition: box2.h:190
RTree< const SHAPE *, int, 2, double > m_rTree

References BOX2< Vec >::GetBottom(), BOX2< Vec >::GetRight(), BOX2< Vec >::GetX(), BOX2< Vec >::GetY(), m_rTree, m_subpolyIndex, and m_triangulatedPoly.

Referenced by CN_LIST::Add().

◆ CanChangeNet()

bool CN_ITEM::CanChangeNet ( ) const
inlineinherited

Definition at line 235 of file connectivity_items.h.

235{ return m_canChangeNet; }
bool m_canChangeNet
can the net propagator modify the netcode?

References CN_ITEM::m_canChangeNet.

Referenced by CN_VISITOR::operator()().

◆ ClearConnections()

void CN_ITEM::ClearConnections ( )
inlineinherited

Definition at line 230 of file connectivity_items.h.

230{ m_connected.clear(); }
std::vector< CN_ITEM * > m_connected
list of physically touching items

References CN_ITEM::m_connected.

◆ ClosestPoint()

VECTOR2I CN_ZONE_LAYER::ClosestPoint ( const VECTOR2I  aPt)
inline

Definition at line 355 of file connectivity_items.h.

356 {
357 VECTOR2I closest;
358
359 m_triangulatedPoly->SquaredDistanceToPolygon( aPt, m_subpolyIndex, &closest );
360
361 return closest;
362 }

References m_subpolyIndex, and m_triangulatedPoly.

◆ Collide()

bool CN_ZONE_LAYER::Collide ( SHAPE aRefShape) const
inline

Definition at line 364 of file connectivity_items.h.

365 {
366 BOX2I bbox = aRefShape->BBox();
367 int min[2] = { bbox.GetX(), bbox.GetY() };
368 int max[2] = { bbox.GetRight(), bbox.GetBottom() };
369 bool collision = false;
370
371 auto visitor =
372 [&]( const SHAPE* aShape ) -> bool
373 {
374 if( aRefShape->Collide( aShape ) )
375 {
376 collision = true;
377 return false;
378 }
379
380 return true;
381 };
382
383 m_rTree.Search( min, max, visitor );
384
385 return collision;
386 }
An abstract shape on 2D plane.
Definition: shape.h:123
virtual bool Collide(const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const
Check if the boundary of shape (this) lies closer to the point aP than aClearance,...
Definition: shape.h:178
virtual const BOX2I BBox(int aClearance=0) const =0
Compute a bounding box of the shape, with a margin of aClearance a collision.

References SHAPE::BBox(), SHAPE::Collide(), BOX2< Vec >::GetBottom(), BOX2< Vec >::GetRight(), BOX2< Vec >::GetX(), BOX2< Vec >::GetY(), and m_rTree.

Referenced by CN_VISITOR::checkZoneItemConnection().

◆ Connect()

void CN_ITEM::Connect ( CN_ITEM b)
inlineinherited

Definition at line 237 of file connectivity_items.h.

238 {
239 std::lock_guard<std::mutex> lock( m_listLock );
240
241 auto i = std::lower_bound( m_connected.begin(), m_connected.end(), b );
242
243 if( i != m_connected.end() && *i == b )
244 return;
245
246 m_connected.insert( i, b );
247 }
std::mutex m_listLock
mutex protecting this item's connected_items set to

References CN_ITEM::m_connected, and CN_ITEM::m_listLock.

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

◆ ConnectedItems()

◆ ContainsPoint()

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

Definition at line 322 of file connectivity_items.h.

323 {
324 int min[2] = { p.x, p.y };
325 int max[2] = { p.x, p.y };
326 bool collision = false;
327
328 auto visitor =
329 [&]( const SHAPE* aShape ) -> bool
330 {
331 if( aShape->Collide( p ) )
332 {
333 collision = true;
334 return false;
335 }
336
337 return true;
338 };
339
340 m_rTree.Search( min, max, visitor );
341
342 return collision;
343 }

References m_rTree, VECTOR2< T >::x, and VECTOR2< T >::y.

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

◆ Dirty()

bool CN_ITEM::Dirty ( ) const
inlineinherited

Definition at line 194 of file connectivity_items.h.

194{ return m_dirty; }

References CN_ITEM::m_dirty.

Referenced by CN_VISITOR::operator()().

◆ Dump()

void CN_ITEM::Dump ( )
inherited

Definition at line 78 of file connectivity_items.cpp.

79{
80 wxLogDebug(" valid: %d, connected: \n", !!Valid());
81
82 for( CN_ITEM* i : m_connected )
83 {
84 PCB_TRACK* t = static_cast<PCB_TRACK*>( i->Parent() );
85 wxLogDebug( wxT( " - %p %d\n" ), t, t->Type() );
86 }
87}
CN_ITEM represents a BOARD_CONNETED_ITEM in the connectivity system (ie: a pad, track/arc/via,...
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97

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

102{
103 if( !Valid() )
104 return VECTOR2I();
105
106 const ZONE* zone = static_cast<const ZONE*>( Parent() );
107
108 return zone->GetFilledPolysList( m_layer )->COutline( m_subpolyIndex ).CPoint( 0 );
109}
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618

References ZONE::GetFilledPolysList(), m_layer, m_subpolyIndex, CN_ITEM::Parent(), and CN_ITEM::Valid().

◆ GetAnchorItem()

std::shared_ptr< CN_ANCHOR > CN_ITEM::GetAnchorItem ( int  n) const
inlineinherited

Definition at line 255 of file connectivity_items.h.

255{ return m_anchors[n]; }

References CN_ITEM::m_anchors.

◆ GetAnchorItemCount()

int CN_ITEM::GetAnchorItemCount ( ) const
inlineinherited

Definition at line 254 of file connectivity_items.h.

254{ return m_anchors.size(); }

References CN_ITEM::m_anchors.

◆ GetLayer() [1/2]

PCB_LAYER_ID CN_ZONE_LAYER::GetLayer ( )
inline

Definition at line 345 of file connectivity_items.h.

345{ return m_layer; }

References m_layer.

◆ GetLayer() [2/2]

PCB_LAYER_ID CN_ZONE_LAYER::GetLayer ( ) const
inline

Definition at line 320 of file connectivity_items.h.

320{ return m_layer; }

References m_layer.

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

◆ GetOutline()

const SHAPE_LINE_CHAIN & CN_ZONE_LAYER::GetOutline ( ) const
inline

Definition at line 350 of file connectivity_items.h.

351 {
352 return m_triangulatedPoly->Outline( m_subpolyIndex );
353 }

References m_subpolyIndex, and m_triangulatedPoly.

Referenced by RN_NET::optimizeRNEdges().

◆ Layer()

virtual int CN_ITEM::Layer ( ) const
inlinevirtualinherited

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

Definition at line 214 of file connectivity_items.h.

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

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

Referenced by RN_NET::optimizeRNEdges().

◆ Layers()

const LAYER_RANGE & CN_ITEM::Layers ( ) const
inlineinherited

Return the contiguous set of layers spanned by the item.

Definition at line 209 of file connectivity_items.h.

209{ 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()

int CN_ITEM::Net ( ) const
inlineinherited

◆ 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(); /* increment in loop */ )
115 {
116 if( !(*it)->Valid() )
117 it = m_connected.erase( it );
118 else
119 ++it;
120 }
121}

References CN_ITEM::m_connected.

◆ SetDirty()

void CN_ITEM::SetDirty ( bool  aDirty)
inlineinherited

Definition at line 193 of file connectivity_items.h.

193{ m_dirty = aDirty; }

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

204{ m_layers = LAYER_RANGE( aLayer, aLayer ); }
Represent a contiguous set of PCB layers.
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

Set the layers spanned by the item to aLayers.

Definition at line 199 of file connectivity_items.h.

199{ m_layers = aLayers; }

References CN_ITEM::m_layers.

Referenced by CN_LIST::Add(), and CN_ZONE_LAYER().

◆ SetValid()

void CN_ITEM::SetValid ( bool  aValid)
inlineinherited

Definition at line 190 of file connectivity_items.h.

190{ m_valid = aValid; }

References CN_ITEM::m_valid.

◆ SetVisited()

void CN_ITEM::SetVisited ( bool  aVisited)
inlineinherited

Definition at line 232 of file connectivity_items.h.

232{ 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

◆ Valid()

◆ Visited()

bool CN_ITEM::Visited ( ) const
inlineinherited

Definition at line 233 of file connectivity_items.h.

233{ return m_visited; }

References CN_ITEM::m_visited.

Member Data Documentation

◆ m_anchors

std::vector<std::shared_ptr<CN_ANCHOR> > CN_ITEM::m_anchors
privateinherited

◆ m_bbox

BOX2I CN_ITEM::m_bbox
protectedinherited

bounding box for the item

Definition at line 266 of file connectivity_items.h.

Referenced by CN_ITEM::BBox().

◆ m_canChangeNet

bool CN_ITEM::m_canChangeNet
privateinherited

can the net propagator modify the netcode?

Definition at line 274 of file connectivity_items.h.

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

◆ m_connected

std::vector<CN_ITEM*> CN_ITEM::m_connected
privateinherited

◆ m_dirty

bool CN_ITEM::m_dirty
protectedinherited

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

Definition at line 263 of file connectivity_items.h.

Referenced by CN_ITEM::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 390 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 265 of file connectivity_items.h.

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

◆ m_listLock

std::mutex CN_ITEM::m_listLock
privateinherited

mutex protecting this item's connected_items set to

Definition at line 279 of file connectivity_items.h.

Referenced by CN_ITEM::Connect().

◆ m_parent

◆ m_rTree

RTree<const SHAPE*, int, 2, double> CN_ZONE_LAYER::m_rTree
private

Definition at line 392 of file connectivity_items.h.

Referenced by BuildRTree(), Collide(), and ContainsPoint().

◆ m_subpolyIndex

int CN_ZONE_LAYER::m_subpolyIndex
private

◆ m_triangulatedPoly

std::shared_ptr<SHAPE_POLY_SET> CN_ZONE_LAYER::m_triangulatedPoly
private

Definition at line 391 of file connectivity_items.h.

Referenced by BuildRTree(), ClosestPoint(), CN_ZONE_LAYER(), and GetOutline().

◆ m_valid

bool CN_ITEM::m_valid
privateinherited

used to identify garbage items (we use lazy removal)

Definition at line 277 of file connectivity_items.h.

Referenced by CN_ITEM::AnchorCount(), CN_ITEM::BBox(), CN_ITEM::CN_ITEM(), CN_ITEM::GetAnchor(), CN_ITEM::Net(), CN_ITEM::SetValid(), and CN_ITEM::Valid().

◆ m_visited

bool CN_ITEM::m_visited
privateinherited

visited flag for the BFS scan

Definition at line 276 of file connectivity_items.h.

Referenced by CN_ITEM::CN_ITEM(), CN_ITEM::SetVisited(), and CN_ITEM::Visited().


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