From 375a7303c52a319d3ce41b5f0f02f7252ae5f23c Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 23 Mar 2022 20:50:29 +0100 Subject: [PATCH] Gerbview: Fix incorrect rendering of aperture macros combining polygons. A aperture macro can have polygons with holes, and/or many polygons. When combining polygons holes can be created. So ensure the resulting polygon is fractured before drawing it. From Master branch Fixes #11218 https://gitlab.com/kicad/code/kicad/issues/11218 --- gerbview/am_primitive.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/gerbview/am_primitive.cpp b/gerbview/am_primitive.cpp index 912a31d3cd..4993819dd0 100644 --- a/gerbview/am_primitive.cpp +++ b/gerbview/am_primitive.cpp @@ -814,7 +814,6 @@ SHAPE_POLY_SET* APERTURE_MACRO::GetApertureMacroShape( const GERBER_DRAW_ITEM* a const wxPoint& aShapePos ) { SHAPE_POLY_SET holeBuffer; - bool hasHole = false; m_shape.RemoveAllContours(); @@ -836,18 +835,17 @@ SHAPE_POLY_SET* APERTURE_MACRO::GetApertureMacroShape( const GERBER_DRAW_ITEM* a { m_shape.BooleanSubtract( holeBuffer, SHAPE_POLY_SET::PM_FAST ); holeBuffer.RemoveAllContours(); - hasHole = true; - } + } } } // Merge and cleanup basic shape polygons m_shape.Simplify( SHAPE_POLY_SET::PM_FAST ); - // If a hole is defined inside a polygon, we must fracture the polygon - // to be able to drawn it (i.e link holes by overlapping edges) - if( hasHole ) - m_shape.Fracture( SHAPE_POLY_SET::PM_FAST ); + // A hole can be is defined inside a polygon, or the polygons themselve can create + // a hole when merged, so we must fracture the polygon to be able to drawn it + // (i.e link holes by overlapping edges) + m_shape.Fracture( SHAPE_POLY_SET::PM_FAST ); m_boundingBox = EDA_RECT( wxPoint( 0, 0 ), wxSize( 1, 1 ) ); auto bb = m_shape.BBox();