7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 17:03:44 +00:00

router: further investigation (and possible fix) for surplus vias in shove mode

This commit is contained in:
Tomasz Wlostowski 2024-11-06 23:23:11 +01:00
parent 55d5988430
commit 8b76e64682
2 changed files with 17 additions and 10 deletions

View File

@ -77,7 +77,7 @@ void SHOVE::replaceItems( ITEM* aOld, std::unique_ptr< ITEM > aNew )
}
void SHOVE::replaceLine( LINE& aOld, LINE& aNew, bool aIncludeInChangedArea, NODE* aNode )
SHOVE::ROOT_LINE_ENTRY* SHOVE::replaceLine( LINE& aOld, LINE& aNew, bool aIncludeInChangedArea, NODE* aNode )
{
if( aIncludeInChangedArea )
{
@ -93,6 +93,9 @@ void SHOVE::replaceLine( LINE& aOld, LINE& aNew, bool aIncludeInChangedArea, NOD
}
}
int old_sc = aOld.SegmentCount();
int old_lc = aOld.LinkCount();
if( aOld.EndsWithVia() )
{
for( auto lnk : aOld.Links() )
@ -151,7 +154,7 @@ void SHOVE::replaceLine( LINE& aOld, LINE& aNew, bool aIncludeInChangedArea, NOD
rootEntry->newLine = aNew;
//assert( rootEntry->newLine->LinkCount() == old_lc)
return rootEntry;
}
@ -1033,13 +1036,17 @@ SHOVE::SHOVE_STATUS SHOVE::pushOrShoveVia( VIA* aVia, const VECTOR2I& aForce, in
if( lp.second.SegmentCount() )
{
lp.second.ClearLinks();
replaceLine( lp.first, lp.second );
ROOT_LINE_ENTRY* rootEntry = replaceLine( lp.first, lp.second );
lp.second.LinkVia( v2 );
unwindLineStack( &lp.second );
lp.second.SetRank( aNewRank );
if( rootEntry )
rootEntry->newLine = lp.second; // fixme: it's inelegant
PNS_DBG( Dbg(), Message, wxString::Format("PushViaF %p %d eov %d\n", &lp.second, lp.second.SegmentCount(), lp.second.EndsWithVia()?1:0 ) );
if( !pushLineStack( lp.second ) ) //, true ) ) // WHY?
@ -2364,6 +2371,7 @@ SHOVE::SHOVE_STATUS SHOVE::Run()
auto headVia = Clone( head.Via() );
headVia->SetRank( 100000 ); // - 100 * currentHeadId );
headLineEntry.origHead->LinkVia( headVia.get() );
head.LinkVia( headVia.get() );
m_currentNode->Add( std::move( headVia ) );
}
@ -2406,18 +2414,16 @@ SHOVE::SHOVE_STATUS SHOVE::Run()
break;
};
PNS_DBG( Dbg(), Message,
wxString::Format( "Shove status : %s after %d iterations, heads: %d",
( ( st == SH_OK || st == SH_HEAD_MODIFIED ) ? "OK" : "FAILURE" ),
m_iter, (int) m_headLines.size() ) );
if( st == SH_OK )
{
//nodeStats( Dbg(), m_currentNode, "pre-opt" );
runOptimizer( m_currentNode );
PNS_DBG( Dbg(), Message,
wxString::Format( "Shove status : %s after %d iterations, heads: %d",
( ( st == SH_OK || st == SH_HEAD_MODIFIED ) ? "OK" : "FAILURE" ),
m_iter, (int) m_headLines.size() ) );
reconstructHeads( false );
removeHeads();

View File

@ -201,7 +201,8 @@ private:
LINE assembleLine( const LINKED_ITEM* aSeg, int* aIndex = nullptr, bool aPreCleanup = false );
void replaceItems( ITEM* aOld, std::unique_ptr< ITEM > aNew );
void replaceLine( LINE& aOld, LINE& aNew, bool aIncludeInChangedArea = true,
ROOT_LINE_ENTRY* replaceLine( LINE& aOld, LINE& aNew,
bool aIncludeInChangedArea = true,
NODE *aNode = nullptr );
ROOT_LINE_ENTRY* findRootLine( const LINE& aLine );