Fix simplify routine for last segment
The last segment of a track could be removed when the iterator does not correctly loop. Keeping the ll within bounds and checking for equivalency instead of comparison works for last point
This commit is contained in:
parent
d92db68597
commit
339cf3f2e2
|
@ -2418,7 +2418,7 @@ void SHAPE_LINE_CHAIN::Simplify( int aMaxError )
|
|||
{
|
||||
bool too_far = false;
|
||||
|
||||
for( size_t ll = ii + 1; ll < kk; ++ll )
|
||||
for( size_t ll = ( ii + 1 ) % m_points.size(); ll != kk; ++ll )
|
||||
{
|
||||
if( !TestSegmentHitFast( m_points[ll], m_points[ii], m_points[kk], aMaxError ) )
|
||||
{
|
||||
|
|
|
@ -387,6 +387,27 @@ BOOST_AUTO_TEST_CASE( SimplifyDuplicatePoint )
|
|||
}
|
||||
|
||||
|
||||
// Test that duplicate point gets removed when we call simplify
|
||||
BOOST_AUTO_TEST_CASE( SimplifyKeepEndPoint )
|
||||
{
|
||||
SHAPE_LINE_CHAIN chain;
|
||||
|
||||
chain.Append( { 114772424, 90949410 } );
|
||||
chain.Append( { 114767360, 90947240 } );
|
||||
chain.Append( { 114772429, 90947228 } );
|
||||
chain.SetClosed( true );
|
||||
|
||||
BOOST_CHECK( GEOM_TEST::IsOutlineValid( chain ) );
|
||||
BOOST_CHECK_EQUAL( chain.PointCount(), 3 );
|
||||
|
||||
chain.Simplify();
|
||||
|
||||
BOOST_CHECK_EQUAL( chain.CPoints().size(), chain.CShapes().size() );
|
||||
BOOST_CHECK_EQUAL( chain.PointCount(), 3 );
|
||||
BOOST_CHECK( GEOM_TEST::IsOutlineValid( chain ) );
|
||||
}
|
||||
|
||||
|
||||
struct REMOVE_SHAPE_CASE
|
||||
{
|
||||
std::string m_ctx_name;
|
||||
|
|
Loading…
Reference in New Issue