router: more verbose debug messages for the debugger tool

This commit is contained in:
Tomasz Wlostowski 2022-06-03 22:53:13 +02:00
parent 3aed13278d
commit aca9cce5d5
2 changed files with 79 additions and 16 deletions

View File

@ -117,6 +117,7 @@ bool LINE_PLACER::handleSelfIntersections()
if( tail.CPoint(0) == head.CPoint(0) )
{
m_p_start = tail.CPoint( 0 );
PNS_DBG( Dbg(), AddPoint, m_p_start, WHITE, 10000, wxT( "new-pstart [sameP0]" ) );
m_direction = m_initial_direction;
tail.Clear();
return true;
@ -151,6 +152,8 @@ bool LINE_PLACER::handleSelfIntersections()
if( n < 2 )
{
m_p_start = tail.CPoint( 0 );
PNS_DBG( Dbg(), AddPoint, m_p_start, WHITE, 10000, wxT( "new-pstart [self-isect1]" ) );
m_direction = m_initial_direction;
tail.Clear();
head.Clear();
@ -163,6 +166,8 @@ bool LINE_PLACER::handleSelfIntersections()
// Set the direction to the one of this segment.
const SEG last = tail.CSegment( n - 1 );
m_p_start = last.A;
PNS_DBG( Dbg(), AddPoint, m_p_start, WHITE, 10000, wxT( "new-pstart [self-isect2]" ) );
m_direction = DIRECTION_45( last );
tail.Remove( n, -1 );
return true;
@ -189,6 +194,8 @@ bool LINE_PLACER::handlePullback()
else if( n == 1 )
{
m_p_start = tail.CPoint( 0 );
PNS_DBG( Dbg(), AddPoint, m_p_start, WHITE, 10000, wxT( "new-pstart [pullback]" ) );
tail.Clear();
return true;
}
@ -229,6 +236,8 @@ bool LINE_PLACER::handlePullback()
const SEG& seg = tail.CSegment( lastSegIdx );
m_direction = DIRECTION_45( seg );
m_p_start = seg.A;
PNS_DBG( Dbg(), AddPoint, m_p_start, WHITE, 10000, wxT( "new-pstart [pullback3]" ) );
}
else
{
@ -310,6 +319,8 @@ bool LINE_PLACER::reduceTail( const VECTOR2I& aEnd )
SHAPE_LINE_CHAIN reducedLine = new_direction.BuildInitialTrace( new_start, aEnd );
m_p_start = new_start;
PNS_DBG( Dbg(), AddPoint, m_p_start, WHITE, 10000, wxT( "new-pstart [reduceTail]" ) );
m_direction = new_direction;
tail.Remove( reduce_index + 1, -1 );
head.Clear();
@ -381,6 +392,9 @@ bool LINE_PLACER::mergeHead()
SEG last = tail.CSegment( -1 );
m_p_start = last.B;
PNS_DBG( Dbg(), AddPoint, m_p_start, WHITE, 10000, wxT( "new-pstart [mergeHead]" ) );
int lastSegIdx = tail.PointCount() - 2;
if( !tail.IsArcSegment( lastSegIdx ) )
@ -390,8 +404,8 @@ bool LINE_PLACER::mergeHead()
head.Remove( 0, -1 );
wxLogTrace( wxT( "PNS" ), wxT( "Placer: merge %d, new direction: %s" ), n_head,
m_direction.Format().c_str() );
// wxLogTrace( wxT( "PNS" ), wxT( "Placer: merge %d, new direction: %s" ), n_head,
// m_direction.Format().c_str() );
head.Simplify();
tail.Simplify();
@ -851,12 +865,12 @@ bool LINE_PLACER::optimizeTailHeadTransition()
m_head = linetmp;
m_p_start = linetmp.CLine().CPoint( 0 );
PNS_DBG( Dbg(), AddPoint, m_p_start, WHITE, 10000, wxT( "new-pstart [optFanoutCleanup]" ) );
m_direction = DIRECTION_45( linetmp.CSegment( 0 ) );
m_tail.Line().Clear();
PNS_DBG( Dbg(), Message, wxString::Format( "Placer: optimize fanout-cleanup" ) );
return true;
}
@ -893,13 +907,14 @@ bool LINE_PLACER::optimizeTailHeadTransition()
{
LINE tmp( m_tail, opt_line );
PNS_DBG( Dbg(), Message, wxString::Format( "Placer: optimize tail-head [%d]", threshold ) );
head.Clear();
tail.Replace( -threshold, -1, new_head.CLine() );
tail.Simplify();
m_p_start = new_head.CLine().CPoint( -1 );
PNS_DBG( Dbg(), AddPoint, m_p_start, WHITE, 10000, wxT( "new-pstart [opt-tail-head]" ) );
m_direction = DIRECTION_45( new_head.CSegment( -1 ) );
return true;
@ -943,7 +958,7 @@ void LINE_PLACER::routeStep( const VECTOR2I& aP )
fail = true;
}
PNS_DBG( Dbg(), AddItem, &new_head, LIGHTGREEN, 100000, wxT( "new_head" ) );
PNS_DBG( Dbg(), AddItem, &new_head, LIGHTGREEN, 100000, wxString::Format( "new_head [fail: %d]", fail?1:0 ) );
if( fail )
break;
@ -974,6 +989,7 @@ void LINE_PLACER::routeStep( const VECTOR2I& aP )
if( m_last_head.PointCount() > 0 )
{
m_head = m_last_head;
PNS_DBG( Dbg(), AddItem, &m_last_head, CYAN, 10000, wxT( "apply-last-head" ) );
}
else
{
@ -1707,6 +1723,9 @@ bool LINE_PLACER::buildInitialLine( const VECTOR2I& aP, LINE& aHead, bool aForce
if( m_orthoMode )
cornerMode = DIRECTION_45::CORNER_MODE::MITERED_45;
PNS_DBG( Dbg(), AddPoint, m_p_start, WHITE, 10000, wxT( "pstart [buildInitial]" ) );
if( m_p_start == aP )
{
l.Clear();
@ -1737,6 +1756,9 @@ bool LINE_PLACER::buildInitialLine( const VECTOR2I& aP, LINE& aHead, bool aForce
aHead.SetLayer( m_currentLayer );
aHead.SetShape( l );
PNS_DBG( Dbg(), AddItem, &aHead, CYAN, 10000, wxT( "initial-trace" ) );
if( !m_placingVia || aForceNoVia )
return true;

View File

@ -292,9 +292,9 @@ SHOVE::SHOVE_STATUS SHOVE::shoveLineToHullSet( const LINE& aCurLine, const LINE&
{
const SHAPE_LINE_CHAIN& hull = aHulls[invertTraversal ? aHulls.size() - 1 - i : i];
PNS_DBG( Dbg(), AddShape, &hull, YELLOW, 10000, wxT( "hull" ) );
PNS_DBG( Dbg(), AddShape, &path, WHITE, l.Width(), wxT( "path" ) );
PNS_DBG( Dbg(), AddShape, &obs, LIGHTGRAY, aObstacleLine.Width(), wxT( "obs" ) );
PNS_DBG( Dbg(), AddShape, &hull, YELLOW, 10000, wxString::Format( "hull[%d]", i ) );
PNS_DBG( Dbg(), AddShape, &path, WHITE, l.Width(), wxString::Format( "path[%d]", i ) );
PNS_DBG( Dbg(), AddShape, &obs, LIGHTGRAY, aObstacleLine.Width(), wxString::Format( "obs[%d]", i ) );
if( !l.Walkaround( hull, path, clockwise ) )
{
@ -307,7 +307,12 @@ SHOVE::SHOVE_STATUS SHOVE::shoveLineToHullSet( const LINE& aCurLine, const LINE&
return SH_INCOMPLETE;
}
PNS_DBG( Dbg(), AddShape, &path, WHITE, l.Width(), wxString::Format( "path-presimp[%d]", i ) );
path.Simplify();
PNS_DBG( Dbg(), AddShape, &path, WHITE, l.Width(), wxString::Format( "path-postsimp[%d]", i ) );
l.SetShape( path );
}
@ -435,10 +440,8 @@ SHOVE::SHOVE_STATUS SHOVE::ShoveObstacleLine( const LINE& aCurLine, const LINE&
hulls.reserve( currentLineSegmentCount + 1 );
#ifdef DEBUG
Dbg()->Message( wxString::Format( wxT( "shove process-single: cur net %d obs %d cl %d" ),
PNS_DBG( Dbg(), Message, wxString::Format( wxT( "shove process-single: cur net %d obs %d cl %d" ),
aCurLine.Net(), aObstacleLine.Net(), clearance ) );
#endif
for( int i = 0; i < currentLineSegmentCount; i++ )
{
@ -449,6 +452,12 @@ SHOVE::SHOVE_STATUS SHOVE::ShoveObstacleLine( const LINE& aCurLine, const LINE&
if( aCurLine.CLine().IsArcSegment( i ) )
extra = SHAPE_ARC::DefaultAccuracyForPCB();
if( extra > 0 )
{
PNS_DBG( Dbg(), Message, wxString::Format( wxT( "shove add-extra-clearance %d" ),
extra ) );
}
SHAPE_LINE_CHAIN hull =
seg.Hull( clearance + extra, obstacleLineWidth, aObstacleLine.Layer() );
@ -673,6 +682,19 @@ SHOVE::SHOVE_STATUS SHOVE::onCollidingSolid( LINE& aCurrent, ITEM* aObstacle, OB
std::set<ITEM*> cluster = topo.AssembleCluster( aObstacle, aCurrent.Layers().Start() );
PNS_DBG( Dbg(), BeginGroup, "walk-cluster", 1 );
for( auto item : cluster )
{
PNS_DBG( Dbg(), AddItem, item, RED, 10000, wxT( "cl-item" ) );
}
PNS_DBGN( Dbg(), EndGroup );
walkaround.SetDebugDecorator( Dbg() );
walkaround.SetSolidsOnly( false );
walkaround.RestrictToSet( true, cluster );
walkaround.SetIterationLimit( 16 ); // fixme: make configurable
@ -969,6 +991,8 @@ SHOVE::SHOVE_STATUS SHOVE::pushOrShoveVia( VIA* aVia, const VECTOR2I& aForce, in
*/
SHOVE::SHOVE_STATUS SHOVE::onCollidingVia( ITEM* aCurrent, VIA* aObstacleVia, OBSTACLE& aObstacleInfo )
{
assert( aObstacleVia );
int clearance = getClearance( aCurrent, aObstacleVia );
VECTOR2I mtv;
int rank = -1;
@ -991,6 +1015,12 @@ SHOVE::SHOVE_STATUS SHOVE::onCollidingVia( ITEM* aCurrent, VIA* aObstacleVia, OB
LINE* currentLine = (LINE*) aCurrent;
PNS_DBG( Dbg(), AddItem, currentLine, LIGHTRED, 10000, wxT( "current-line" ) );
if( currentLine->EndsWithVia() )
{
PNS_DBG( Dbg(), AddItem, &currentLine->Via(), LIGHTRED, 10000, wxT( "current-line-via" ) );
}
PNS_DBG( Dbg(), AddItem, &vtmp, LIGHTRED, 100000, wxT( "orig-via" ) );
lineCollision = vtmp.Shape()->Collide( currentLine->Shape(),
@ -1021,6 +1051,7 @@ SHOVE::SHOVE_STATUS SHOVE::onCollidingVia( ITEM* aCurrent, VIA* aObstacleVia, OB
mtv = VECTOR2I(0, 0);
SHOVE::SHOVE_STATUS st = pushOrShoveVia( aObstacleVia, -mtv, aCurrent->Rank() );
PNS_DBG(Dbg(), Message, wxString::Format("push-or-shove-via st %d", st ) );
PNS_DBGN( Dbg(), EndGroup );
@ -1163,7 +1194,11 @@ void SHOVE::unwindLineStack( ITEM* aItem )
bool SHOVE::pushLineStack( const LINE& aL, bool aKeepCurrentOnTop )
{
if( !aL.IsLinkedChecked() && aL.SegmentCount() != 0 )
{
PNS_DBG( Dbg(), AddItem, &aL, BLUE, 10000, wxT( "push line stack failed" ) );
return false;
}
if( aKeepCurrentOnTop && m_lineStack.size() > 0)
{
@ -1304,10 +1339,14 @@ SHOVE::SHOVE_STATUS SHOVE::shoveIteration( int aIter )
nearest = m_currentNode->NearestObstacle( &currentLine, search_order );
if( nearest )
{
PNS_DBG( Dbg(), Message,
wxString::Format( wxT( "nearest %p %s rank %d" ), nearest->m_item,
nearest->m_item->KindStr(), nearest->m_item->Rank() ) );
PNS_DBG( Dbg(), AddShape, nearest->m_item->Shape(), YELLOW, 10000, wxT("nearest") );
}
if( nearest )
break;
}
@ -1361,7 +1400,6 @@ SHOVE::SHOVE_STATUS SHOVE::shoveIteration( int aIter )
popLineStack();
st = onCollidingLine( revLine, currentLine );
PNS_DBGN( Dbg(), EndGroup );
if( !pushLineStack( revLine ) )
{
@ -1369,6 +1407,8 @@ SHOVE::SHOVE_STATUS SHOVE::shoveIteration( int aIter )
}
PNS_DBGN( Dbg(), EndGroup );
break;
}
@ -1425,7 +1465,8 @@ SHOVE::SHOVE_STATUS SHOVE::shoveIteration( int aIter )
break;
case ITEM::VIA_T:
PNS_DBG( Dbg(), BeginGroup, wxString::Format( "iter %d: collide-via (fixup: %d)", aIter, 0 ), 0 ); st = onCollidingVia( &currentLine, (VIA*) ni, nearest.get() );
PNS_DBG( Dbg(), BeginGroup, wxString::Format( "iter %d: collide-via (fixup: %d)", aIter, 0 ), 0 );
st = onCollidingVia( &currentLine, (VIA*) ni, nearest.get() );
if( st == SH_TRY_WALK )
st = onCollidingSolid( currentLine, ni, nearest.get() );