Add Remove overloads for specific item types, split removal into index-handling and lifetime-handling (not 100% correct yet, since the index is defactor lifetime-owner, it will be later.)
This commit is contained in:
parent
94fae5d6a1
commit
94aaa47583
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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<SEGMENT*>& 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<SOLID*>( aItem ) );
|
||||
break;
|
||||
|
||||
case ITEM::SEGMENT_T:
|
||||
removeSegment( static_cast<SEGMENT*>( aItem ) );
|
||||
Remove( static_cast<SEGMENT*>( aItem ) );
|
||||
break;
|
||||
|
||||
case ITEM::LINE_T:
|
||||
removeLine( static_cast<LINE*>( aItem ) );
|
||||
assert( false );
|
||||
break;
|
||||
|
||||
case ITEM::VIA_T:
|
||||
removeVia( static_cast<VIA*>( aItem ) );
|
||||
Remove( static_cast<VIA*>( 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<SEGMENT*>& segRefs = aLine.LinkedSegments();
|
||||
|
||||
for( SEGMENT* seg : segRefs )
|
||||
{
|
||||
Remove( seg );
|
||||
}
|
||||
|
||||
aLine.SetOwner( nullptr );
|
||||
aLine.ClearSegmentLinks();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue