Gerbview, export to pcbnew : export polygons as new DRAWSEGMENT polygonal shape.
It can creates issues on copper layers, but the only one other alternative is to ignore polygons in export, and this is worst.
This commit is contained in:
parent
5b8c35f64d
commit
fa39acfc2f
|
@ -72,7 +72,6 @@ public:
|
|||
|
||||
private:
|
||||
/**
|
||||
* Function export_non_copper_item
|
||||
* write a non copper line or arc to the board file.
|
||||
* @param aGbrItem = the Gerber item (line, arc) to export
|
||||
* @param aLayer = the technical layer to use
|
||||
|
@ -80,7 +79,13 @@ private:
|
|||
void export_non_copper_item( GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
|
||||
|
||||
/**
|
||||
* Function export_copper_item
|
||||
* write a non copper polygon item to the board file.
|
||||
* @param aGbrItem = the Gerber item (line, arc) to export
|
||||
* @param aLayer = the technical layer to use
|
||||
*/
|
||||
void writePcbPolygonItem( GERBER_DRAW_ITEM* aGbrItem, LAYER_NUM aLayer );
|
||||
|
||||
/**
|
||||
* write a track or via) to the board file.
|
||||
* @param aGbrItem = the Gerber item (line, arc, flashed) to export
|
||||
* @param aLayer = the copper layer to use
|
||||
|
@ -281,6 +286,12 @@ void GBR_TO_PCB_EXPORTER::export_non_copper_item( GERBER_DRAW_ITEM* aGbrItem, LA
|
|||
wxPoint seg_start = aGbrItem->m_Start;
|
||||
wxPoint seg_end = aGbrItem->m_End;
|
||||
|
||||
if( aGbrItem->m_Shape == GBR_POLYGON )
|
||||
{
|
||||
writePcbPolygonItem( aGbrItem, aLayer );
|
||||
return;
|
||||
}
|
||||
|
||||
if( aGbrItem->m_Shape == GBR_ARC )
|
||||
{
|
||||
double a = atan2( (double) ( aGbrItem->m_Start.y - aGbrItem->m_ArcCentre.y),
|
||||
|
@ -319,6 +330,12 @@ void GBR_TO_PCB_EXPORTER::export_copper_item( GERBER_DRAW_ITEM* aGbrItem, LAYER_
|
|||
export_segarc_copper_item( aGbrItem, aLayer );
|
||||
break;
|
||||
|
||||
case GBR_POLYGON:
|
||||
// Currently: Pcbnew does not really handle polygons on copper layers (no DRC test).
|
||||
// However, we can export them if the purpose of this export is to help recreate a board
|
||||
writePcbPolygonItem( aGbrItem, aLayer );
|
||||
break;
|
||||
|
||||
default:
|
||||
export_segline_copper_item( aGbrItem, aLayer );
|
||||
break;
|
||||
|
@ -504,3 +521,41 @@ 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;
|
||||
SHAPE_LINE_CHAIN& poly = polys.Outline( 0 );
|
||||
|
||||
#define MAX_COORD_CNT 4
|
||||
int jj = MAX_COORD_CNT;
|
||||
int cnt_max = poly.PointCount() -1;
|
||||
|
||||
// Do not generate last corner, if it is the same point as the first point:
|
||||
if( poly.Point( 0 ) == poly.Point( cnt_max ) )
|
||||
cnt_max--;
|
||||
|
||||
for( int ii = 0; ii <= cnt_max; ii++ )
|
||||
{
|
||||
if( --jj == 0 )
|
||||
{
|
||||
jj = MAX_COORD_CNT;
|
||||
fprintf( m_fp, "\n" );
|
||||
}
|
||||
|
||||
fprintf( m_fp, " (xy %s %s)",
|
||||
Double2Str( TO_PCB_UNIT( poly.Point( ii ).x ) ).c_str(),
|
||||
Double2Str( TO_PCB_UNIT( -poly.Point( ii ).y ) ).c_str() );
|
||||
}
|
||||
|
||||
fprintf( m_fp, ")" );
|
||||
|
||||
if( jj != MAX_COORD_CNT )
|
||||
fprintf( m_fp, "\n" );
|
||||
|
||||
fprintf( m_fp, "(layer %s) (width 0) )\n",
|
||||
TO_UTF8( GetPCBDefaultLayerName( aLayer ) ) );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue