Gerber plotter: fix incorrect handling of arcs in polygons.
From master branch. Fixes #11156 https://gitlab.com/kicad/code/kicad/issues/11156
This commit is contained in:
parent
dd55ffb75c
commit
cf4c403094
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
|
@ -842,18 +842,6 @@ void GERBER_PLOTTER::plotArc( const SHAPE_ARC& aArc, bool aPlotInRegion )
|
|||
wxPoint start( aArc.GetP0() );
|
||||
wxPoint end( aArc.GetP1() );
|
||||
wxPoint center( aArc.GetCenter() );
|
||||
double startAngle = aArc.GetStartAngle();
|
||||
double endAngle = aArc.GetEndAngle();
|
||||
|
||||
if( startAngle > endAngle )
|
||||
{
|
||||
if( endAngle < 0.0 )
|
||||
endAngle = NormalizeAnglePos( endAngle ) ;
|
||||
else
|
||||
{
|
||||
startAngle = NormalizeAnglePos( startAngle ) - 3600.0;
|
||||
}
|
||||
}
|
||||
|
||||
if( !aPlotInRegion )
|
||||
MoveTo( start);
|
||||
|
@ -861,14 +849,20 @@ void GERBER_PLOTTER::plotArc( const SHAPE_ARC& aArc, bool aPlotInRegion )
|
|||
LineTo( start );
|
||||
|
||||
DPOINT devEnd = userToDeviceCoordinates( end );
|
||||
DPOINT devCenter = userToDeviceCoordinates( center ) - userToDeviceCoordinates( start );
|
||||
DPOINT devCenter = userToDeviceCoordinates( center - start );
|
||||
VECTOR2I arcMidPoint = aArc.GetArcMid();
|
||||
|
||||
// We need to know if the arc is CW or CCW in device coordinates, so build this arc.
|
||||
SHAPE_ARC deviceArc( userToDeviceCoordinates( start ),
|
||||
userToDeviceCoordinates( wxPoint( arcMidPoint.x, arcMidPoint.y ) ),
|
||||
devEnd, 0 );
|
||||
|
||||
fprintf( m_outputFile, "G75*\n" ); // Multiquadrant (360 degrees) mode
|
||||
|
||||
if( startAngle > endAngle )
|
||||
fprintf( m_outputFile, "G03*\n" ); // Active circular interpolation, CCW
|
||||
else
|
||||
if( deviceArc.IsClockwise() )
|
||||
fprintf( m_outputFile, "G02*\n" ); // Active circular interpolation, CW
|
||||
else
|
||||
fprintf( m_outputFile, "G03*\n" ); // Active circular interpolation, CCW
|
||||
|
||||
fprintf( m_outputFile, "X%dY%dI%dJ%dD01*\n",
|
||||
KiROUND( devEnd.x ), KiROUND( devEnd.y ),
|
||||
|
|
Loading…
Reference in New Issue