PNS: Find origin segment correctly when arcs are present

Fixes https://gitlab.com/kicad/code/kicad/-/issues/8139
This commit is contained in:
Jon Evans 2021-04-07 20:28:30 -04:00
parent 677d7b0a60
commit 9432484394
2 changed files with 12 additions and 3 deletions

View File

@ -947,16 +947,25 @@ const LINE NODE::AssembleLine( LINKED_ITEM* aSeg, int* aOriginSegmentIndex,
const VECTOR2I& p = corners[i];
LINKED_ITEM* li = segs[i];
int nsegs = pl.Line().SegmentCount();
if( !li || li->Kind() != ITEM::ARC_T )
pl.Line().Append( p );
if( li && prev_seg != li )
{
int segIdxIncrement = 1;
if( li->Kind() == ITEM::ARC_T )
{
const ARC* arc = static_cast<const ARC*>( li );
const SHAPE_ARC* sa = static_cast<const SHAPE_ARC*>( arc->Shape() );
int nSegs = pl.Line().SegmentCount();
pl.Line().Append( arcReversed[i] ? sa->Reversed() : *sa );
segIdxIncrement = pl.Line().SegmentCount() - nSegs - 1;
}
pl.Link( li );
@ -968,7 +977,7 @@ const LINE NODE::AssembleLine( LINKED_ITEM* aSeg, int* aOriginSegmentIndex,
originSet = true;
}
n++;
n += segIdxIncrement;
}
prev_seg = li;