From 92b6e05909230c959aa0425623eac0a95d66813f Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Thu, 19 Sep 2019 12:43:24 -0700 Subject: [PATCH] connectivity: Check all anchors for connection With pads, we should check available anchor points for each connection, increasing probability of finding connection to match fill algorithm Fixes: lp:1844661 * https://bugs.launchpad.net/kicad/+bug/1844661 (cherry picked from commit b7128639f8786d5c630cc9cbebfd1a5e1a4f1afe) --- pcbnew/connectivity/connectivity_algo.cpp | 27 ++++++++++++++--------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/pcbnew/connectivity/connectivity_algo.cpp b/pcbnew/connectivity/connectivity_algo.cpp index 93f51ccd9d..9e7135f825 100644 --- a/pcbnew/connectivity/connectivity_algo.cpp +++ b/pcbnew/connectivity/connectivity_algo.cpp @@ -698,17 +698,24 @@ bool CN_VISITOR::operator()( CN_ITEM* aCandidate ) // Items do not necessarily have reciprocity as we only check for anchors // therefore, we check HitTest both directions A->B & B->A - // TODO: Check for collision geometry on extended features - wxPoint ptA1( aCandidate->GetAnchor( 0 ).x, aCandidate->GetAnchor( 0 ).y ); - wxPoint ptA2( aCandidate->GetAnchor( 1 ).x, aCandidate->GetAnchor( 1 ).y ); - wxPoint ptB1( m_item->GetAnchor( 0 ).x, m_item->GetAnchor( 0 ).y ); - wxPoint ptB2( m_item->GetAnchor( 1 ).x, m_item->GetAnchor( 1 ).y ); - if( parentA->HitTest( ptB1 ) || parentB->HitTest( ptA1 ) || - ( parentA->Type() == PCB_TRACE_T && parentB->HitTest( ptA2 ) ) || - ( parentB->Type() == PCB_TRACE_T && parentA->HitTest( ptB2 ) ) ) + for( int i = 0; i < aCandidate->AnchorCount(); ++i ) { - m_item->Connect( aCandidate ); - aCandidate->Connect( m_item ); + if( parentB->HitTest( wxPoint( aCandidate->GetAnchor( i ) ) ) ) + { + m_item->Connect( aCandidate ); + aCandidate->Connect( m_item ); + return true; + } + } + + for( int i = 0; i < m_item->AnchorCount(); ++i ) + { + if( parentA->HitTest( wxPoint( m_item->GetAnchor( i ) ) ) ) + { + m_item->Connect( aCandidate ); + aCandidate->Connect( m_item ); + return true; + } } return true;