Gerbview,export to pcbnew: avoid exporting not valid polygons.

Gerber regions are exported as polygons (they are filled polygon).
The fix ensure the polygons are simple and valid.
Invalid polygons crash Pcbnew.

From master branch, commit 25504319.
This commit is contained in:
jean-pierre charras 2019-12-15 14:02:12 +01:00
parent 68d644fd28
commit bea2d42e8c
1 changed files with 12 additions and 2 deletions

View File

@ -536,11 +536,21 @@ void GBR_TO_PCB_EXPORTER::writePcbLineItem( bool aIsArc, wxPoint& aStart, wxPoin
void GBR_TO_PCB_EXPORTER::writePcbPolygonItem( GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer )
{
fprintf( m_fp, "(gr_poly (pts " );
SHAPE_POLY_SET polys = aGbrItem->m_Polygon;
// Cleanup the polygon
polys.Simplify( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
// Ensure the polygon is valid:
if( polys.OutlineCount() == 0 )
return;
polys.Fracture( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
SHAPE_LINE_CHAIN& poly = polys.Outline( 0 );
fprintf( m_fp, "(gr_poly (pts " );
#define MAX_COORD_CNT 4
int jj = MAX_COORD_CNT;
int cnt_max = poly.PointCount() -1;