SHAPE_ARC::update_bbox(): use double instead of int to calculate radius, and
if the radius is too large (> INT_MAX/2), consider arc as a segment to avoid overflows. Nor perfect, but it avoid some issues when calculating bbox.
This commit is contained in:
parent
cd27f801f6
commit
8ffd4f636a
|
@ -328,8 +328,16 @@ void SHAPE_ARC::update_bbox()
|
||||||
int quad_angle_start = std::ceil( start_angle.AsDegrees() / 90.0 );
|
int quad_angle_start = std::ceil( start_angle.AsDegrees() / 90.0 );
|
||||||
int quad_angle_end = std::floor( end_angle.AsDegrees() / 90.0 );
|
int quad_angle_end = std::floor( end_angle.AsDegrees() / 90.0 );
|
||||||
|
|
||||||
|
// very large radius means the arc is similar to a segment
|
||||||
|
// so do not try to add more points, center cannot be handled
|
||||||
|
// Very large is here > INT_MAX/2
|
||||||
|
double d_radius = GetRadius();
|
||||||
|
|
||||||
|
if( d_radius < INT_MAX/2 )
|
||||||
|
{
|
||||||
VECTOR2I center = GetCenter();
|
VECTOR2I center = GetCenter();
|
||||||
const int radius = KiROUND( GetRadius() );
|
|
||||||
|
const int radius = KiROUND( d_radius );
|
||||||
|
|
||||||
// count through quadrants included in arc
|
// count through quadrants included in arc
|
||||||
for( int quad_angle = quad_angle_start; quad_angle <= quad_angle_end; ++quad_angle )
|
for( int quad_angle = quad_angle_start; quad_angle <= quad_angle_end; ++quad_angle )
|
||||||
|
@ -348,6 +356,7 @@ void SHAPE_ARC::update_bbox()
|
||||||
|
|
||||||
points.push_back( quad_pt );
|
points.push_back( quad_pt );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_bbox.Compute( points );
|
m_bbox.Compute( points );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue