router: clear head line geometry if current head routing failed + small improvement to follow-mouse optimization.

Also added a lot of verbosity for the pns-log-viewer tool.

Fixes: 8511
This commit is contained in:
Tomasz Wlostowski 2021-05-31 00:18:42 +02:00
parent dfd80e077c
commit 614787caae
1 changed files with 45 additions and 10 deletions

View File

@ -820,6 +820,8 @@ bool LINE_PLACER::optimizeTailHeadTransition()
{ {
LINE linetmp = Trace(); LINE linetmp = Trace();
PNS_DBG( Dbg(), Message, "optimize HT" );
if( OPTIMIZER::Optimize( &linetmp, OPTIMIZER::FANOUT_CLEANUP, m_currentNode ) ) if( OPTIMIZER::Optimize( &linetmp, OPTIMIZER::FANOUT_CLEANUP, m_currentNode ) )
{ {
if( linetmp.SegmentCount() < 1 ) if( linetmp.SegmentCount() < 1 )
@ -830,6 +832,9 @@ bool LINE_PLACER::optimizeTailHeadTransition()
m_direction = DIRECTION_45( linetmp.CSegment( 0 ) ); m_direction = DIRECTION_45( linetmp.CSegment( 0 ) );
m_tail.Line().Clear(); m_tail.Line().Clear();
PNS_DBG( Dbg(), Message, wxString::Format( "Placer: optimize fanout-cleanup" ) );
return true; return true;
} }
@ -859,11 +864,14 @@ bool LINE_PLACER::optimizeTailHeadTransition()
// If so, replace the (threshold) last tail points and the head with // If so, replace the (threshold) last tail points and the head with
// the optimized line // the optimized line
if( OPTIMIZER::Optimize( &new_head, OPTIMIZER::MERGE_OBTUSE, m_currentNode ) )
PNS_DBG( Dbg(), AddLine, new_head.CLine(), LIGHTCYAN, 10000, "ht-newline" );
if( OPTIMIZER::Optimize( &new_head, OPTIMIZER::MERGE_SEGMENTS, m_currentNode ) )
{ {
LINE tmp( m_tail, opt_line ); LINE tmp( m_tail, opt_line );
wxLogTrace( "PNS", "Placer: optimize tail-head [%d]", threshold ); PNS_DBG( Dbg(), Message, wxString::Format( "Placer: optimize tail-head [%d]", threshold ) );
head.Clear(); head.Clear();
tail.Replace( -threshold, -1, new_head.CLine() ); tail.Replace( -threshold, -1, new_head.CLine() );
@ -893,11 +901,19 @@ void LINE_PLACER::routeStep( const VECTOR2I& aP )
m_head.ShapeCount(), m_head.ShapeCount(),
m_tail.ShapeCount() ); m_tail.ShapeCount() );
PNS_DBG( Dbg(), BeginGroup, "route-step" );
PNS_DBG( Dbg(), AddLine, m_tail.CLine(), WHITE, 10000, "tail-init" );
PNS_DBG( Dbg(), AddLine, m_head.CLine(), GREEN, 10000, "head-init" );
for( i = 0; i < n_iter; i++ ) for( i = 0; i < n_iter; i++ )
{ {
if( !go_back && Settings().FollowMouse() ) if( !go_back && Settings().FollowMouse() )
reduceTail( aP ); reduceTail( aP );
PNS_DBG( Dbg(), AddLine, m_tail.CLine(), WHITE, 10000, "tail-after-reduce" );
PNS_DBG( Dbg(), AddLine, m_head.CLine(), GREEN, 10000, "head-after-reduce" );
go_back = false; go_back = false;
if( !routeHead( aP, new_head ) ) if( !routeHead( aP, new_head ) )
@ -907,12 +923,11 @@ void LINE_PLACER::routeStep( const VECTOR2I& aP )
fail = true; fail = true;
if( fail ) if( fail )
return; break;
m_head = new_head; m_head = new_head;
if( !Settings().FollowMouse() ) PNS_DBG( Dbg(), AddLine, m_head.CLine(), LIGHTGREEN, 100000, "head-new" );
return;
if( handleSelfIntersections() ) if( handleSelfIntersections() )
{ {
@ -920,20 +935,40 @@ void LINE_PLACER::routeStep( const VECTOR2I& aP )
go_back = true; go_back = true;
} }
PNS_DBG( Dbg(), AddLine, m_tail.CLine(), WHITE, 10000, "tail-after-si" );
PNS_DBG( Dbg(), AddLine, m_head.CLine(), GREEN, 10000, "head-after-si" );
if( !go_back && handlePullback() ) if( !go_back && handlePullback() )
{ {
n_iter++; n_iter++;
go_back = true; go_back = true;
} }
PNS_DBG( Dbg(), AddLine, m_tail.CLine(), WHITE, 100000, "tail-after-pb" );
PNS_DBG( Dbg(), AddLine, m_head.CLine(), GREEN, 100000, "head-after-pb" );
} }
if( !fail ) if( fail )
{ {
if( optimizeTailHeadTransition() ) m_head.RemoveVia();
return; m_head.Clear();
mergeHead();
} }
if( !fail && Settings().FollowMouse() )
{
PNS_DBG( Dbg(), AddLine, m_tail.CLine(), WHITE, 10000, "tail-pre-merge" );
PNS_DBG( Dbg(), AddLine, m_head.CLine(), GREEN, 10000, "head-pre-merge" );
if( !optimizeTailHeadTransition() )
{
mergeHead();
}
PNS_DBG( Dbg(), AddLine, m_tail.CLine(), WHITE, 100000, "tail-post-merge" );
PNS_DBG( Dbg(), AddLine, m_head.CLine(), GREEN, 100000, "head-post-merge" );
}
PNS_DBGN( Dbg(), EndGroup );
} }