From 52e193ededcc102cd4a96d17437b37d673d3f0c4 Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Thu, 2 Jul 2015 16:09:32 +0200 Subject: [PATCH] router: fixing assert --- pcbnew/router/pns_node.cpp | 6 ----- pcbnew/router/pns_router.cpp | 2 -- pcbnew/router/pns_shove.cpp | 43 +++++++++++++++++++----------------- pcbnew/router/pns_shove.h | 2 +- 4 files changed, 24 insertions(+), 29 deletions(-) diff --git a/pcbnew/router/pns_node.cpp b/pcbnew/router/pns_node.cpp index 2a36991ec6..831dc79cd2 100644 --- a/pcbnew/router/pns_node.cpp +++ b/pcbnew/router/pns_node.cpp @@ -632,11 +632,6 @@ void PNS_NODE::removeLine( PNS_LINE* aLine ) assert( segRefs != NULL ); assert( aLine->Owner() ); - if( (int) segRefs->size() != aLine->SegmentCount() ) - { - //printf("******weird deletion: segrefs %d segcount %d hasloops %d\n", segRefs->size(), aLine->SegmentCount(), aLine->HasLoops()); - } - BOOST_FOREACH( PNS_SEGMENT* seg, *segRefs ) { removeSegment( seg ); @@ -822,7 +817,6 @@ PNS_LINE* PNS_NODE::AssembleLine( PNS_SEGMENT* aSeg, int* aOriginSegmentIndex) } assert( pl->SegmentCount() != 0 ); - assert( pl->SegmentCount() == (int) pl->LinkedSegments()->size() ); return pl; } diff --git a/pcbnew/router/pns_router.cpp b/pcbnew/router/pns_router.cpp index 1603bd7d9a..6ad61e2af0 100644 --- a/pcbnew/router/pns_router.cpp +++ b/pcbnew/router/pns_router.cpp @@ -435,8 +435,6 @@ const PNS_ITEMSET PNS_ROUTER::QueryHoverItems( const VECTOR2I& aP ) return m_world->HitTest( aP ); else { - //assert ( m_placer->GetCurrentNode()->checkExists() ); - //TRACE(0,"query-hover [%p]", m_placer->GetCurrentNode()); return m_placer->CurrentNode()->HitTest( aP ); } } diff --git a/pcbnew/router/pns_shove.cpp b/pcbnew/router/pns_shove.cpp index c6373b78f5..496bfec671 100644 --- a/pcbnew/router/pns_shove.cpp +++ b/pcbnew/router/pns_shove.cpp @@ -50,8 +50,6 @@ void PNS_SHOVE::replaceItems( PNS_ITEM* aOld, PNS_ITEM* aNew ) if( changed_area ) { - assert( !changed_area->Contains( VECTOR2I( 0, 0 ) ) ); - m_affectedAreaSum = m_affectedAreaSum ? m_affectedAreaSum->Merge ( *changed_area ) : *changed_area; } @@ -339,7 +337,8 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingSegment( PNS_LINE* aCurrent, PNS_S int rank = aCurrent->Rank(); shovedLine->SetRank( rank - 1 ); - pushLine( shovedLine ); + if (!pushLine( shovedLine ) ) + rv = SH_INCOMPLETE; } #ifdef DEBUG @@ -377,7 +376,8 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingLine( PNS_LINE* aCurrent, PNS_LINE int rank = aObstacle->Rank(); shovedLine->SetRank ( rank ); - pushLine( shovedLine ); + if( !pushLine( shovedLine ) ) + rv = SH_INCOMPLETE; #ifdef DEBUG m_logger.NewGroup( "on-colliding-line", m_iter ); @@ -466,7 +466,8 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingSolid( PNS_LINE* aCurrent, PNS_SOL #endif popLine(); - pushLine( walkaroundLine ); + if ( !pushLine( walkaroundLine ) ) + return SH_INCOMPLETE; return SH_OK; } @@ -619,7 +620,8 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::pushVia( PNS_VIA* aVia, const VECTOR2I& aForc { replaceItems( lp.first, lp.second ); lp.second->SetRank( aCurrentRank - 1 ); - pushLine( lp.second ); + if (! pushLine( lp.second ) ) + return SH_INCOMPLETE; } else m_currentNode->Remove( lp.first ); @@ -758,7 +760,9 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onReverseCollidingVia( PNS_LINE* aCurrent, PN int currentRank = aCurrent->Rank(); replaceItems( aCurrent, shoved ); - pushLine( shoved ); + if ( !pushLine( shoved ) ) + return SH_INCOMPLETE; + shoved->SetRank( currentRank ); return SH_OK; @@ -802,21 +806,15 @@ void PNS_SHOVE::unwindStack( PNS_ITEM* aItem ) } -void PNS_SHOVE::pushLine( PNS_LINE* aL ) +bool PNS_SHOVE::pushLine( PNS_LINE* aL ) { if( aL->LinkCount() >= 0 && ( aL->LinkCount() != aL->SegmentCount() ) ) - { - printf("LC: %d SC %d\n", aL->LinkCount(), aL->SegmentCount() ); - for(int i=0;iSegmentCount();i++) - { - SEG s = aL->CLine().CSegment(i); - printf("s %d: %d %d %d %d\n", i, s.A.x, s.A.y, s.B.x, s.B.y ); - } - assert( false ); - } + return false; m_lineStack.push_back( aL ); m_optimizerQueue.push_back( aL ); + + return true; } @@ -893,7 +891,9 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::shoveIteration( int aIter ) popLine(); st = onCollidingLine( revLine, currentLine ); - pushLine( revLine ); + if ( !pushLine( revLine ) ) + return SH_INCOMPLETE; + break; } @@ -1024,7 +1024,9 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveLines( const PNS_LINE& aCurrentHead ) m_logger.Log( headVia, 0, "head-via" ); } - pushLine( head ); + if ( !pushLine( head ) ) + return SH_INCOMPLETE; + st = shoveMainLoop(); runOptimizer( m_currentNode, head ); @@ -1095,7 +1097,8 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveMultiLines( const PNS_ITEMSET& aHeadSet head->Mark( MK_HEAD ); head->SetRank( 100000 ); n++; - pushLine( head ); + if ( !pushLine( head ) ) + return SH_INCOMPLETE; PNS_VIA* headVia = NULL; diff --git a/pcbnew/router/pns_shove.h b/pcbnew/router/pns_shove.h index f7ea6e517f..39800893a6 100644 --- a/pcbnew/router/pns_shove.h +++ b/pcbnew/router/pns_shove.h @@ -122,7 +122,7 @@ private: void runOptimizer( PNS_NODE* aNode, PNS_LINE* aHead ); - void pushLine( PNS_LINE* aL ); + bool pushLine( PNS_LINE* aL ); void popLine(); PNS_LINE* assembleLine( const PNS_SEGMENT* aSeg, int* aIndex = NULL );