From 3f50199dad9955e71419e763754a89050ab52ca7 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 26 Nov 2022 12:55:07 +0100 Subject: [PATCH] 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 --- pcbnew/teardrop/teardrop_utils.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pcbnew/teardrop/teardrop_utils.cpp b/pcbnew/teardrop/teardrop_utils.cpp index e3afe0fefd..2863d38523 100644 --- a/pcbnew/teardrop/teardrop_utils.cpp +++ b/pcbnew/teardrop/teardrop_utils.cpp @@ -216,13 +216,16 @@ PCB_TRACK* TEARDROP_MANAGER::findTouchingTrack( EDA_ITEM_FLAGS& aMatchType, PCB_ if( match ) { - // if faced with a Y junction, stop here + // if faced with a Y junction, choose the track longest segment as candidate matches++; if( matches > 1 ) { - aMatchType = 0; - return nullptr; + double previous_len = candidate->GetLength(); + double curr_len = curr_track->GetLength(); + + if( previous_len >= curr_len ) + continue; } aMatchType = match; @@ -694,6 +697,10 @@ bool TEARDROP_MANAGER::computeTeardropPolygonPoints( TEARDROP_PARAMETERS* aCurrP aFollowTracks, aTrackLookupList ) ) 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); // find the 2 points on the track, sharp end of the teardrop