From 018f4531a5cde6f94ee12652cbe2c979550040b2 Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Sun, 13 Feb 2022 20:36:44 +0100 Subject: [PATCH] Fixes in the SVG import polygon postprocessing: - don't drop subsequent polys when a non-filled primitive is imported 'in between' - fix missing holes (also related to the interleaving of stroke and filled shapes, depending on the software that wrote the SVG file) Fixes: https://gitlab.com/kicad/code/kicad/-/issues/10813 --- pcbnew/import_gfx/graphics_importer_buffer.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pcbnew/import_gfx/graphics_importer_buffer.cpp b/pcbnew/import_gfx/graphics_importer_buffer.cpp index 9d2d395753..13b880b333 100644 --- a/pcbnew/import_gfx/graphics_importer_buffer.cpp +++ b/pcbnew/import_gfx/graphics_importer_buffer.cpp @@ -172,7 +172,7 @@ static void convertPolygon( std::list>& aShapes, void GRAPHICS_IMPORTER_BUFFER::PostprocessNestedPolygons() { - int curShapeIdx = 0; + int curShapeIdx = -1; int lastWidth = 1; std::list> newShapes; @@ -191,11 +191,14 @@ void GRAPHICS_IMPORTER_BUFFER::PostprocessNestedPolygons() lastWidth = poly->GetWidth(); int index = poly->GetParentShapeIndex(); + if( curShapeIdx < 0 ) + index = curShapeIdx; + if( index == curShapeIdx ) { polypaths.push_back( poly ); } - else if( index == curShapeIdx + 1 ) + else if( index >= curShapeIdx + 1 ) { convertPolygon( newShapes, polypaths, m_shapeFillRules[curShapeIdx], lastWidth ); curShapeIdx++;