From ec93fb317127a0ad985949e4a386929c4e5170f5 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Thu, 20 Dec 2018 17:03:55 -0800 Subject: [PATCH] pcbnew: Fracture polygons before plotting While not technically allowed, overlapping polygons can be drawn in pcbnew. Gerber polygons are strictly simple, however, so we need to fracture prior to exporting to avoid invalid gerbers. --- pcbnew/plot_brditems_plotter.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index c1ba28b59c..45ed748f6e 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -792,9 +792,14 @@ void BRDITEMS_PLOTTER::PlotDrawSegment( DRAWSEGMENT* aSeg ) // Draw the polygon: only one polygon is expected // However we provide a multi polygon shape drawing // ( for the future or to show a non expected shape ) - for( int jj = 0; jj < aSeg->GetPolyShape().OutlineCount(); ++jj ) + // This must be simplified and fractured to prevent overlapping polygons + // from generating invalid Gerber files + auto tmpPoly = SHAPE_POLY_SET( aSeg->GetPolyShape() ); + tmpPoly.Fracture( SHAPE_POLY_SET::PM_FAST ); + + for( int jj = 0; jj < tmpPoly.OutlineCount(); ++jj ) { - SHAPE_LINE_CHAIN& poly = aSeg->GetPolyShape().Outline( jj ); + SHAPE_LINE_CHAIN& poly = tmpPoly.Outline( jj ); m_plotter->PlotPoly( poly, FILLED_SHAPE, thickness, &gbr_metadata ); } }