router: fixes for disappearing segments after shoving & assertion in PNS_NODE destructor

This commit is contained in:
Tomasz Wlostowski 2015-09-14 18:40:29 +02:00 committed by Maciej Suminski
parent 463b8b4127
commit 5bbf980ec7
5 changed files with 30 additions and 19 deletions

View File

@ -71,7 +71,7 @@ public:
m_tag.net = aB.m_tag.net; m_tag.net = aB.m_tag.net;
m_linkedItems = aB.m_linkedItems; m_linkedItems = aB.m_linkedItems;
m_layers = aB.m_layers; m_layers = aB.m_layers;
m_locked = false; m_locked = aB.m_locked;
} }
PNS_ITEM* Clone( ) const PNS_ITEM* Clone( ) const
@ -194,6 +194,9 @@ public:
m_layers.Merge( aJoint.m_layers ); m_layers.Merge( aJoint.m_layers );
if( aJoint.IsLocked() )
m_locked = true;
BOOST_FOREACH( PNS_ITEM* item, aJoint.LinkList() ) BOOST_FOREACH( PNS_ITEM* item, aJoint.LinkList() )
{ {
m_linkedItems.Add( item ); m_linkedItems.Add( item );

View File

@ -871,6 +871,10 @@ bool PNS_LINE_PLACER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem )
{ {
m_lastNode->Add( pl.Via().Clone() ); m_lastNode->Add( pl.Via().Clone() );
Router()->CommitRouting( m_lastNode ); Router()->CommitRouting( m_lastNode );
m_lastNode = NULL;
m_currentNode = NULL;
m_idle = true; m_idle = true;
} }
@ -913,6 +917,7 @@ bool PNS_LINE_PLACER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem )
Router()->CommitRouting( m_lastNode ); Router()->CommitRouting( m_lastNode );
m_lastNode = NULL; m_lastNode = NULL;
m_currentNode = NULL;
if( !realEnd ) if( !realEnd )
{ {

View File

@ -111,7 +111,7 @@ PNS_NODE* PNS_NODE::Branch()
TRACE( 0, "PNS_NODE::branch %p (parent %p)", child % this ); TRACE( 0, "PNS_NODE::branch %p (parent %p)", child % this );
m_children.push_back( child ); m_children.insert( child );
child->m_depth = m_depth + 1; child->m_depth = m_depth + 1;
child->m_parent = this; child->m_parent = this;
@ -145,15 +145,7 @@ void PNS_NODE::unlinkParent()
if( isRoot() ) if( isRoot() )
return; return;
for( std::vector<PNS_NODE*>::iterator i = m_parent->m_children.begin(); m_parent->m_children.erase( this );
i != m_parent->m_children.end(); ++i )
{
if( *i == this )
{
m_parent->m_children.erase( i );
return;
}
}
} }
@ -1125,7 +1117,7 @@ void PNS_NODE::GetUpdatedItems( ITEM_VECTOR& aRemoved, ITEM_VECTOR& aAdded )
void PNS_NODE::releaseChildren() void PNS_NODE::releaseChildren()
{ {
// copy the kids as the PNS_NODE destructor erases the item from the parent node. // copy the kids as the PNS_NODE destructor erases the item from the parent node.
std::vector<PNS_NODE*> kids = m_children; std::set<PNS_NODE*> kids = m_children;
BOOST_FOREACH( PNS_NODE* node, kids ) BOOST_FOREACH( PNS_NODE* node, kids )
{ {

View File

@ -383,6 +383,11 @@ public:
PNS_ITEM* FindItemByParent( const BOARD_CONNECTED_ITEM *aParent ); PNS_ITEM* FindItemByParent( const BOARD_CONNECTED_ITEM *aParent );
bool HasChildren() const
{
return !m_children.empty();
}
private: private:
struct OBSTACLE_VISITOR; struct OBSTACLE_VISITOR;
typedef boost::unordered_multimap<PNS_JOINT::HASH_TAG, PNS_JOINT> JOINT_MAP; typedef boost::unordered_multimap<PNS_JOINT::HASH_TAG, PNS_JOINT> JOINT_MAP;
@ -454,7 +459,7 @@ private:
PNS_NODE* m_root; PNS_NODE* m_root;
///> list of nodes branched from this one ///> list of nodes branched from this one
std::vector<PNS_NODE*> m_children; std::set<PNS_NODE*> m_children;
///> hash of root's items that have been changed in this node ///> hash of root's items that have been changed in this node
boost::unordered_set<PNS_ITEM*> m_override; boost::unordered_set<PNS_ITEM*> m_override;

View File

@ -963,7 +963,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::shoveIteration( int aIter )
} }
} }
else else
{ // "forward" collisoins { // "forward" collisions
switch( ni->Kind() ) switch( ni->Kind() )
{ {
case PNS_ITEM::SEGMENT: case PNS_ITEM::SEGMENT:
@ -1098,17 +1098,23 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveLines( const PNS_LINE& aCurrentHead )
} }
if( !pushLine( head ) ) if( !pushLine( head ) )
{
delete m_currentNode;
m_currentNode = parent;
return SH_INCOMPLETE; return SH_INCOMPLETE;
}
st = shoveMainLoop(); st = shoveMainLoop();
if( st == SH_OK )
if( ( st == SH_OK || st == SH_HEAD_MODIFIED ) ) {
runOptimizer( m_currentNode ); runOptimizer( m_currentNode );
if( m_newHead && st == SH_OK ) if( m_newHead )
{ st = m_currentNode->CheckColliding( &(*m_newHead) ) ? SH_INCOMPLETE : SH_HEAD_MODIFIED;
st = SH_HEAD_MODIFIED; else
st = m_currentNode->CheckColliding( &head ) ? SH_INCOMPLETE : SH_OK;
} }
m_currentNode->RemoveByMarker( MK_HEAD ); m_currentNode->RemoveByMarker( MK_HEAD );