GRAPHICS_CLEANER: fix bad detection of short Bezier curves that can be cleaned

eda_shape: small enhancement: when generating a polyline from the Bezier curve,
filter the last point if the last segment is shorter than the given min lenght
This commit is contained in:
jean-pierre charras 2022-12-10 17:59:50 +01:00
parent 492e6548ff
commit 75f1067642
2 changed files with 19 additions and 1 deletions

View File

@ -413,6 +413,18 @@ void EDA_SHAPE::RebuildBezierToSegmentsPointsList( int aMinSegLen )
// Rebuild the m_BezierPoints vertex list that approximate the Bezier curve
m_bezierPoints = buildBezierToSegmentsPointsList( aMinSegLen );
// Ensure last point respects aMinSegLen parameter
if( m_bezierPoints.size() > 2 )
{
int idx = m_bezierPoints.size()-1;
if( VECTOR2I( m_bezierPoints[idx] - m_bezierPoints[idx]-1 ).EuclideanNorm() < aMinSegLen )
{
m_bezierPoints[idx]-1 = m_bezierPoints[idx];
m_bezierPoints.pop_back();
}
}
}

View File

@ -100,7 +100,13 @@ bool GRAPHICS_CLEANER::isNullShape( PCB_SHAPE* aShape )
case SHAPE_T::BEZIER:
aShape->RebuildBezierToSegmentsPointsList( aShape->GetWidth() );
return aShape->GetBezierPoints().empty();
// If the Bezier points list contains 2 points, it is equivalent to a segment
if( aShape->GetBezierPoints().size() == 2 )
return equivalent( aShape->GetStart(), aShape->GetEnd(), m_epsilon );
// If the Bezier points list contains 1 points, it is equivalent to a point
return aShape->GetBezierPoints().size() < 2;
default:
UNIMPLEMENTED_FOR( aShape->SHAPE_T_asString() );