SHAPE_ARC: fix polyline conversion when radius=0
Prevent a divide-by-zero bug in SHAPE_ARC::ConvertToPolyline.
When the radius is zero, just use the initial angle (it makes
no different anyway, the result is the centre point, which is
the start point.
(cherry picked from commit e312e2b286
)
This commit is contained in:
parent
98f78f534c
commit
ab39f06003
|
@ -256,7 +256,11 @@ const SHAPE_LINE_CHAIN SHAPE_ARC::ConvertToPolyline( double aAccuracy ) const
|
||||||
|
|
||||||
for( int i = 0; i <= n ; i++ )
|
for( int i = 0; i <= n ; i++ )
|
||||||
{
|
{
|
||||||
double a = sa + m_centralAngle * (double) i / (double) n;
|
double a = sa;
|
||||||
|
|
||||||
|
if( n != 0 )
|
||||||
|
sa += m_centralAngle * (double) i / (double) n;
|
||||||
|
|
||||||
double x = c.x + r * cos( a * M_PI / 180.0 );
|
double x = c.x + r * cos( a * M_PI / 180.0 );
|
||||||
double y = c.y + r * sin( a * M_PI / 180.0 );
|
double y = c.y + r * sin( a * M_PI / 180.0 );
|
||||||
|
|
||||||
|
|
|
@ -314,10 +314,8 @@ bool ArePolylinePointsNearCircle(
|
||||||
return GEOM_TEST::ArePointsNearCircle( points, aCentre, aRad, aTolEnds );
|
return GEOM_TEST::ArePointsNearCircle( points, aCentre, aRad, aTolEnds );
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_EXPECTED_FAILURES
|
|
||||||
|
|
||||||
// Failure in zero-radius case
|
BOOST_AUTO_TEST_CASE( ArcToPolyline )
|
||||||
BOOST_AUTO_TEST_CASE( ArcToPolyline, *boost::unit_test::expected_failures( 1 ) )
|
|
||||||
{
|
{
|
||||||
const std::vector<ARC_TO_POLYLINE_CASE> cases = {
|
const std::vector<ARC_TO_POLYLINE_CASE> cases = {
|
||||||
{
|
{
|
||||||
|
@ -373,7 +371,5 @@ BOOST_AUTO_TEST_CASE( ArcToPolyline, *boost::unit_test::expected_failures( 1 ) )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HAVE_EXPECTED_FAILURES
|
|
||||||
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
Loading…
Reference in New Issue