From 58f5e611864cc333ac748a683ec2e84d316e1983 Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Sat, 28 Dec 2024 17:31:37 +0100 Subject: [PATCH] router: pass current routing mode to rhWalkBase() so that it knows what kinds of board primitives to walk around --- pcbnew/router/pns_line_placer.cpp | 19 ++++++++++--------- pcbnew/router/pns_line_placer.h | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/pcbnew/router/pns_line_placer.cpp b/pcbnew/router/pns_line_placer.cpp index 15050ddea5..26c25835e1 100644 --- a/pcbnew/router/pns_line_placer.cpp +++ b/pcbnew/router/pns_line_placer.cpp @@ -553,7 +553,7 @@ bool LINE_PLACER::cursorDistMinimum( const SHAPE_LINE_CHAIN& aL, const VECTOR2I& } -bool LINE_PLACER::rhWalkBase( const VECTOR2I& aP, LINE& aWalkLine, int aCollisionMask, +bool LINE_PLACER::rhWalkBase( const VECTOR2I& aP, LINE& aWalkLine, int aCollisionMask, PNS::PNS_MODE aMode, bool& aViaOk ) { LINE walkFull( m_head ); @@ -582,7 +582,7 @@ bool LINE_PLACER::rhWalkBase( const VECTOR2I& aP, LINE& aWalkLine, int aCollisio PNS_DBG( Dbg(), BeginGroup, wxString::Format( "walk-round-%d", round ), 0 ); round++; - aViaOk = buildInitialLine( walkP, l1, round == 0 ); + aViaOk = buildInitialLine( walkP, l1, aMode, round == 0 ); PNS_DBG( Dbg(), AddItem, &l1, BLUE, 20000, wxT( "walk-base-l1" ) ); if( l1.EndsWithVia() ) @@ -748,7 +748,7 @@ bool LINE_PLACER::rhWalkOnly( const VECTOR2I& aP, LINE& aNewHead, LINE& aNewTail int effort = 0; bool viaOk = false; - if( ! rhWalkBase( aP, walkFull, ITEM::ANY_T, viaOk ) ) + if( ! rhWalkBase( aP, walkFull, ITEM::ANY_T, RM_Walkaround, viaOk ) ) return false; switch( Settings().OptimizerEffort() ) @@ -814,7 +814,7 @@ bool LINE_PLACER::rhWalkOnly( const VECTOR2I& aP, LINE& aNewHead, LINE& aNewTail bool LINE_PLACER::rhMarkObstacles( const VECTOR2I& aP, LINE& aNewHead, LINE& aNewTail ) { - buildInitialLine( aP, m_head ); + buildInitialLine( aP, m_head, RM_MarkObstacles ); m_head.SetBlockingObstacle( nullptr ); auto obs = m_currentNode->NearestObstacle( &m_head ); @@ -836,7 +836,7 @@ bool LINE_PLACER::rhMarkObstacles( const VECTOR2I& aP, LINE& aNewHead, LINE& aNe nearest = hull.NearestPoint( aP ); if( ( nearest - aP ).EuclideanNorm() < m_head.Width() / 2 ) - buildInitialLine( nearest, m_head ); + buildInitialLine( nearest, m_head, RM_MarkObstacles ); } // Note: Something like the below could be used to implement a "stop at first obstacle" mode, @@ -930,7 +930,7 @@ bool LINE_PLACER::rhShoveOnly( const VECTOR2I& aP, LINE& aNewHead, LINE& aNewTai bool viaOk = false; - if( ! rhWalkBase( aP, walkSolids, ITEM::SOLID_T, viaOk ) ) + if( ! rhWalkBase( aP, walkSolids, ITEM::SOLID_T, RM_Shove, viaOk ) ) return false; m_currentNode = m_shove->CurrentNode(); @@ -1976,7 +1976,7 @@ void LINE_PLACER::SetOrthoMode( bool aOrthoMode ) } -bool LINE_PLACER::buildInitialLine( const VECTOR2I& aP, LINE& aHead, bool aForceNoVia ) +bool LINE_PLACER::buildInitialLine( const VECTOR2I& aP, LINE& aHead, PNS::PNS_MODE aMode, bool aForceNoVia ) { SHAPE_LINE_CHAIN l; DIRECTION_45 guessedDir = m_mouseTrailTracer.GetPosture( aP ); @@ -2031,13 +2031,13 @@ bool LINE_PLACER::buildInitialLine( const VECTOR2I& aP, LINE& aHead, bool aForce VIA v( makeVia( aP ) ); v.SetNet( aHead.Net() ); - if( Settings().Mode() == RM_MarkObstacles ) + if( aMode == RM_MarkObstacles ) { aHead.AppendVia( v ); return true; } - const int collMask = ( Settings().Mode() == RM_Walkaround ) ? ITEM::ANY_T : ITEM::SOLID_T; + const int collMask = ( aMode == RM_Walkaround ) ? ITEM::ANY_T : ITEM::SOLID_T; const int iterLimit = Settings().ViaForcePropIterationLimit(); for( int attempt = 0; attempt < 2; attempt++) @@ -2076,6 +2076,7 @@ void LINE_PLACER::GetModifiedNets( std::vector& aNets ) const bool LINE_PLACER::AbortPlacement() { m_world->KillChildren(); + m_lastNode = nullptr; return true; } diff --git a/pcbnew/router/pns_line_placer.h b/pcbnew/router/pns_line_placer.h index ec79de8e89..c62e253314 100644 --- a/pcbnew/router/pns_line_placer.h +++ b/pcbnew/router/pns_line_placer.h @@ -323,7 +323,7 @@ private: ///< Route step walk around mode. bool rhWalkOnly( const VECTOR2I& aP, LINE& aNewHead, LINE& aNewTail ); - bool rhWalkBase( const VECTOR2I& aP, LINE& aWalkLine, int aCollisionMask, bool& aViaOk ); + bool rhWalkBase( const VECTOR2I& aP, LINE& aWalkLine, int aCollisionMask, PNS::PNS_MODE aMode, bool& aViaOk ); bool splitHeadTail( const LINE& aNewLine, const LINE& aOldTail, LINE& aNewHead, LINE& aNewTail ); bool cursorDistMinimum( const SHAPE_LINE_CHAIN& aL, const VECTOR2I& aCursor, double lengthThreshold, SHAPE_LINE_CHAIN& aOut ); bool clipAndCheckCollisions( const VECTOR2I& aP, const SHAPE_LINE_CHAIN& aL, SHAPE_LINE_CHAIN& aOut, int &thresholdDist ); @@ -340,7 +340,7 @@ private: const VIA makeVia( const VECTOR2I& aP ); - bool buildInitialLine( const VECTOR2I& aP, LINE& aHead, bool aForceNoVia = false ); + bool buildInitialLine( const VECTOR2I& aP, LINE& aHead, PNS::PNS_MODE aMode, bool aForceNoVia = false ); DIRECTION_45 m_direction; ///< current routing direction