router: fixing assert

This commit is contained in:
Tomasz Wlostowski 2015-07-02 16:09:32 +02:00 committed by Maciej Suminski
parent e6dd016cb2
commit 52e193eded
4 changed files with 24 additions and 29 deletions

View File

@ -632,11 +632,6 @@ void PNS_NODE::removeLine( PNS_LINE* aLine )
assert( segRefs != NULL ); assert( segRefs != NULL );
assert( aLine->Owner() ); 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 ) BOOST_FOREACH( PNS_SEGMENT* seg, *segRefs )
{ {
removeSegment( seg ); removeSegment( seg );
@ -822,7 +817,6 @@ PNS_LINE* PNS_NODE::AssembleLine( PNS_SEGMENT* aSeg, int* aOriginSegmentIndex)
} }
assert( pl->SegmentCount() != 0 ); assert( pl->SegmentCount() != 0 );
assert( pl->SegmentCount() == (int) pl->LinkedSegments()->size() );
return pl; return pl;
} }

View File

@ -435,8 +435,6 @@ const PNS_ITEMSET PNS_ROUTER::QueryHoverItems( const VECTOR2I& aP )
return m_world->HitTest( aP ); return m_world->HitTest( aP );
else else
{ {
//assert ( m_placer->GetCurrentNode()->checkExists() );
//TRACE(0,"query-hover [%p]", m_placer->GetCurrentNode());
return m_placer->CurrentNode()->HitTest( aP ); return m_placer->CurrentNode()->HitTest( aP );
} }
} }

View File

@ -50,8 +50,6 @@ void PNS_SHOVE::replaceItems( PNS_ITEM* aOld, PNS_ITEM* aNew )
if( changed_area ) if( changed_area )
{ {
assert( !changed_area->Contains( VECTOR2I( 0, 0 ) ) );
m_affectedAreaSum = m_affectedAreaSum ? m_affectedAreaSum->Merge ( *changed_area ) : *changed_area; 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(); int rank = aCurrent->Rank();
shovedLine->SetRank( rank - 1 ); shovedLine->SetRank( rank - 1 );
pushLine( shovedLine ); if (!pushLine( shovedLine ) )
rv = SH_INCOMPLETE;
} }
#ifdef DEBUG #ifdef DEBUG
@ -377,7 +376,8 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingLine( PNS_LINE* aCurrent, PNS_LINE
int rank = aObstacle->Rank(); int rank = aObstacle->Rank();
shovedLine->SetRank ( rank ); shovedLine->SetRank ( rank );
pushLine( shovedLine ); if( !pushLine( shovedLine ) )
rv = SH_INCOMPLETE;
#ifdef DEBUG #ifdef DEBUG
m_logger.NewGroup( "on-colliding-line", m_iter ); 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 #endif
popLine(); popLine();
pushLine( walkaroundLine ); if ( !pushLine( walkaroundLine ) )
return SH_INCOMPLETE;
return SH_OK; 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 ); replaceItems( lp.first, lp.second );
lp.second->SetRank( aCurrentRank - 1 ); lp.second->SetRank( aCurrentRank - 1 );
pushLine( lp.second ); if (! pushLine( lp.second ) )
return SH_INCOMPLETE;
} }
else else
m_currentNode->Remove( lp.first ); m_currentNode->Remove( lp.first );
@ -758,7 +760,9 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onReverseCollidingVia( PNS_LINE* aCurrent, PN
int currentRank = aCurrent->Rank(); int currentRank = aCurrent->Rank();
replaceItems( aCurrent, shoved ); replaceItems( aCurrent, shoved );
pushLine( shoved ); if ( !pushLine( shoved ) )
return SH_INCOMPLETE;
shoved->SetRank( currentRank ); shoved->SetRank( currentRank );
return SH_OK; 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() ) ) if( aL->LinkCount() >= 0 && ( aL->LinkCount() != aL->SegmentCount() ) )
{ return false;
printf("LC: %d SC %d\n", aL->LinkCount(), aL->SegmentCount() );
for(int i=0;i<aL->SegmentCount();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 );
}
m_lineStack.push_back( aL ); m_lineStack.push_back( aL );
m_optimizerQueue.push_back( aL ); m_optimizerQueue.push_back( aL );
return true;
} }
@ -893,7 +891,9 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::shoveIteration( int aIter )
popLine(); popLine();
st = onCollidingLine( revLine, currentLine ); st = onCollidingLine( revLine, currentLine );
pushLine( revLine ); if ( !pushLine( revLine ) )
return SH_INCOMPLETE;
break; break;
} }
@ -1024,7 +1024,9 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveLines( const PNS_LINE& aCurrentHead )
m_logger.Log( headVia, 0, "head-via" ); m_logger.Log( headVia, 0, "head-via" );
} }
pushLine( head ); if ( !pushLine( head ) )
return SH_INCOMPLETE;
st = shoveMainLoop(); st = shoveMainLoop();
runOptimizer( m_currentNode, head ); runOptimizer( m_currentNode, head );
@ -1095,7 +1097,8 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveMultiLines( const PNS_ITEMSET& aHeadSet
head->Mark( MK_HEAD ); head->Mark( MK_HEAD );
head->SetRank( 100000 ); head->SetRank( 100000 );
n++; n++;
pushLine( head ); if ( !pushLine( head ) )
return SH_INCOMPLETE;
PNS_VIA* headVia = NULL; PNS_VIA* headVia = NULL;

View File

@ -122,7 +122,7 @@ private:
void runOptimizer( PNS_NODE* aNode, PNS_LINE* aHead ); void runOptimizer( PNS_NODE* aNode, PNS_LINE* aHead );
void pushLine( PNS_LINE* aL ); bool pushLine( PNS_LINE* aL );
void popLine(); void popLine();
PNS_LINE* assembleLine( const PNS_SEGMENT* aSeg, int* aIndex = NULL ); PNS_LINE* assembleLine( const PNS_SEGMENT* aSeg, int* aIndex = NULL );