From e26c912b86651b9c8062f529f2225b10de7a69f3 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 3 Feb 2021 11:56:15 +0000 Subject: [PATCH] Don't apply electrical clearance to non-copper zones. Also removes a very old (and somewhat confusing) comment. Fixes https://gitlab.com/kicad/code/kicad/issues/7404 --- pcbnew/zone.cpp | 21 ++++++++++++++------- pcbnew/zone_filler.cpp | 7 +------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/pcbnew/zone.cpp b/pcbnew/zone.cpp index 1f0a131cd2..a8c5618131 100644 --- a/pcbnew/zone.cpp +++ b/pcbnew/zone.cpp @@ -1165,12 +1165,19 @@ bool ZONE::BuildSmoothedPoly( SHAPE_POLY_SET& aSmoothedPoly, PCB_LAYER_ID aLayer if( GetNumCorners() <= 2 ) // malformed zone. polygon calculations will not like it ... return false; + int zoneClearance = m_ZoneClearance; + if( GetIsRuleArea() ) { // We like keepouts just the way they are.... aSmoothedPoly = *m_Poly; return true; } + else if( !IsOnCopperLayer() ) + { + // Non-copper zones don't have electrical clearances + zoneClearance = 0; + } BOARD* board = GetBoard(); int edgeClearance = 0; @@ -1229,21 +1236,21 @@ bool ZONE::BuildSmoothedPoly( SHAPE_POLY_SET& aSmoothedPoly, PCB_LAYER_ID aLayer for( ZONE* zone : interactingZones ) aSmoothedPoly.BooleanAdd( *zone->Outline(), SHAPE_POLY_SET::PM_FAST ); - if( !GetIsRuleArea() && aBoardOutline ) + if( aBoardOutline ) { - SHAPE_POLY_SET bufferedOutline = *aBoardOutline; - bufferedOutline.Deflate( std::max( m_ZoneClearance, edgeClearance ), 16 ); - aSmoothedPoly.BooleanIntersection( bufferedOutline, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE ); + SHAPE_POLY_SET poly = *aBoardOutline; + poly.Deflate( std::max( zoneClearance, edgeClearance ), 16 ); + aSmoothedPoly.BooleanIntersection( poly, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE ); } smooth( aSmoothedPoly ); if( aSmoothedPolyWithApron ) { - SHAPE_POLY_SET bufferedExtents = *maxExtents; - bufferedExtents.Inflate( m_ZoneMinThickness, 16 ); + SHAPE_POLY_SET poly = *maxExtents; + poly.Inflate( m_ZoneMinThickness, 16 ); *aSmoothedPolyWithApron = aSmoothedPoly; - aSmoothedPolyWithApron->BooleanIntersection( bufferedExtents, SHAPE_POLY_SET::PM_FAST ); + aSmoothedPolyWithApron->BooleanIntersection( poly, SHAPE_POLY_SET::PM_FAST ); } aSmoothedPoly.BooleanIntersection( *maxExtents, SHAPE_POLY_SET::PM_FAST ); diff --git a/pcbnew/zone_filler.cpp b/pcbnew/zone_filler.cpp index b0091c3966..03b3b95933 100644 --- a/pcbnew/zone_filler.cpp +++ b/pcbnew/zone_filler.cpp @@ -1193,11 +1193,6 @@ bool ZONE_FILLER::fillSingleZone( ZONE* aZone, PCB_LAYER_ID aLayer, SHAPE_POLY_S aLayer = F_Cu; } - /* - * convert outlines + holes to outlines without holes (adding extra segments if necessary) - * m_Poly data is expected normalized, i.e. NormalizeAreaOutlines was used after building - * this zone - */ if ( !aZone->BuildSmoothedPoly( maxExtents, aLayer, boardOutline, &smoothedPoly ) ) return false; @@ -1234,7 +1229,7 @@ bool ZONE_FILLER::fillSingleZone( ZONE* aZone, PCB_LAYER_ID aLayer, SHAPE_POLY_S } else if( half_min_width - epsilon > epsilon ) { - smoothedPoly.Deflate( -( half_min_width - epsilon ), numSegs ); + smoothedPoly.Inflate( half_min_width - epsilon, numSegs ); } aRawPolys = smoothedPoly;