CADSTAR PCB: Load 2-point polygons as line segments

Fixes asserts when loading design from https://gitlab.com/kicad/code/kicad/-/issues/12349
This commit is contained in:
Roberto Fernandez Bautista 2022-09-03 23:39:49 +02:00
parent 21b3753e9b
commit c961624d43
1 changed files with 20 additions and 6 deletions

View File

@ -2689,17 +2689,22 @@ void CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarShape( const SHAPE& aCadstarShape,
const VECTOR2I& aTransformCentre,
const bool& aMirrorInvert )
{
auto drawAsOutline = [&]()
{
drawCadstarVerticesAsShapes( aCadstarShape.Vertices, aKiCadLayer, aLineThickness,
aContainer, aCadstarGroupID, aMoveVector, aRotationAngle,
aScalingFactor, aTransformCentre, aMirrorInvert );
drawCadstarCutoutsAsShapes( aCadstarShape.Cutouts, aKiCadLayer, aLineThickness, aContainer,
aCadstarGroupID, aMoveVector, aRotationAngle, aScalingFactor,
aTransformCentre, aMirrorInvert );
};
switch( aCadstarShape.Type )
{
case SHAPE_TYPE::OPENSHAPE:
case SHAPE_TYPE::OUTLINE:
///TODO update this when Polygons in KiCad can be defined with no fill
drawCadstarVerticesAsShapes( aCadstarShape.Vertices, aKiCadLayer, aLineThickness,
aContainer, aCadstarGroupID, aMoveVector, aRotationAngle,
aScalingFactor, aTransformCentre, aMirrorInvert );
drawCadstarCutoutsAsShapes( aCadstarShape.Cutouts, aKiCadLayer, aLineThickness,
aContainer, aCadstarGroupID, aMoveVector, aRotationAngle,
aScalingFactor, aTransformCentre, aMirrorInvert );
drawAsOutline();
break;
case SHAPE_TYPE::HATCHED:
@ -2711,6 +2716,15 @@ void CADSTAR_PCB_ARCHIVE_LOADER::drawCadstarShape( const SHAPE& aCadstarShape,
case SHAPE_TYPE::SOLID:
{
// Special case solid shapes that are effectively a single line
if( aCadstarShape.Vertices.size() < 3
|| ( aCadstarShape.Vertices.size() == 3
&& aCadstarShape.Vertices.at( 0 ).End == aCadstarShape.Vertices.at( 2 ).End ) )
{
drawAsOutline();
break;
}
PCB_SHAPE* shape;
if( isFootprint( aContainer ) )