PNS: Apply co-linear seg merging to drag operations
This commit is contained in:
parent
1c431d9929
commit
49a91414d7
|
@ -402,9 +402,12 @@ void DRAGGER::optimizeAndUpdateDraggedLine( LINE& aDragged, const LINE& aOrig, c
|
|||
|
||||
OPTIMIZER optimizer( m_lastNode );
|
||||
|
||||
optimizer.SetEffortLevel( OPTIMIZER::MERGE_SEGMENTS |
|
||||
OPTIMIZER::KEEP_TOPOLOGY |
|
||||
OPTIMIZER::RESTRICT_AREA );
|
||||
int effort = OPTIMIZER::MERGE_SEGMENTS | OPTIMIZER::KEEP_TOPOLOGY | OPTIMIZER::RESTRICT_AREA;
|
||||
|
||||
if( Settings().SmoothDraggedSegments() )
|
||||
effort |= OPTIMIZER::MERGE_COLINEAR;
|
||||
|
||||
optimizer.SetEffortLevel( effort );
|
||||
|
||||
OPT_BOX2I affectedArea = aDragged.ChangedArea( &aOrig );
|
||||
VECTOR2I anchor( aP );
|
||||
|
|
|
@ -963,8 +963,8 @@ const LINE NODE::AssembleLine( LINKED_ITEM* aSeg, int* aOriginSegmentIndex,
|
|||
const SHAPE_ARC* sa = static_cast<const SHAPE_ARC*>( arc->Shape() );
|
||||
|
||||
int nSegs = line.PointCount();
|
||||
VECTOR2I last = line.CPoint( -1 );
|
||||
ssize_t lastShape = line.CShapes()[nSegs - 1];
|
||||
VECTOR2I last = nSegs ? line.CPoint( -1 ) : VECTOR2I();
|
||||
ssize_t lastShape = nSegs ? line.CShapes()[nSegs - 1] : -1;
|
||||
|
||||
line.Append( arcReversed[i] ? sa->Reversed() : *sa );
|
||||
|
||||
|
|
|
@ -571,8 +571,16 @@ bool OPTIMIZER::mergeColinear( LINE* aLine )
|
|||
SEG s1 = line.CSegment( segIdx );
|
||||
SEG s2 = line.CSegment( segIdx + 1 );
|
||||
|
||||
if( shapes[segIdx] < 0 && shapes[segIdx + 1] < 0 && s1.Collinear( s2 ) )
|
||||
line.Replace( segIdx, segIdx + 1, s1.A );
|
||||
// Skip zero-length segs caused by abutting arcs
|
||||
if( s1.SquaredLength() == 0 || s2.SquaredLength() == 0 )
|
||||
continue;
|
||||
|
||||
if( s1.Collinear( s2 ) )
|
||||
{
|
||||
// We should not see a collinear vertex inside an arc
|
||||
wxASSERT( shapes[segIdx + 1] < 0 );
|
||||
line.Remove( segIdx + 1 );
|
||||
}
|
||||
}
|
||||
|
||||
return line.SegmentCount() < nSegs;
|
||||
|
|
Loading…
Reference in New Issue