diff --git a/pcbnew/router/pns_line.cpp b/pcbnew/router/pns_line.cpp index 074cdc60ea..b22ab3e11e 100644 --- a/pcbnew/router/pns_line.cpp +++ b/pcbnew/router/pns_line.cpp @@ -166,7 +166,7 @@ bool LINE::Walkaround( SHAPE_LINE_CHAIN aObstacle, SHAPE_LINE_CHAIN& aPre, if( aObstacle.PointInside( line.CPoint( 0 ) ) || aObstacle.PointInside( line.CPoint( -1 ) ) ) return false; - SHAPE_LINE_CHAIN::INTERSECTIONS ips, ips2; + SHAPE_LINE_CHAIN::INTERSECTIONS ips; line.Intersect( aObstacle, ips ); @@ -226,6 +226,9 @@ bool LINE::Walkaround( SHAPE_LINE_CHAIN aObstacle, SHAPE_LINE_CHAIN& aPre, int i = i_first; + if( i_first < 0 || i_last < 0 ) + return false; + while( i != i_last ) { aWalk.Append( aObstacle.CPoint( i ) ); @@ -249,14 +252,18 @@ bool LINE::Walkaround( SHAPE_LINE_CHAIN aObstacle, SHAPE_LINE_CHAIN& aPre, } -void LINE::Walkaround( const SHAPE_LINE_CHAIN& aObstacle, SHAPE_LINE_CHAIN& aPath, bool aCw ) const +bool LINE::Walkaround( const SHAPE_LINE_CHAIN& aObstacle, SHAPE_LINE_CHAIN& aPath, bool aCw ) const { SHAPE_LINE_CHAIN walk, post; - Walkaround( aObstacle, aPath, walk, post, aCw ); + if( ! Walkaround( aObstacle, aPath, walk, post, aCw ) ) + return false; + aPath.Append( walk ); aPath.Append( post ); aPath.Simplify(); + + return true; } diff --git a/pcbnew/router/pns_line.h b/pcbnew/router/pns_line.h index c972833e03..58ec12d59e 100644 --- a/pcbnew/router/pns_line.h +++ b/pcbnew/router/pns_line.h @@ -236,7 +236,7 @@ public: SHAPE_LINE_CHAIN& aPost, bool aCw ) const; - void Walkaround( const SHAPE_LINE_CHAIN& aObstacle, + bool Walkaround( const SHAPE_LINE_CHAIN& aObstacle, SHAPE_LINE_CHAIN& aPath, bool aCw ) const; diff --git a/pcbnew/router/pns_shove.cpp b/pcbnew/router/pns_shove.cpp index 60c367a3b5..a61bcabba9 100644 --- a/pcbnew/router/pns_shove.cpp +++ b/pcbnew/router/pns_shove.cpp @@ -135,8 +135,11 @@ SHOVE::SHOVE_STATUS SHOVE::walkaroundLoneVia( LINE& aCurrent, LINE& aObstacle, const SHAPE_LINE_CHAIN hull = aCurrent.Via().Hull( clearance, aObstacle.Width() ); SHAPE_LINE_CHAIN path_cw, path_ccw; - aObstacle.Walkaround( hull, path_cw, true ); - aObstacle.Walkaround( hull, path_ccw, false ); + if( ! aObstacle.Walkaround( hull, path_cw, true ) ) + return SH_INCOMPLETE; + + if( ! aObstacle.Walkaround( hull, path_ccw, false ) ) + return SH_INCOMPLETE; const SHAPE_LINE_CHAIN& shortest = path_ccw.Length() < path_cw.Length() ? path_ccw : path_cw; @@ -178,7 +181,9 @@ SHOVE::SHOVE_STATUS SHOVE::processHullSet( LINE& aCurrent, LINE& aObstacle, { const SHAPE_LINE_CHAIN& hull = aHulls[invertTraversal ? aHulls.size() - 1 - i : i]; - l.Walkaround( hull, path, clockwise ); + if( ! l.Walkaround( hull, path, clockwise ) ) + return SH_INCOMPLETE; + path.Simplify(); l.SetShape( path ); } diff --git a/pcbnew/router/pns_walkaround.cpp b/pcbnew/router/pns_walkaround.cpp index 18b7673d55..07c64823b2 100644 --- a/pcbnew/router/pns_walkaround.cpp +++ b/pcbnew/router/pns_walkaround.cpp @@ -79,10 +79,13 @@ WALKAROUND::WALKAROUND_STATUS WALKAROUND::singleStep( LINE& aPath, } } - aPath.Walkaround( current_obs->m_hull, path_pre[0], path_walk[0], - path_post[0], aWindingDirection ); - aPath.Walkaround( current_obs->m_hull, path_pre[1], path_walk[1], - path_post[1], !aWindingDirection ); + if( ! aPath.Walkaround( current_obs->m_hull, path_pre[0], path_walk[0], + path_post[0], aWindingDirection ) ) + return STUCK; + + if( ! aPath.Walkaround( current_obs->m_hull, path_pre[1], path_walk[1], + path_post[1], !aWindingDirection ) ) + return STUCK; #ifdef DEBUG m_logger.NewGroup( aWindingDirection ? "walk-cw" : "walk-ccw", m_iteration );