From 9ca9d7120a261fe32d571137af5bedd9d4d236f4 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 18 Feb 2025 11:53:34 +0000 Subject: [PATCH] Cleanup. --- pcbnew/pad.cpp | 13 ++++++------- pcbnew/pcb_track.cpp | 33 +++++++++++++++++++++------------ pcbnew/zone_filler.cpp | 19 +++++++++++-------- 3 files changed, 38 insertions(+), 27 deletions(-) diff --git a/pcbnew/pad.cpp b/pcbnew/pad.cpp index 2c1faeb2b1..b3c32e5a25 100644 --- a/pcbnew/pad.cpp +++ b/pcbnew/pad.cpp @@ -393,12 +393,7 @@ bool PAD::FlashLayer( int aLayer, bool aOnlyCheckIfPermitted ) const if( const BOARD* board = GetBoard() ) { - // Must be static to keep from raising its ugly head in performance profiles - static std::initializer_list types = { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T, - PCB_PAD_T }; - - if( auto it = m_zoneLayerOverrides.find( static_cast( aLayer ) ); - it != m_zoneLayerOverrides.end() && it->second == ZLO_FORCE_FLASHED ) + if( GetZoneLayerOverride( layer ) == ZLO_FORCE_FLASHED ) { return true; } @@ -408,7 +403,11 @@ bool PAD::FlashLayer( int aLayer, bool aOnlyCheckIfPermitted ) const } else { - return board->GetConnectivity()->IsConnectedOnLayer( this, aLayer, types ); + // Must be static to keep from raising its ugly head in performance profiles + static std::initializer_list nonZoneTypes = { PCB_TRACE_T, PCB_ARC_T, + PCB_VIA_T, PCB_PAD_T }; + + return board->GetConnectivity()->IsConnectedOnLayer( this, aLayer, nonZoneTypes ); } } } diff --git a/pcbnew/pcb_track.cpp b/pcbnew/pcb_track.cpp index 324ce8d427..e54127b81b 100644 --- a/pcbnew/pcb_track.cpp +++ b/pcbnew/pcb_track.cpp @@ -1229,14 +1229,15 @@ bool PCB_VIA::FlashLayer( int aLayer ) const return true; const BOARD* board = GetBoard(); + PCB_LAYER_ID layer = static_cast( aLayer ); if( !board ) return true; - if( !IsOnLayer( static_cast( aLayer ) ) ) + if( !IsOnLayer( layer ) ) return false; - if( !IsCopperLayer( aLayer ) ) + if( !IsCopperLayer( layer ) ) return true; switch( Padstack().UnconnectedLayerMode() ) @@ -1246,7 +1247,7 @@ bool PCB_VIA::FlashLayer( int aLayer ) const case PADSTACK::UNCONNECTED_LAYER_MODE::REMOVE_EXCEPT_START_AND_END: { - if( aLayer == Padstack().Drill().start || aLayer == Padstack().Drill().end ) + if( layer == Padstack().Drill().start || layer == Padstack().Drill().end ) return true; // Check for removal below @@ -1258,14 +1259,18 @@ bool PCB_VIA::FlashLayer( int aLayer ) const break; } - // Must be static to keep from raising its ugly head in performance profiles - static std::initializer_list connectedTypes = { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T, - PCB_PAD_T }; - - if( GetZoneLayerOverride( static_cast( aLayer ) ) == ZLO_FORCE_FLASHED ) + if( GetZoneLayerOverride( layer ) == ZLO_FORCE_FLASHED ) + { return true; + } else - return board->GetConnectivity()->IsConnectedOnLayer( this, static_cast( aLayer ), connectedTypes ); + { + // Must be static to keep from raising its ugly head in performance profiles + static std::initializer_list nonZoneTypes = { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T, + PCB_PAD_T }; + + return board->GetConnectivity()->IsConnectedOnLayer( this, layer, nonZoneTypes ); + } } @@ -1299,17 +1304,21 @@ void PCB_VIA::GetOutermostConnectedLayers( PCB_LAYER_ID* aTopmost, *aTopmost = UNDEFINED_LAYER; *aBottommost = UNDEFINED_LAYER; - static std::initializer_list connectedTypes = { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T, - PCB_PAD_T }; + static std::initializer_list nonZoneTypes = { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T, + PCB_PAD_T }; for( int layer = TopLayer(); layer <= BottomLayer(); ++layer ) { bool connected = false; if( GetZoneLayerOverride( static_cast( layer ) ) == ZLO_FORCE_FLASHED ) + { connected = true; - else if( GetBoard()->GetConnectivity()->IsConnectedOnLayer( this, layer, connectedTypes ) ) + } + else if( GetBoard()->GetConnectivity()->IsConnectedOnLayer( this, layer, nonZoneTypes ) ) + { connected = true; + } if( connected ) { diff --git a/pcbnew/zone_filler.cpp b/pcbnew/zone_filler.cpp index acfefa0316..790854bf7d 100644 --- a/pcbnew/zone_filler.cpp +++ b/pcbnew/zone_filler.cpp @@ -358,6 +358,8 @@ bool ZONE_FILLER::Fill( const std::vector& aZones, bool aCheck, wxWindow* }; // Determine state of conditional via flashing + // This is now done completely deterministically prior to filling due to the pathological + // case presented in https://gitlab.com/kicad/code/kicad/-/issues/12964. for( PCB_TRACK* track : m_board->Tracks() ) { if( track->Type() == PCB_VIA_T ) @@ -371,15 +373,15 @@ bool ZONE_FILLER::Fill( const std::vector& aZones, bool aCheck, wxWindow* BOX2I bbox = via->GetBoundingBox(); VECTOR2I center = via->GetPosition(); - int testRadius = via->GetDrillValue() / 2 + 1; - unsigned netcode = via->GetNetCode(); + int holeRadius = via->GetDrillValue() / 2 + 1; + int netcode = via->GetNetCode(); LSET layers = via->GetLayerSet() & boardCuMask; // Checking if the via hole touches the zone outline auto viaTestFn = [&]( const ZONE* aZone ) -> bool { - return aZone->Outline()->Contains( center, -1, testRadius ); + return aZone->Outline()->Contains( center, -1, holeRadius ); }; for( PCB_LAYER_ID layer : layers.Seq() ) @@ -416,13 +418,14 @@ bool ZONE_FILLER::Fill( const std::vector& aZones, bool aCheck, wxWindow* BOX2I bbox = pad->GetBoundingBox(); VECTOR2I center = pad->GetPosition(); - unsigned netcode = pad->GetNetCode(); + int netcode = pad->GetNetCode(); LSET layers = pad->GetLayerSet() & boardCuMask; - auto padTestFn = [&]( const ZONE* aZone ) -> bool - { - return aZone->Outline()->Contains( center ); - }; + auto padTestFn = + [&]( const ZONE* aZone ) -> bool + { + return aZone->Outline()->Contains( center ); + }; for( PCB_LAYER_ID layer : layers.Seq() ) {