diff --git a/pcbnew/router/pns_dragger.cpp b/pcbnew/router/pns_dragger.cpp index a4d6c1b2c3..e12234e5c5 100644 --- a/pcbnew/router/pns_dragger.cpp +++ b/pcbnew/router/pns_dragger.cpp @@ -210,7 +210,7 @@ void DRAGGER::dumbDragVia( VIA* aVia, NODE* aNode, const VECTOR2I& aP ) m_draggedItems.Add( draggedLine ); - m_lastNode->Remove( &origLine ); + m_lastNode->Remove( origLine ); m_lastNode->Add( draggedLine ); } } diff --git a/pcbnew/router/pns_line_placer.cpp b/pcbnew/router/pns_line_placer.cpp index 46a8bbd0c2..68dd55b555 100644 --- a/pcbnew/router/pns_line_placer.cpp +++ b/pcbnew/router/pns_line_placer.cpp @@ -979,7 +979,7 @@ void LINE_PLACER::removeLoops( NODE* aNode, LINE& aLatest ) for( SEGMENT *s : toErase ) aNode->Remove( s ); - aNode->Remove( &aLatest ); + aNode->Remove( aLatest ); } @@ -993,7 +993,7 @@ void LINE_PLACER::simplifyNewLine( NODE* aNode, SEGMENT* aLatest ) if( simplified.PointCount() != l.PointCount() ) { LINE lnew( l ); - aNode->Remove( &l ); + aNode->Remove( l ); lnew.SetShape( simplified ); aNode->Add( lnew ); } diff --git a/pcbnew/router/pns_meander_placer.cpp b/pcbnew/router/pns_meander_placer.cpp index 6d21ad8691..e0f876d7b2 100644 --- a/pcbnew/router/pns_meander_placer.cpp +++ b/pcbnew/router/pns_meander_placer.cpp @@ -80,7 +80,7 @@ bool MEANDER_PLACER::Start( const VECTOR2I& aP, ITEM* aStartItem ) TOPOLOGY topo( m_world ); m_tunedPath = topo.AssembleTrivialPath( m_initialSegment ); - m_world->Remove( &m_originLine ); + m_world->Remove( m_originLine ); m_currentWidth = m_originLine.Width(); m_currentEnd = VECTOR2I( 0, 0 ); diff --git a/pcbnew/router/pns_meander_skew_placer.cpp b/pcbnew/router/pns_meander_skew_placer.cpp index cfa26c3cd5..ae59b97cd1 100644 --- a/pcbnew/router/pns_meander_skew_placer.cpp +++ b/pcbnew/router/pns_meander_skew_placer.cpp @@ -85,7 +85,7 @@ bool MEANDER_SKEW_PLACER::Start( const VECTOR2I& aP, ITEM* aStartItem ) m_tunedPathP = topo.AssembleTrivialPath( m_originPair.PLine().GetLink( 0 ) ); m_tunedPathN = topo.AssembleTrivialPath( m_originPair.NLine().GetLink( 0 ) ); - m_world->Remove( &m_originLine ); + m_world->Remove( m_originLine ); m_currentWidth = m_originLine.Width(); m_currentEnd = VECTOR2I( 0, 0 ); diff --git a/pcbnew/router/pns_node.cpp b/pcbnew/router/pns_node.cpp index a57e49ca96..4c0600d6fe 100644 --- a/pcbnew/router/pns_node.cpp +++ b/pcbnew/router/pns_node.cpp @@ -1,4 +1,3 @@ -#include "pns_node.h" /* * KiRouter - a push-and-(sometimes-)shove PCB router * @@ -581,7 +580,6 @@ void NODE::Add( LINE& aLine, bool aAllowRedundant ) } } } - } void NODE::addSegment( SEGMENT* aSeg ) @@ -654,29 +652,13 @@ void NODE::doRemove( ITEM* aItem ) } -void NODE::removeSegment( SEGMENT* aSeg ) +void NODE::removeSegmentIndex( SEGMENT* aSeg ) { unlinkJoint( aSeg->Seg().A, aSeg->Layers(), aSeg->Net(), aSeg ); unlinkJoint( aSeg->Seg().B, aSeg->Layers(), aSeg->Net(), aSeg ); - - doRemove( aSeg ); } - -void NODE::removeLine( LINE* aLine ) -{ - std::vector& segRefs = aLine->LinkedSegments(); - - for( SEGMENT* seg : segRefs ) - { - removeSegment( seg ); - } - - aLine->ClearSegmentLinks(); - aLine->SetOwner( nullptr ); -} - -void NODE::removeVia( VIA* aVia ) +void NODE::removeViaIndex( VIA* aVia ) { // We have to split a single joint (associated with a via, binding together multiple layers) // into multiple independent joints. As I'm a lazy bastard, I simply delete the via and all its links and re-insert them. @@ -721,8 +703,11 @@ void NODE::removeVia( VIA* aVia ) if( item != aVia ) linkJoint( p, item->Layers(), net, item ); } +} - doRemove( aVia ); +void NODE::removeSolidIndex( SOLID* aSolid ) +{ + // fixme: this fucks up the joints, but it's only used for marking colliding obstacles for the moment, so we don't care. } @@ -738,25 +723,42 @@ void NODE::Replace( LINE& aOldLine, LINE& aNewLine ) Add( aNewLine ); } +void NODE::Remove( SOLID* aSolid ) +{ + removeSolidIndex( aSolid ); + doRemove( aSolid ); +} + +void NODE::Remove( VIA* aVia ) +{ + removeViaIndex( aVia ); + doRemove( aVia ); +} + +void NODE::Remove( SEGMENT* aSegment ) +{ + removeSegmentIndex( aSegment ); + doRemove( aSegment ); +} + void NODE::Remove( ITEM* aItem ) { switch( aItem->Kind() ) { case ITEM::SOLID_T: - // fixme: this fucks up the joints, but it's only used for marking colliding obstacles for the moment, so we don't care. - doRemove( aItem ); + Remove( static_cast( aItem ) ); break; case ITEM::SEGMENT_T: - removeSegment( static_cast( aItem ) ); + Remove( static_cast( aItem ) ); break; case ITEM::LINE_T: - removeLine( static_cast( aItem ) ); + assert( false ); break; case ITEM::VIA_T: - removeVia( static_cast( aItem ) ); + Remove( static_cast( aItem ) ); break; default: @@ -767,7 +769,16 @@ void NODE::Remove( ITEM* aItem ) void NODE::Remove( LINE& aLine ) { - removeLine( &aLine ); + // LINE does not have a seperate remover, as LINEs are never truly a member of the tree + std::vector& segRefs = aLine.LinkedSegments(); + + for( SEGMENT* seg : segRefs ) + { + Remove( seg ); + } + + aLine.SetOwner( nullptr ); + aLine.ClearSegmentLinks(); } diff --git a/pcbnew/router/pns_node.h b/pcbnew/router/pns_node.h index c1f2efece4..e584e0cfbb 100644 --- a/pcbnew/router/pns_node.h +++ b/pcbnew/router/pns_node.h @@ -289,8 +289,12 @@ public: * Just as the name says, removes an item from this branch. * @param aItem item to remove */ + void Remove( SOLID* aSolid ); + void Remove( VIA* aVia ); + void Remove( SEGMENT* aSegment ); void Remove( ITEM* aItem ); +public: /** * Function Remove() * @@ -440,10 +444,11 @@ private: void addSolid( SOLID* aSeg ); void addSegment( SEGMENT* aSeg ); void addVia( VIA* aVia ); - void removeSolid( SOLID* aSeg ); - void removeLine( LINE* aLine ); - void removeSegment( SEGMENT* aSeg ); - void removeVia( VIA* aVia ); + + void removeLine( LINE& aLine ); + void removeSolidIndex( SOLID* aSeg ); + void removeSegmentIndex( SEGMENT* aSeg ); + void removeViaIndex( VIA* aVia ); void doRemove( ITEM* aItem ); void unlinkParent(); diff --git a/pcbnew/router/pns_shove.cpp b/pcbnew/router/pns_shove.cpp index a46000dd1c..3bd35671f6 100644 --- a/pcbnew/router/pns_shove.cpp +++ b/pcbnew/router/pns_shove.cpp @@ -697,7 +697,7 @@ SHOVE::SHOVE_STATUS SHOVE::pushVia( VIA* aVia, const VECTOR2I& aForce, int aCurr } else { - m_currentNode->Remove( &lp.first ); + m_currentNode->Remove( lp.first ); } #ifdef DEBUG @@ -1382,7 +1382,7 @@ void SHOVE::runOptimizer( NODE* aNode ) if( optimizer.Optimize( &line, &optimized ) ) { - aNode->Remove( &line ); + aNode->Remove( line ); line.SetShape( optimized.CLine() ); aNode->Add( line ); } @@ -1409,7 +1409,7 @@ const LINE SHOVE::NewHead() const void SHOVE::SetInitialLine( LINE& aInitial ) { m_root = m_root->Branch(); - m_root->Remove( &aInitial ); + m_root->Remove( aInitial ); } } diff --git a/pcbnew/router/pns_topology.cpp b/pcbnew/router/pns_topology.cpp index 2948b29eac..5eca29b31c 100644 --- a/pcbnew/router/pns_topology.cpp +++ b/pcbnew/router/pns_topology.cpp @@ -48,7 +48,7 @@ bool TOPOLOGY::SimplifyLine( LINE* aLine ) if( simplified.PointCount() != l.PointCount() ) { LINE lnew( l ); - m_world->Remove( &l ); + m_world->Remove( l ); lnew.SetShape( simplified ); m_world->Add( lnew ); return true;