SHAPE_LINE_CHAIN::NextShape instead of explicitly calculating indices

Fixes https://gitlab.com/kicad/code/kicad/-/issues/8738
This commit is contained in:
Roberto Fernandez Bautista 2021-07-07 19:46:17 +01:00
parent a17862d646
commit cda26bd57b
1 changed files with 2 additions and 19 deletions

View File

@ -1084,29 +1084,12 @@ void LINE::ClipVertexRange( int aStart, int aEnd )
int numPoints = static_cast<int>( m_line.PointCount() );
for( int i = 0; i < m_line.PointCount(); i++ )
for( int i = 0; i >= 0 && i < m_line.PointCount(); i = m_line.NextShape( i ) )
{
if( i <= aStart )
firstLink = linkIdx;
//@todo RFB Should this be replaced by m_line.NextShape( i ); ?
if( m_line.IsPtOnArc( i ) )
{
// Account for "hidden segments" between two arcs
if( i > aStart && ( m_line.IsArcSegment( static_cast<size_t>( i ) - 1 ) ) )
linkIdx++;
arcIdx = m_line.ArcIndex(i);
// Skip over the rest of the arc vertices
while( i < numPoints && m_line.ArcIndex( i ) == arcIdx )
i++;
// Back up two vertices to restart at the segment coincident with the end of the arc
i -= 2;
}
if( i >= aEnd - 1 || linkIdx >= lastLink )
if( i == -1 || i >= aEnd - 1 || linkIdx >= lastLink )
{
lastLink = linkIdx;
break;