Patch Altium import of oddly constructed line segments.

Fixes https://gitlab.com/kicad/code/kicad/issues/8974
This commit is contained in:
Jeff Young 2021-09-11 13:38:59 +01:00
parent 3316f3998a
commit c736bd3fd0
1 changed files with 24 additions and 3 deletions

View File

@ -1063,18 +1063,39 @@ void SCH_ALTIUM_PLUGIN::ParseBezier( const std::map<wxString, wxString>& aProper
line->SetWidth( elem.lineWidth ); line->SetWidth( elem.lineWidth );
} }
else if( i + 3 == elem.points.size() )
{
// TODO: special case of a single line with an extra point?
// I haven't a clue what this is all about, but the sample document we have in
// https://gitlab.com/kicad/code/kicad/-/issues/8974 responds best by treating it
// as another single line special case.
LIB_POLYLINE* line = new LIB_POLYLINE( libSymbolIt->second );
libSymbolIt->second->AddDrawItem( line );
line->SetUnit( elem.ownerpartid );
for( size_t j = i; j < elem.points.size() && j < i + 2; j++ )
{
line->AddPoint( GetRelativePosition( elem.points.at( j ) + m_sheetOffset,
symbol ) );
}
line->SetWidth( elem.lineWidth );
}
else else
{ {
// Bezier always has maximum of 4 control points // Bezier must have exactly 4 control points
LIB_BEZIER* bezier = new LIB_BEZIER( libSymbolIt->second ); LIB_BEZIER* bezier = new LIB_BEZIER( libSymbolIt->second );
libSymbolIt->second->AddDrawItem( bezier ); libSymbolIt->second->AddDrawItem( bezier );
bezier->SetUnit( elem.ownerpartid ); bezier->SetUnit( elem.ownerpartid );
std::vector<wxPoint> pts;
for( size_t j = i; j < elem.points.size() && j < i + 4; j++ ) for( size_t j = i; j < elem.points.size() && j < i + 4; j++ )
{ {
bezier->AddPoint( GetRelativePosition( elem.points.at( j ) + m_sheetOffset, pts.push_back( GetRelativePosition( elem.points.at( j ) + m_sheetOffset,
symbol ) ); symbol ) );
} }
bezier->SetWidth( elem.lineWidth ); bezier->SetWidth( elem.lineWidth );