From a5305aa2352cb4e511163cbc30d0ccf890396ef6 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 20 Feb 2022 23:49:02 +0000 Subject: [PATCH] A more discerning un-flashed-connectivity test. (cherry picked from commit aa2c8e9b0c579fd93b820a5684ccfc0528bd83c7) --- pcbnew/connectivity/connectivity_data.cpp | 25 +++++++++++++++++++++-- pcbnew/connectivity/connectivity_data.h | 2 +- pcbnew/pcb_track.cpp | 9 ++++---- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/pcbnew/connectivity/connectivity_data.cpp b/pcbnew/connectivity/connectivity_data.cpp index 9d195ea9b3..524cf8fc0b 100644 --- a/pcbnew/connectivity/connectivity_data.cpp +++ b/pcbnew/connectivity/connectivity_data.cpp @@ -35,6 +35,8 @@ #include #include +#include +#include #include #include #include @@ -378,7 +380,8 @@ void CONNECTIVITY_DATA::PropagateNets( BOARD_COMMIT* aCommit, PROPAGATE_MODE aMo bool CONNECTIVITY_DATA::IsConnectedOnLayer( const BOARD_CONNECTED_ITEM *aItem, int aLayer, - std::vector aTypes, bool aIgnoreNets ) const + std::vector aTypes, + bool aCheckOptionalFlashing ) const { CN_CONNECTIVITY_ALGO::ITEM_MAP_ENTRY &entry = m_connAlgo->ItemEntry( aItem ); @@ -397,10 +400,28 @@ bool CONNECTIVITY_DATA::IsConnectedOnLayer( const BOARD_CONNECTED_ITEM *aItem, i { if( connected->Valid() && connected->Layers().Overlaps( aLayer ) - && ( connected->Net() == aItem->GetNetCode() || aIgnoreNets ) && matchType( connected->Parent()->Type() ) ) { + if( connected->Net() == aItem->GetNetCode() ) + { return true; + } + else if( aCheckOptionalFlashing && aItem->Type() == PCB_PAD_T ) + { + const PAD* pad = static_cast( aItem ); + SHAPE_SEGMENT hole( *pad->GetEffectiveHoleShape() ); + PCB_LAYER_ID layer = ToLAYER_ID( aLayer ); + + return connected->Parent()->GetEffectiveShape( layer )->Collide( &hole ); + } + else if( aCheckOptionalFlashing && aItem->Type() == PCB_VIA_T ) + { + const PCB_VIA* via = static_cast( aItem ); + SHAPE_CIRCLE hole( via->GetCenter(), via->GetDrillValue() / 2 ); + PCB_LAYER_ID layer = ToLAYER_ID( aLayer ); + + return connected->Parent()->GetEffectiveShape( layer )->Collide( &hole ); + } } } } diff --git a/pcbnew/connectivity/connectivity_data.h b/pcbnew/connectivity/connectivity_data.h index 4095027667..bb0471e7bc 100644 --- a/pcbnew/connectivity/connectivity_data.h +++ b/pcbnew/connectivity/connectivity_data.h @@ -202,7 +202,7 @@ public: bool IsConnectedOnLayer( const BOARD_CONNECTED_ITEM* aItem, int aLayer, std::vector aTypes = {}, - bool aIgnoreNets = false ) const; + bool aCheckOptionalFlashing = false ) const; unsigned int GetNodeCount( int aNet = -1 ) const; diff --git a/pcbnew/pcb_track.cpp b/pcbnew/pcb_track.cpp index 8472993aaf..8479e201cc 100644 --- a/pcbnew/pcb_track.cpp +++ b/pcbnew/pcb_track.cpp @@ -492,9 +492,6 @@ bool PCB_VIA::FlashLayer( LSET aLayers ) const bool PCB_VIA::FlashLayer( int aLayer ) const { - std::vector types - { PCB_TRACE_T, PCB_ARC_T, PCB_PAD_T, PCB_ZONE_T, PCB_FP_ZONE_T }; - // Return the "normal" shape if the caller doesn't specify a particular layer if( aLayer == UNDEFINED_LAYER ) return true; @@ -513,7 +510,11 @@ bool PCB_VIA::FlashLayer( int aLayer ) const if( m_keepTopBottomLayer && ( aLayer == m_layer || aLayer == m_bottomLayer ) ) return true; - return board->GetConnectivity()->IsConnectedOnLayer( this, static_cast( aLayer ), types ); + // Must be static to keep from raising its ugly head in performance profiles + static std::vector connectedTypes = { PCB_TRACE_T, PCB_ARC_T, PCB_PAD_T, + PCB_ZONE_T, PCB_FP_ZONE_T }; + + return board->GetConnectivity()->IsConnectedOnLayer( this, aLayer, connectedTypes, true ); }