From 7d6665c31334b792ce190a3e588fe4ff05dd65e9 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 19 Mar 2019 17:16:04 -0700 Subject: [PATCH] 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. --- common/geometry/shape_line_chain.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/geometry/shape_line_chain.cpp b/common/geometry/shape_line_chain.cpp index 94d5717e97..7bb8d808ea 100644 --- a/common/geometry/shape_line_chain.cpp +++ b/common/geometry/shape_line_chain.cpp @@ -550,7 +550,9 @@ SHAPE_LINE_CHAIN& SHAPE_LINE_CHAIN::Simplify() const VECTOR2I p1 = pts_unique[i + 1]; 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++; m_points.push_back( p0 );