From 619c340d929b50907044a6fd4d54c08cd4889f93 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 1 Nov 2022 13:19:33 +0000 Subject: [PATCH] Handle holes when building outlines for copper sliver checker. Fixes https://gitlab.com/kicad/code/kicad/issues/12797 --- .../drc/drc_test_provider_sliver_checker.cpp | 18 +++++++----------- pcbnew/zone.h | 9 ++++++++- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/pcbnew/drc/drc_test_provider_sliver_checker.cpp b/pcbnew/drc/drc_test_provider_sliver_checker.cpp index 086daf716d..bd43b003fd 100644 --- a/pcbnew/drc/drc_test_provider_sliver_checker.cpp +++ b/pcbnew/drc/drc_test_provider_sliver_checker.cpp @@ -111,11 +111,11 @@ bool DRC_TEST_PROVIDER_SLIVER_CHECKER::Run() std::vector layerPolys( layerCount ); - auto sliver_checker = - [&]( int aItem ) -> size_t + auto build_layer_polys = + [&]( int layerIdx ) -> size_t { - PCB_LAYER_ID layer = copperLayers[aItem]; - SHAPE_POLY_SET& poly = layerPolys[aItem]; + PCB_LAYER_ID layer = copperLayers[layerIdx]; + SHAPE_POLY_SET& poly = layerPolys[layerIdx]; if( m_drcEngine->IsCancelled() ) return 0; @@ -125,17 +125,13 @@ bool DRC_TEST_PROVIDER_SLIVER_CHECKER::Run() forEachGeometryItem( s_allBasicItems, LSET().set( layer ), [&]( BOARD_ITEM* item ) -> bool { - if( dynamic_cast( item) ) + if( ZONE* zone = dynamic_cast( item) ) { - ZONE* zone = static_cast( item ); - if( !zone->GetIsRuleArea() ) { fill = zone->GetFill( layer )->CloneDropTriangulation(); fill.Unfracture( SHAPE_POLY_SET::PM_FAST ); - - for( int jj = 0; jj < fill.OutlineCount(); ++jj ) - poly.AddOutline( fill.Outline( jj ) ); + poly.Append( fill ); // Report progress on board zones only. Everything else is // in the noise. @@ -173,7 +169,7 @@ bool DRC_TEST_PROVIDER_SLIVER_CHECKER::Run() returns.reserve( copperLayers.size() ); for( size_t ii = 0; ii < copperLayers.size(); ++ii ) - returns.emplace_back( tp.submit( sliver_checker, ii ) ); + returns.emplace_back( tp.submit( build_layer_polys, ii ) ); for( const std::future& ret : returns ) { diff --git a/pcbnew/zone.h b/pcbnew/zone.h index dbcb1dd9f4..9919a16bbd 100644 --- a/pcbnew/zone.h +++ b/pcbnew/zone.h @@ -236,7 +236,7 @@ public: return m_fillFlags.test( aLayer ); } - void SetFillFlag( PCB_LAYER_ID aLayer, bool aFlag ) { m_fillFlags.set( aLayer, aFlag); } + void SetFillFlag( PCB_LAYER_ID aLayer, bool aFlag ) { m_fillFlags.set( aLayer, aFlag ); } bool IsFilled() const { return m_isFilled; } void SetIsFilled( bool isFilled ) { m_isFilled = isFilled; } @@ -772,6 +772,13 @@ public: #if defined(DEBUG) virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); } + + void SetFillPoly( PCB_LAYER_ID aLayer, SHAPE_POLY_SET* aPoly ) + { + m_FilledPolysList[ aLayer ] = std::make_shared( *aPoly ); + SetFillFlag( aLayer, true ); + } + #endif virtual void SwapData( BOARD_ITEM* aImage ) override;