specctra export: fix handling of multi-layer zones.

(from master branch)
This commit is contained in:
jean-pierre charras 2023-03-07 15:45:28 +01:00
parent ee0ba17c03
commit 411c9707ee
1 changed files with 89 additions and 77 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2007-2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2007-2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2015-2022 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2015-2023 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -1226,9 +1226,20 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
continue; continue;
// Currently, we export only copper layers // Currently, we export only copper layers
if( ! IsCopperLayer( zone->GetLayer() ) ) if( ! zone->IsOnCopperLayer() )
continue; continue;
// Now, build zone polygon on each copper layer where the zone
// is living (zones can live on many copper layers)
const int copperCount = aBoard->GetCopperLayerCount();
for( int layer = 0; layer < copperCount; layer++ )
{
if( layer == copperCount-1 )
layer = B_Cu;
if( !zone->IsOnLayer( PCB_LAYER_ID( layer ) ) )
continue;
COPPER_PLANE* plane = new COPPER_PLANE( m_pcb->structure ); COPPER_PLANE* plane = new COPPER_PLANE( m_pcb->structure );
m_pcb->structure->planes.push_back( plane ); m_pcb->structure->planes.push_back( plane );
@ -1256,7 +1267,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
plane->name = no_net->net_id; plane->name = no_net->net_id;
} }
mainPolygon->layer_id = m_layerIds[ m_kicadLayer2pcb[ zone->GetLayer() ] ]; mainPolygon->layer_id = m_layerIds[ m_kicadLayer2pcb[ layer ] ];
// Handle the main outlines // Handle the main outlines
SHAPE_POLY_SET::ITERATOR iterator; SHAPE_POLY_SET::ITERATOR iterator;
@ -1300,7 +1311,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
cutout = new PATH( window, T_polygon ); cutout = new PATH( window, T_polygon );
window->SetShape( cutout ); window->SetShape( cutout );
cutout->layer_id = m_layerIds[ m_kicadLayer2pcb[ zone->GetLayer() ] ]; cutout->layer_id = m_layerIds[ m_kicadLayer2pcb[ layer ] ];
} }
// If the point in this iteration is the last of the contour, the next iteration // If the point in this iteration is the last of the contour, the next iteration
@ -1324,6 +1335,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
if( iterator.IsEndContour() ) if( iterator.IsEndContour() )
cutout->AppendPoint( mapPt( startpoint ) ); cutout->AppendPoint( mapPt( startpoint ) );
} }
} // end build zones by layer
} }
} }
@ -1409,7 +1421,7 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard )
cutout = new PATH( window, T_polygon ); cutout = new PATH( window, T_polygon );
window->SetShape( cutout ); window->SetShape( cutout );
cutout->layer_id = m_layerIds[ m_kicadLayer2pcb[ zone->GetLayer() ] ]; cutout->layer_id = m_layerIds[ m_kicadLayer2pcb[ layer ] ];
} }
isStartContour = iterator.IsEndContour(); isStartContour = iterator.IsEndContour();