Altium PCB import: avoid integer overflows when rotating rectangular fills.

Fixes artifacts seen in https://gitlab.com/kicad/code/kicad/-/issues/18156

(cherry picked from commit 3ea314cb9f)
This commit is contained in:
Alex Shvartzkop 2024-06-10 01:00:46 +03:00
parent ca54eb422b
commit 43dab2a8b5
1 changed files with 8 additions and 6 deletions

View File

@ -4109,8 +4109,8 @@ void ALTIUM_PCB::ConvertFills6ToBoardItem( const AFILL6& aElem )
if( aElem.rotation != 0. )
{
VECTOR2I center( ( aElem.pos1.x + aElem.pos2.x ) / 2,
( aElem.pos1.y + aElem.pos2.y ) / 2 );
VECTOR2I center( aElem.pos1.x / 2 + aElem.pos2.x / 2,
aElem.pos1.y / 2 + aElem.pos2.y / 2 );
shape.Rotate( center, EDA_ANGLE( aElem.rotation, DEGREES_T ) );
}
@ -4140,8 +4140,8 @@ void ALTIUM_PCB::ConvertFills6ToFootprintItem( FOOTPRINT* aFootprint, const AFIL
if( aElem.rotation != 0. )
{
VECTOR2I center( ( aElem.pos1.x + aElem.pos2.x ) / 2,
( aElem.pos1.y + aElem.pos2.y ) / 2 );
VECTOR2I center( aElem.pos1.x / 2 + aElem.pos2.x / 2,
aElem.pos1.y / 2 + aElem.pos2.y / 2 );
shape.Rotate( center, EDA_ANGLE( aElem.rotation, DEGREES_T ) );
}
@ -4182,7 +4182,8 @@ void ALTIUM_PCB::ConvertFills6ToBoardItemOnLayer( const AFILL6& aElem, PCB_LAYER
if( aElem.rotation != 0. )
{
// TODO: Do we need SHAPE_T::POLY for non 90° rotations?
VECTOR2I center( ( aElem.pos1.x + aElem.pos2.x ) / 2, ( aElem.pos1.y + aElem.pos2.y ) / 2 );
VECTOR2I center( aElem.pos1.x / 2 + aElem.pos2.x / 2,
aElem.pos1.y / 2 + aElem.pos2.y / 2 );
fill->Rotate( center, EDA_ANGLE( aElem.rotation, DEGREES_T ) );
}
@ -4205,7 +4206,8 @@ void ALTIUM_PCB::ConvertFills6ToFootprintItemOnLayer( FOOTPRINT* aFootprint, con
if( aElem.rotation != 0. )
{
// TODO: Do we need SHAPE_T::POLY for non 90° rotations?
VECTOR2I center( ( aElem.pos1.x + aElem.pos2.x ) / 2, ( aElem.pos1.y + aElem.pos2.y ) / 2 );
VECTOR2I center( aElem.pos1.x / 2 + aElem.pos2.x / 2,
aElem.pos1.y / 2 + aElem.pos2.y / 2 );
fill->Rotate( center, EDA_ANGLE( aElem.rotation, DEGREES_T ) );
}