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.
This commit is contained in:
Seth Hillbrand 2018-12-20 17:03:55 -08:00
parent 1d230bbee9
commit ec93fb3171
1 changed files with 7 additions and 2 deletions

View File

@ -792,9 +792,14 @@ void BRDITEMS_PLOTTER::PlotDrawSegment( DRAWSEGMENT* aSeg )
// Draw the polygon: only one polygon is expected // Draw the polygon: only one polygon is expected
// However we provide a multi polygon shape drawing // However we provide a multi polygon shape drawing
// ( for the future or to show a non expected shape ) // ( 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 ); m_plotter->PlotPoly( poly, FILLED_SHAPE, thickness, &gbr_metadata );
} }
} }