Simplify to merge sequential, parallel segments

The Simplify() routine can take multiple segments that are in a single
line and merge them into a single segment, reducing the line complexity.
This commit is contained in:
Seth Hillbrand 2019-03-19 17:16:04 -07:00
parent 21dd8db7a9
commit 7d6665c313
1 changed files with 3 additions and 1 deletions

View File

@ -550,7 +550,9 @@ SHAPE_LINE_CHAIN& SHAPE_LINE_CHAIN::Simplify()
const VECTOR2I p1 = pts_unique[i + 1]; const VECTOR2I p1 = pts_unique[i + 1];
int n = i; int n = i;
while( n < np - 2 && SEG( p0, p1 ).LineDistance( pts_unique[n + 2] ) <= 1 ) while( n < np - 2
&& ( SEG( p0, p1 ).LineDistance( pts_unique[n + 2] ) <= 1
|| SEG( p0, p1 ).Collinear( SEG( p1, pts_unique[n + 2] ) ) ) )
n++; n++;
m_points.push_back( p0 ); m_points.push_back( p0 );