Check for proper winding when creating an EDA_SHAPE

There is a defined order to arc points in the EDA_SHAPE.  When creating
the new object, we need to check that that order is preserved on
conversion
This commit is contained in:
Seth Hillbrand 2021-12-07 10:51:43 -08:00
parent 84cdc9701f
commit 42f63b679d
1 changed files with 16 additions and 0 deletions

View File

@ -492,6 +492,22 @@ void EDA_SHAPE::SetArcGeometry( const wxPoint& aStart, const wxPoint& aMid, cons
m_end = aEnd; m_end = aEnd;
m_arcCenter = CalcArcCenter( aStart, aMid, aEnd ); m_arcCenter = CalcArcCenter( aStart, aMid, aEnd );
m_endsSwapped = false; m_endsSwapped = false;
/**
* If the input winding doesn't match our internal winding, the calculated midpoint will end up
* on the other side of the arc. In this case, we need to flip the start/end points and flag this
* change for the system
*/
wxPoint new_mid = GetArcMid();
VECTOR2D dist( new_mid - aMid );
VECTOR2D dist2( new_mid - m_arcCenter );
if( dist.SquaredEuclideanNorm() > dist2.SquaredEuclideanNorm() )
{
std::swap( m_start, m_end );
m_endsSwapped = true;
}
} }