From 12fdeac31ce60d1078ed1646ec2644d3b71f982d Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sat, 2 Dec 2023 17:14:53 -0800 Subject: [PATCH] Re-implementation of 8b3ac316 Update GenCAD export to handle arbitrary outline Fixes https://gitlab.com/kicad/code/kicad/-/issues/15961 --- pcbnew/exporters/export_gencad.cpp | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/pcbnew/exporters/export_gencad.cpp b/pcbnew/exporters/export_gencad.cpp index dcde63d337..65498a998f 100644 --- a/pcbnew/exporters/export_gencad.cpp +++ b/pcbnew/exporters/export_gencad.cpp @@ -47,6 +47,7 @@ #include #include #include // LAST_PATH_TYPE +#include #include #include @@ -1140,21 +1141,15 @@ static void CreateBoardSection( FILE* aFile, BOARD* aPcb ) { fputs( "$BOARD\n", aFile ); - // Extract the board edges - for( BOARD_ITEM* drawing : aPcb->Drawings() ) - { - if( drawing->Type() == PCB_SHAPE_T ) - { - PCB_SHAPE* drawseg = static_cast( drawing ); + SHAPE_POLY_SET outline; + aPcb->GetBoardPolygonOutlines( outline ); - if( drawseg->GetLayer() == Edge_Cuts ) - { - // XXX GenCAD supports arc boundaries but I've seen nothing that reads them - fprintf( aFile, "LINE %g %g %g %g\n", - MapXTo( drawseg->GetStart().x ), MapYTo( drawseg->GetStart().y ), - MapXTo( drawseg->GetEnd().x ), MapYTo( drawseg->GetEnd().y ) ); - } - } + for( auto seg1 = outline.IterateSegmentsWithHoles(); seg1; seg1++ ) + { + SEG seg = *seg1; + fprintf( aFile, "LINE %g %g %g %g\n", + MapXTo( seg.A.x ), MapYTo( seg.A.y ), + MapXTo( seg.B.x ), MapYTo( seg.B.y ) ); } fputs( "$ENDBOARD\n\n", aFile );