Make sure to add start points to arcs in TransformOvalToPolygon.

Otherwise the long line segments can be non-parallel to the centerline.

This was the root cause of the slowdown in https://gitlab.com/kicad/code/kicad/-/issues/18156

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18156

(cherry picked from commit 76b2741a92)
This commit is contained in:
Alex Shvartzkop 2024-06-09 20:01:45 +03:00
parent ad7bd9b5f8
commit 96370f6665
1 changed files with 10 additions and 2 deletions

View File

@ -171,6 +171,10 @@ void TransformOvalToPolygon( SHAPE_POLY_SET& aBuffer, const VECTOR2I& aStart, co
// add right rounded end: // add right rounded end:
// Right arc start:
corner = VECTOR2I( seg_len, radius );
polyshape.Append( corner.x, corner.y );
for( EDA_ANGLE angle = delta / 2; angle < ANGLE_180; angle += delta ) for( EDA_ANGLE angle = delta / 2; angle < ANGLE_180; angle += delta )
{ {
corner = VECTOR2I( 0, radius ); corner = VECTOR2I( 0, radius );
@ -179,10 +183,14 @@ void TransformOvalToPolygon( SHAPE_POLY_SET& aBuffer, const VECTOR2I& aStart, co
polyshape.Append( corner.x, corner.y ); polyshape.Append( corner.x, corner.y );
} }
// Finish arc: // Finish right arc:
corner = VECTOR2I( seg_len, -radius ); corner = VECTOR2I( seg_len, -radius );
polyshape.Append( corner.x, corner.y ); polyshape.Append( corner.x, corner.y );
// Left arc start:
corner = VECTOR2I( 0, -radius );
polyshape.Append( corner.x, corner.y );
// add left rounded end: // add left rounded end:
for( EDA_ANGLE angle = delta / 2; angle < ANGLE_180; angle += delta ) for( EDA_ANGLE angle = delta / 2; angle < ANGLE_180; angle += delta )
{ {
@ -191,7 +199,7 @@ void TransformOvalToPolygon( SHAPE_POLY_SET& aBuffer, const VECTOR2I& aStart, co
polyshape.Append( corner.x, corner.y ); polyshape.Append( corner.x, corner.y );
} }
// Finish arc: // Finish left arc:
corner = VECTOR2I( 0, radius ); corner = VECTOR2I( 0, radius );
polyshape.Append( corner.x, corner.y ); polyshape.Append( corner.x, corner.y );