diff --git a/pcbnew/plugins/altium/altium_parser_pcb.cpp b/pcbnew/plugins/altium/altium_parser_pcb.cpp index b9d49e09e3..fbb7c2a082 100644 --- a/pcbnew/plugins/altium/altium_parser_pcb.cpp +++ b/pcbnew/plugins/altium/altium_parser_pcb.cpp @@ -1059,6 +1059,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 ) @@ -1080,21 +1083,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 e711592d27..db5fc47168 100644 --- a/pcbnew/plugins/altium/altium_pcb.cpp +++ b/pcbnew/plugins/altium/altium_pcb.cpp @@ -1993,9 +1993,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 ) );