Fix SHAPE_LINE_CHAIN::Slice when end is an arc followed by a point

Fixes https://gitlab.com/kicad/code/kicad/-/issues/9770
This commit is contained in:
Jon Evans 2021-11-25 10:05:27 -05:00
parent ade8fe4333
commit b4342d813b
3 changed files with 12 additions and 3 deletions

View File

@ -988,7 +988,7 @@ int SHAPE_LINE_CHAIN::NextShape( int aPointIndex, bool aForwards ) const
if( aPointIndex == lastIndex )
{
if( !m_closed )
if( !m_closed && arcIndex( aPointIndex ) == currentArcIdx )
return -1;
else
return lastIndex; // Segment between last point and the start

View File

@ -95,11 +95,11 @@ void MEANDER_PLACER_BASE::cutTunedLine( const SHAPE_LINE_CHAIN& aOrigin, const V
if( idx >= 0 )
{
const SEG& s = aOrigin.CSegment( idx );
cp += (s.B - s.A).Resize(2);
cp += ( s.B - s.A ).Resize( 2 );
}
else
{
cp += VECTOR2I (2, 5); // some arbitrary value that is not 45 degrees oriented
cp += VECTOR2I( 2, 5 ); // some arbitrary value that is not 45 degrees oriented
}
}

View File

@ -393,6 +393,15 @@ BOOST_AUTO_TEST_CASE( Slice )
BOOST_CHECK_EQUAL( sliceResult.GetPoint( 8 ), targetSegment.B );
BOOST_CHECK_EQUAL( sliceResult.GetPoint( 9 ), secondArc.GetP0() );
}
BOOST_TEST_CONTEXT( "Case 5: Chain ends in arc and point" )
{
SHAPE_LINE_CHAIN chainCopy = chain;
chainCopy.Append( VECTOR2I( 400000, 400000 ) );
SHAPE_LINE_CHAIN sliceResult = chainCopy.Slice( 11, -1 );
BOOST_CHECK_EQUAL( sliceResult.GetPoint( -1 ), VECTOR2I( 400000, 400000 ) );
}
}