Fix rounding errors in gerber files

The userToDeviceCoordinates helper returns a VECTOR2D
Converting it to VECTOR2I back and forth generates rounding errors
Also is a waste of time
This commit is contained in:
Salvador E. Tropea 2023-02-28 09:15:31 -03:00 committed by jean-pierre charras
parent 8a34f91172
commit 4213bb3a62
1 changed files with 5 additions and 6 deletions

View File

@ -154,7 +154,6 @@ void GERBER_PLOTTER::SetGerberCoordinatesFormat( int aResolution, bool aUseInche
void GERBER_PLOTTER::emitDcode( const VECTOR2D& pt, int dcode )
{
fprintf( m_outputFile, "X%dY%dD%02d*\n", KiROUND( pt.x ), KiROUND( pt.y ), dcode );
}
@ -1322,7 +1321,7 @@ void GERBER_PLOTTER::FlashPadOval( const VECTOR2I& aPos, const VECTOR2I& aSize,
if( orient.IsCardinal90() )
std::swap( size.x, size.y );
VECTOR2I pos_device = userToDeviceCoordinates( aPos );
VECTOR2D pos_device = userToDeviceCoordinates( aPos );
int aperture_attrib = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
selectAperture( size, 0, ANGLE_0, APERTURE::AT_OVAL, aperture_attrib );
@ -1353,7 +1352,7 @@ void GERBER_PLOTTER::FlashPadOval( const VECTOR2I& aPos, const VECTOR2I& aSize,
orient -= ANGLE_180;
}
VECTOR2I pos_device = userToDeviceCoordinates( aPos );
VECTOR2D pos_device = userToDeviceCoordinates( aPos );
int aperture_attrib = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
selectAperture( size, 0, orient, APERTURE::AM_ROTATED_OVAL, aperture_attrib );
@ -1416,7 +1415,7 @@ void GERBER_PLOTTER::FlashPadRect( const VECTOR2I& pos, const VECTOR2I& aSize,
}
else
{
VECTOR2I pos_device = userToDeviceCoordinates( pos );
VECTOR2D pos_device = userToDeviceCoordinates( pos );
int aperture_attrib = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
selectAperture( size, 0, ANGLE_0, APERTURE::AT_RECT, aperture_attrib );
@ -1433,7 +1432,7 @@ void GERBER_PLOTTER::FlashPadRect( const VECTOR2I& pos, const VECTOR2I& aSize,
{
m_hasApertureRotRect = true;
VECTOR2I pos_device = userToDeviceCoordinates( pos );
VECTOR2D pos_device = userToDeviceCoordinates( pos );
int aperture_attrib = gbr_metadata ? gbr_metadata->GetApertureAttrib() : 0;
selectAperture( size, 0, aOrient, APERTURE::AM_ROT_RECT, aperture_attrib );
@ -1755,7 +1754,7 @@ void GERBER_PLOTTER::FlashPadChamferRoundRect( const VECTOR2I& aShapePos, const
if( aData )
gbr_metadata = *static_cast<GBR_METADATA*>( aData );
VECTOR2I pos_device = userToDeviceCoordinates( aShapePos );
VECTOR2D pos_device = userToDeviceCoordinates( aShapePos );
SHAPE_POLY_SET outline;
std::vector<VECTOR2I> cornerList;