From a3d8ab911fc24d24d85dddaceac5dc6980c324a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20W=C5=82ostowski?= Date: Tue, 25 Dec 2018 02:29:23 +0100 Subject: [PATCH] router: improved snap-to-clearance zone algorithm in highlight collisions mode --- pcbnew/router/pns_line_placer.cpp | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/pcbnew/router/pns_line_placer.cpp b/pcbnew/router/pns_line_placer.cpp index a6282085b5..1569ce1394 100644 --- a/pcbnew/router/pns_line_placer.cpp +++ b/pcbnew/router/pns_line_placer.cpp @@ -413,24 +413,39 @@ bool LINE_PLACER::rhWalkOnly( const VECTOR2I& aP, LINE& aNewHead ) bool LINE_PLACER::rhMarkObstacles( const VECTOR2I& aP, LINE& aNewHead ) { - buildInitialLine( aP, m_head ); + LINE newHead( m_head ), bestHead( m_head ); + bool hasBest = false; - auto obs = m_currentNode->NearestObstacle( &m_head ); + buildInitialLine( aP, newHead ); - if( obs ) + NODE::OBSTACLES obstacles; + + m_currentNode->QueryColliding( &newHead, obstacles ); + + for( auto& obs : obstacles ) { - int cl = m_currentNode->GetClearance( obs->m_item, &m_head ); - auto hull = obs->m_item->Hull( cl, m_head.Width() ); + int cl = m_currentNode->GetClearance( obs.m_item, &newHead ); + auto hull = obs.m_item->Hull( cl, newHead.Width() ); auto nearest = hull.NearestPoint( aP ); Dbg()->AddLine( hull, 2, 10000 ); - if( ( nearest - aP ).EuclideanNorm() < m_head.Width() ) + if( ( nearest - aP ).EuclideanNorm() < newHead.Width() + cl ) { - buildInitialLine( nearest, m_head ); + buildInitialLine( nearest, newHead ); + if ( newHead.CLine().Length() > bestHead.CLine().Length() ) + { + bestHead = newHead; + hasBest = true; + } } } + if( hasBest ) + m_head = bestHead; + else + m_head = newHead; + aNewHead = m_head; return static_cast( m_currentNode->CheckColliding( &m_head ) );