From e60386f02881e73e27fdffbbcb2d56d631a73ae0 Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Sun, 21 Nov 2021 22:56:26 +0100 Subject: [PATCH] router: disable 'limit corner count' optimization for via dragging It seems to be completely preventing optimization instead of preventing over-optimization in case the head is a dragged via. To be investigated in more details in V7. Fixes: https://gitlab.com/kicad/code/kicad/-/issues/8665 --- pcbnew/router/pns_dragger.cpp | 3 +++ pcbnew/router/pns_optimizer.cpp | 1 + pcbnew/router/pns_shove.cpp | 10 +++++++++- pcbnew/router/pns_shove.h | 3 +++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/pcbnew/router/pns_dragger.cpp b/pcbnew/router/pns_dragger.cpp index 6d3750d717..4bd5b87bf5 100644 --- a/pcbnew/router/pns_dragger.cpp +++ b/pcbnew/router/pns_dragger.cpp @@ -650,6 +650,9 @@ bool DRAGGER::dragShove( const VECTOR2I& aP ) { VIA_HANDLE newVia; + // corner count limiter intended to avoid excessive optimization produces mediocre results for via shoving. + // this is a hack that disables it, before I figure out a more reliable solution + m_shove->DisablePostShoveOptimizations( OPTIMIZER::LIMIT_CORNER_COUNT ); SHOVE::SHOVE_STATUS st = m_shove->ShoveDraggingVia( m_draggedVia, aP, newVia ); if( st == SHOVE::SH_OK || st == SHOVE::SH_HEAD_MODIFIED ) diff --git a/pcbnew/router/pns_optimizer.cpp b/pcbnew/router/pns_optimizer.cpp index 26a207a320..2e3743e4aa 100644 --- a/pcbnew/router/pns_optimizer.cpp +++ b/pcbnew/router/pns_optimizer.cpp @@ -271,6 +271,7 @@ bool CORNER_COUNT_LIMIT_CONSTRAINT::Check( int aVertex1, int aVertex2, const LIN { LINE newPath( *aOriginLine, aCurrentPath ); newPath.Line().Replace( aVertex1, aVertex2, aReplacement ); + newPath.Line().Simplify(); int cc = newPath.CountCorners( m_angleMask ); if( cc >= m_minCorners && cc <= m_maxCorners ) diff --git a/pcbnew/router/pns_shove.cpp b/pcbnew/router/pns_shove.cpp index 1daa9d3d7e..ea0c1de357 100644 --- a/pcbnew/router/pns_shove.cpp +++ b/pcbnew/router/pns_shove.cpp @@ -159,6 +159,7 @@ void SHOVE::sanityCheck( LINE* aOld, LINE* aNew ) SHOVE::SHOVE( NODE* aWorld, ROUTER* aRouter ) : ALGO_BASE( aRouter ) { + m_optFlagDisableMask = 0; m_forceClearance = -1; m_root = aWorld; m_currentNode = aWorld; @@ -1759,7 +1760,8 @@ void SHOVE::runOptimizer( NODE* aNode ) if( Settings().SmartPads() ) optFlags |= OPTIMIZER::SMART_PADS; - optimizer.SetEffortLevel( optFlags ); + + optimizer.SetEffortLevel( optFlags & ~m_optFlagDisableMask ); optimizer.SetCollisionMask( ITEM::ANY_T ); for( int pass = 0; pass < n_passes; pass++ ) @@ -1873,5 +1875,11 @@ void SHOVE::UnlockSpringbackNode( NODE* aNode ) } } + +void SHOVE::DisablePostShoveOptimizations( int aMask ) +{ + m_optFlagDisableMask = aMask; +} + } diff --git a/pcbnew/router/pns_shove.h b/pcbnew/router/pns_shove.h index 8f032f2125..cd8ee5d0d7 100644 --- a/pcbnew/router/pns_shove.h +++ b/pcbnew/router/pns_shove.h @@ -89,6 +89,7 @@ public: void UnlockSpringbackNode( NODE* aNode ); bool RewindSpringbackTo( NODE* aNode ); bool RewindToLastLockedNode(); + void DisablePostShoveOptimizations( int aMask ); private: typedef std::vector HULL_SET; @@ -180,6 +181,8 @@ private: int m_iter; int m_forceClearance; bool m_multiLineMode; + + int m_optFlagDisableMask; }; }