From 8e1466a35a1c8173ead90f5475425412d34e8f8e Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Fri, 21 Jul 2023 08:02:21 +0500 Subject: [PATCH] Altium PCB import: import holes in non-Cu polygons. (cherry picked from commit ef66fe88ac0b39ebae705bd6502b2e413f3b6b89) --- pcbnew/plugins/altium/altium_parser_pcb.cpp | 25 ++++++++++----------- pcbnew/plugins/altium/altium_pcb.cpp | 16 ++++++++++++- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/pcbnew/plugins/altium/altium_parser_pcb.cpp b/pcbnew/plugins/altium/altium_parser_pcb.cpp index 9dcfb9dbe5..35ff48b95c 100644 --- a/pcbnew/plugins/altium/altium_parser_pcb.cpp +++ b/pcbnew/plugins/altium/altium_parser_pcb.cpp @@ -1055,6 +1055,9 @@ AREGION6::AREGION6( ALTIUM_PARSER& aReader, bool aExtendedVertices ) uint32_t num_outline_vertices = aReader.Read(); + if( aExtendedVertices ) + num_outline_vertices++; // Has a closing vertex + for( uint32_t i = 0; i < num_outline_vertices; i++ ) { if( aExtendedVertices ) @@ -1076,21 +1079,17 @@ AREGION6::AREGION6( ALTIUM_PARSER& aReader, bool aExtendedVertices ) } } - // TODO: for now we only support holes in regions where there are stored as double - if( !aExtendedVertices ) + holes.resize( holecount ); + for( uint16_t k = 0; k < holecount; k++ ) { - holes.resize( holecount ); - for( uint16_t k = 0; k < holecount; k++ ) - { - uint32_t num_hole_vertices = aReader.Read(); - holes.at( k ).reserve( num_hole_vertices ); + uint32_t num_hole_vertices = aReader.Read(); + holes.at( k ).reserve( num_hole_vertices ); - for( uint32_t i = 0; i < num_hole_vertices; i++ ) - { - int32_t x = ALTIUM_PARSER::ConvertToKicadUnit( aReader.Read() ); - int32_t y = ALTIUM_PARSER::ConvertToKicadUnit( -aReader.Read() ); - holes.at( k ).emplace_back( VECTOR2I( x, y ) ); - } + for( uint32_t i = 0; i < num_hole_vertices; i++ ) + { + int32_t x = ALTIUM_PARSER::ConvertToKicadUnit( aReader.Read() ); + int32_t y = ALTIUM_PARSER::ConvertToKicadUnit( -aReader.Read() ); + holes.at( k ).emplace_back( VECTOR2I( x, y ) ); } } diff --git a/pcbnew/plugins/altium/altium_pcb.cpp b/pcbnew/plugins/altium/altium_pcb.cpp index 05a4e00a6f..cea3bd1cf4 100644 --- a/pcbnew/plugins/altium/altium_pcb.cpp +++ b/pcbnew/plugins/altium/altium_pcb.cpp @@ -2035,9 +2035,23 @@ void ALTIUM_PCB::ConvertShapeBasedRegions6ToBoardItemOnLayer( const AREGION6& aE return; } + SHAPE_POLY_SET polySet; + polySet.AddOutline( linechain ); + + for( const std::vector& hole : aElem.holes ) + { + SHAPE_LINE_CHAIN hole_linechain; + HelperShapeLineChainFromAltiumVertices( hole_linechain, hole ); + + if( hole_linechain.PointCount() < 3 ) + continue; + + polySet.AddHole( hole_linechain ); + } + PCB_SHAPE* shape = new PCB_SHAPE( m_board, SHAPE_T::POLY ); - shape->SetPolyShape( linechain ); + shape->SetPolyShape( polySet ); shape->SetFilled( true ); shape->SetLayer( aLayer ); shape->SetStroke( STROKE_PARAMS( 0 ) );