TEARDROP_MANAGER: fix a corner case that generate a invalid teardrop polygon.

Also add a better handling of connected tracks when searching for a track connected
to a too short track to create a teardrop, search was stopped to Y connections.
Now the selected track is the longest of these 2 candidates.
Fixes #13006
https://gitlab.com/kicad/code/kicad/issues/13006
This commit is contained in:
jean-pierre charras 2022-11-26 12:55:07 +01:00
parent 754e82535a
commit 3f50199dad
1 changed files with 10 additions and 3 deletions

View File

@ -216,13 +216,16 @@ PCB_TRACK* TEARDROP_MANAGER::findTouchingTrack( EDA_ITEM_FLAGS& aMatchType, PCB_
if( match ) if( match )
{ {
// if faced with a Y junction, stop here // if faced with a Y junction, choose the track longest segment as candidate
matches++; matches++;
if( matches > 1 ) if( matches > 1 )
{ {
aMatchType = 0; double previous_len = candidate->GetLength();
return nullptr; double curr_len = curr_track->GetLength();
if( previous_len >= curr_len )
continue;
} }
aMatchType = match; aMatchType = match;
@ -694,6 +697,10 @@ bool TEARDROP_MANAGER::computeTeardropPolygonPoints( TEARDROP_PARAMETERS* aCurrP
aFollowTracks, aTrackLookupList ) ) aFollowTracks, aTrackLookupList ) )
return false; return false;
// The start and end points must be different to calculate a valid polygon shape
if( start == end )
return false;
VECTOR2D vecT = NormalizeVector(end - start); VECTOR2D vecT = NormalizeVector(end - start);
// find the 2 points on the track, sharp end of the teardrop // find the 2 points on the track, sharp end of the teardrop