|
|
|
@ -305,11 +305,36 @@ void SHAPE_LINE_CHAIN::Replace( int aStartIndex, int aEndIndex, const SHAPE_LINE |
|
|
|
if( aStartIndex < 0 ) |
|
|
|
aStartIndex += PointCount(); |
|
|
|
|
|
|
|
// We only process lines in order in this house
|
|
|
|
wxASSERT( aStartIndex <= aEndIndex ); |
|
|
|
|
|
|
|
SHAPE_LINE_CHAIN newLine = aLine; |
|
|
|
|
|
|
|
// It's possible that the start or end lands on the end of an arc. If so, we'd better have a
|
|
|
|
// replacement line that matches up to the same coordinates, as we can't break the arc(s).
|
|
|
|
ssize_t startShape = m_shapes[aStartIndex]; |
|
|
|
ssize_t endShape = m_shapes[aEndIndex]; |
|
|
|
|
|
|
|
if( startShape >= 0 ) |
|
|
|
{ |
|
|
|
wxASSERT( newLine.m_points.front() == m_points[aStartIndex] && |
|
|
|
aStartIndex < m_points.size() - 1 ); |
|
|
|
aStartIndex++; |
|
|
|
newLine.Remove( 0 ); |
|
|
|
} |
|
|
|
|
|
|
|
if( endShape >= 0 ) |
|
|
|
{ |
|
|
|
wxASSERT( newLine.m_points.back() == m_points[aEndIndex] && aEndIndex > 0 ); |
|
|
|
aEndIndex--; |
|
|
|
newLine.Remove( -1 ); |
|
|
|
} |
|
|
|
|
|
|
|
Remove( aStartIndex, aEndIndex ); |
|
|
|
|
|
|
|
// The total new arcs index is added to the new arc indices
|
|
|
|
size_t prev_arc_count = m_arcs.size(); |
|
|
|
std::vector<ssize_t> new_shapes = aLine.m_shapes; |
|
|
|
size_t prev_arc_count = m_arcs.size(); |
|
|
|
std::vector<ssize_t> new_shapes = newLine.m_shapes; |
|
|
|
|
|
|
|
for( ssize_t& shape : new_shapes ) |
|
|
|
{ |
|
|
|
@ -318,8 +343,9 @@ void SHAPE_LINE_CHAIN::Replace( int aStartIndex, int aEndIndex, const SHAPE_LINE |
|
|
|
} |
|
|
|
|
|
|
|
m_shapes.insert( m_shapes.begin() + aStartIndex, new_shapes.begin(), new_shapes.end() ); |
|
|
|
m_points.insert( m_points.begin() + aStartIndex, aLine.m_points.begin(), aLine.m_points.end() ); |
|
|
|
m_arcs.insert( m_arcs.end(), aLine.m_arcs.begin(), aLine.m_arcs.end() ); |
|
|
|
m_points.insert( m_points.begin() + aStartIndex, newLine.m_points.begin(), |
|
|
|
newLine.m_points.end() ); |
|
|
|
m_arcs.insert( m_arcs.end(), newLine.m_arcs.begin(), newLine.m_arcs.end() ); |
|
|
|
|
|
|
|
assert( m_shapes.size() == m_points.size() ); |
|
|
|
} |
|
|
|
@ -328,6 +354,7 @@ void SHAPE_LINE_CHAIN::Replace( int aStartIndex, int aEndIndex, const SHAPE_LINE |
|
|
|
void SHAPE_LINE_CHAIN::Remove( int aStartIndex, int aEndIndex ) |
|
|
|
{ |
|
|
|
assert( m_shapes.size() == m_points.size() ); |
|
|
|
|
|
|
|
if( aEndIndex < 0 ) |
|
|
|
aEndIndex += PointCount(); |
|
|
|
|
|
|
|
@ -1025,7 +1052,7 @@ SHAPE_LINE_CHAIN& SHAPE_LINE_CHAIN::Simplify( bool aRemoveColinear ) |
|
|
|
const VECTOR2I p1 = pts_unique[i + 1]; |
|
|
|
int n = i; |
|
|
|
|
|
|
|
if( aRemoveColinear ) |
|
|
|
if( aRemoveColinear && shapes_unique[i] < 0 && shapes_unique[i + 1] < 0 ) |
|
|
|
{ |
|
|
|
while( n < np - 2 |
|
|
|
&& ( SEG( p0, p1 ).LineDistance( pts_unique[n + 2] ) <= 1 |
|
|
|
|