diff --git a/pcbnew/router/pns_line_placer.cpp b/pcbnew/router/pns_line_placer.cpp index 19464b512c..bedb392689 100644 --- a/pcbnew/router/pns_line_placer.cpp +++ b/pcbnew/router/pns_line_placer.cpp @@ -821,7 +821,6 @@ bool LINE_PLACER::rhShoveOnly( const VECTOR2I& aP, LINE& aNewHead ) walkaround.SetWorld( m_currentNode ); walkaround.SetSolidsOnly( false ); walkaround.SetIterationLimit( 10 ); - walkaround.SetApproachCursor( true, aP ); walkaround.Route( initTrack, l2 ); aNewHead = l2.ClipToNearestObstacle( m_shove->CurrentNode() ); diff --git a/pcbnew/router/pns_shove.cpp b/pcbnew/router/pns_shove.cpp index 958e596e8d..bc872befed 100644 --- a/pcbnew/router/pns_shove.cpp +++ b/pcbnew/router/pns_shove.cpp @@ -710,12 +710,10 @@ SHOVE::SHOVE_STATUS SHOVE::onCollidingSolid( LINE& aCurrent, ITEM* aObstacle, OB { nextRank = currentRank - 1; - walkaround.SetSingleDirection( true ); } else { nextRank = currentRank + 10000; - walkaround.SetSingleDirection( false ); } diff --git a/pcbnew/router/pns_walkaround.cpp b/pcbnew/router/pns_walkaround.cpp index 88d868551d..f75843f802 100644 --- a/pcbnew/router/pns_walkaround.cpp +++ b/pcbnew/router/pns_walkaround.cpp @@ -28,6 +28,8 @@ #include "pns_utils.h" #include "pns_router.h" #include "pns_debug_decorator.h" +#include "pns_solid.h" + namespace PNS { @@ -53,6 +55,25 @@ NODE::OPT_OBSTACLE WALKAROUND::nearestObstacle( const LINE& aPath ) } +void WALKAROUND::RestrictToSet( bool aEnabled, const std::set& aSet ) +{ + m_restrictedVertices.clear(); + + if( aEnabled ) + m_restrictedSet = aSet; + else + m_restrictedSet.clear(); + + for( auto item : aSet ) + { + if( auto solid = dyn_cast( item ) ) + { + m_restrictedVertices.push_back( solid->Anchor( 0 ) ); + } + } +} + + WALKAROUND::WALKAROUND_STATUS WALKAROUND::singleStep( LINE& aPath, bool aWindingDirection ) { OPT& current_obs = @@ -111,7 +132,6 @@ const WALKAROUND::RESULT WALKAROUND::Route( const LINE& aInitialPath ) start( aInitialPath ); m_currentObstacle[0] = m_currentObstacle[1] = nearestObstacle( aInitialPath ); - m_recursiveBlockageCount = 0; result.lineCw = aInitialPath; result.lineCcw = aInitialPath; @@ -120,11 +140,6 @@ const WALKAROUND::RESULT WALKAROUND::Route( const LINE& aInitialPath ) { s_cw = m_forceCw ? IN_PROGRESS : STUCK; s_ccw = m_forceCw ? STUCK : IN_PROGRESS; - m_forceSingleDirection = true; - } - else - { - m_forceSingleDirection = false; } // In some situations, there isn't a trivial path (or even a path at all). Hitting the @@ -198,6 +213,9 @@ const WALKAROUND::RESULT WALKAROUND::Route( const LINE& aInitialPath ) result.statusCcw = ALMOST_DONE; } + result.lineCw.ClearLinks(); + result.lineCcw.ClearLinks(); + return result; } @@ -223,7 +241,6 @@ WALKAROUND::WALKAROUND_STATUS WALKAROUND::Route( const LINE& aInitialPath, LINE& start( aInitialPath ); m_currentObstacle[0] = m_currentObstacle[1] = nearestObstacle( aInitialPath ); - m_recursiveBlockageCount = 0; aWalkPath = aInitialPath; @@ -231,11 +248,6 @@ WALKAROUND::WALKAROUND_STATUS WALKAROUND::Route( const LINE& aInitialPath, LINE& { s_cw = m_forceCw ? IN_PROGRESS : STUCK; s_ccw = m_forceCw ? STUCK : IN_PROGRESS; - m_forceSingleDirection = true; - } - else - { - m_forceSingleDirection = false; } while( m_iteration < m_iterationLimit ) diff --git a/pcbnew/router/pns_walkaround.h b/pcbnew/router/pns_walkaround.h index ddef15db7c..db1f960cdc 100644 --- a/pcbnew/router/pns_walkaround.h +++ b/pcbnew/router/pns_walkaround.h @@ -42,18 +42,13 @@ public: m_world( aWorld ), m_iterationLimit( DefaultIterationLimit ) { - m_forceSingleDirection = false; - m_forceLongerPath = false; m_forceWinding = false; - m_cursorApproachMode = false; m_itemMask = ITEM::ANY_T; // Initialize other members, to avoid uninitialized variables. - m_recursiveBlockageCount = 0; - m_recursiveCollision[0] = m_recursiveCollision[1] = false; m_iteration = 0; m_forceCw = false; - m_forceUniqueWindingDirection = false; + m_forceLongerPath = false; } ~WALKAROUND() {}; @@ -103,36 +98,13 @@ public: m_itemMask = aMask; } - void SetSingleDirection( bool aForceSingleDirection ) - { - m_forceSingleDirection = aForceSingleDirection; - m_forceLongerPath = aForceSingleDirection; - } - - void SetSingleDirection2( bool aForceSingleDirection ) - { - m_forceSingleDirection = aForceSingleDirection; - } - - void SetApproachCursor( bool aEnabled, const VECTOR2I& aPos ) - { - m_cursorPos = aPos; - m_cursorApproachMode = aEnabled; - } - void SetForceWinding ( bool aEnabled, bool aCw ) { m_forceCw = aCw; m_forceWinding = aEnabled; } - void RestrictToSet( bool aEnabled, const std::set& aSet ) - { - if( aEnabled ) - m_restrictedSet = aSet; - else - m_restrictedSet.clear(); - } + void RestrictToSet( bool aEnabled, const std::set& aSet ); WALKAROUND_STATUS Route( const LINE& aInitialPath, LINE& aWalkPath, bool aOptimize = true ); @@ -147,19 +119,16 @@ private: NODE* m_world; - int m_recursiveBlockageCount; int m_iteration; int m_iterationLimit; int m_itemMask; - bool m_forceSingleDirection, m_forceLongerPath; - bool m_cursorApproachMode; bool m_forceWinding; bool m_forceCw; - bool m_forceUniqueWindingDirection; VECTOR2I m_cursorPos; NODE::OPT_OBSTACLE m_currentObstacle[2]; - bool m_recursiveCollision[2]; std::set m_restrictedSet; + std::vector m_restrictedVertices; + bool m_forceLongerPath; }; }