use unique_ptr at client <-> pns-router border, to document the pns router is taking ownership

add overloads for NODE::Add( ... ) taking pointers to specific item types (retain old private add-Functions, they will come in handy later)
LINE overloads now take by reference, to document their special treatment.
updated code throughout affected by these changes
This commit is contained in:
decimad 2016-08-30 17:28:35 +02:00 committed by Maciej Suminski
parent 2aef1a4568
commit 96a3145543
15 changed files with 195 additions and 121 deletions

View File

@ -778,8 +778,8 @@ bool DIFF_PAIR_PLACER::FixRoute( const VECTOR2I& aP, ITEM* aEndItem )
if( m_currentTrace.EndsWithVias() )
{
m_lastNode->Add( m_currentTrace.PLine().Via().Clone() );
m_lastNode->Add( m_currentTrace.NLine().Via().Clone() );
m_lastNode->Add( Clone( m_currentTrace.PLine().Via() ) );
m_lastNode->Add( Clone( m_currentTrace.NLine().Via() ) );
m_chainedPlacement = false;
}
else
@ -790,8 +790,8 @@ bool DIFF_PAIR_PLACER::FixRoute( const VECTOR2I& aP, ITEM* aEndItem )
LINE lineP( m_currentTrace.PLine() );
LINE lineN( m_currentTrace.NLine() );
m_lastNode->Add( &lineP );
m_lastNode->Add( &lineN );
m_lastNode->Add( lineP );
m_lastNode->Add( lineN );
topo.SimplifyLine( &lineP );
topo.SimplifyLine( &lineN );

View File

@ -307,8 +307,8 @@ bool DP_MEANDER_PLACER::FixRoute( const VECTOR2I& aP, ITEM* aEndItem )
LINE lP( m_originPair.PLine(), m_finalShapeP );
LINE lN( m_originPair.NLine(), m_finalShapeN );
m_currentNode->Add( &lP );
m_currentNode->Add( &lN );
m_currentNode->Add( lP );
m_currentNode->Add( lN );
Router()->CommitRouting( m_currentNode );

View File

@ -158,7 +158,7 @@ bool DRAGGER::dragMarkObstacles( const VECTOR2I& aP )
m_lastValidDraggedLine.ClearSegmentLinks();
m_lastValidDraggedLine.Unmark();
m_lastNode->Add( &m_lastValidDraggedLine );
m_lastNode->Add( m_lastValidDraggedLine );
m_draggedItems.Clear();
m_draggedItems.Add( m_lastValidDraggedLine );
@ -188,13 +188,15 @@ void DRAGGER::dumbDragVia( VIA* aVia, NODE* aNode, const VECTOR2I& aP )
m_draggedItems.Clear();
// fixme: this is awful.
m_draggedVia = aVia->Clone();
auto via_clone = Clone( *aVia );
m_draggedVia = via_clone.get();
m_draggedVia->SetPos( aP );
m_draggedItems.Add( m_draggedVia );
m_lastNode->Remove( aVia );
m_lastNode->Add( m_draggedVia );
m_lastNode->Add( std::move( via_clone ) );
for( ITEM* item : m_origViaConnections.Items() )
{
@ -209,7 +211,7 @@ void DRAGGER::dumbDragVia( VIA* aVia, NODE* aNode, const VECTOR2I& aP )
m_draggedItems.Add( draggedLine );
m_lastNode->Remove( &origLine );
m_lastNode->Add( &draggedLine );
m_lastNode->Add( draggedLine );
}
}
}
@ -255,7 +257,7 @@ bool DRAGGER::dragShove( const VECTOR2I& aP )
m_lastValidDraggedLine.ClearSegmentLinks();
m_lastValidDraggedLine.Unmark();
m_lastNode->Add( &m_lastValidDraggedLine );
m_lastNode->Add( m_lastValidDraggedLine );
m_draggedItems.Clear();
m_draggedItems.Add( m_lastValidDraggedLine );

View File

@ -22,6 +22,7 @@
#ifndef __PNS_ITEM_H
#define __PNS_ITEM_H
#include <memory>
#include <math/vector2d.h>
#include <geometry/shape.h>
@ -354,6 +355,21 @@ protected:
int m_rank;
};
template< typename T, typename S >
std::unique_ptr< T > ItemCast( std::unique_ptr< S > aPtr )
{
static_assert(std::is_base_of< ITEM, S >::value, "Need to be handed a ITEM!");
static_assert(std::is_base_of< ITEM, T >::value, "Need to cast to an ITEM!");
return std::unique_ptr< T >( static_cast<T*>(aPtr.release()) );
}
template< typename T >
std::unique_ptr< typename std::remove_const< T >::type > Clone( const T& aItem )
{
static_assert(std::is_base_of< ITEM, T >::value, "Need to be handed an ITEM!");
return std::unique_ptr< typename std::remove_const< T >::type >( aItem.Clone() );
}
}
#endif // __PNS_ITEM_H

View File

@ -429,7 +429,7 @@ PNS_KICAD_IFACE::~PNS_KICAD_IFACE()
}
PNS::ITEM* PNS_KICAD_IFACE::syncPad( D_PAD* aPad )
std::unique_ptr< PNS::SOLID > PNS_KICAD_IFACE::syncPad( D_PAD* aPad )
{
LAYER_RANGE layers( 0, MAX_CU_LAYERS - 1 );
@ -472,7 +472,7 @@ PNS::ITEM* PNS_KICAD_IFACE::syncPad( D_PAD* aPad )
return NULL;
}
PNS::SOLID* solid = new PNS::SOLID;
std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );
solid->SetLayers( layers );
solid->SetNet( aPad->GetNetCode() );
@ -564,8 +564,7 @@ PNS::ITEM* PNS_KICAD_IFACE::syncPad( D_PAD* aPad )
default:
wxLogTrace( "PNS", "unsupported pad shape" );
delete solid;
return NULL;
return nullptr;
}
}
else
@ -661,9 +660,7 @@ PNS::ITEM* PNS_KICAD_IFACE::syncPad( D_PAD* aPad )
default:
wxLogTrace( "PNS", "unsupported pad shape" );
delete solid;
return NULL;
return nullptr;
}
}
}
@ -671,33 +668,44 @@ PNS::ITEM* PNS_KICAD_IFACE::syncPad( D_PAD* aPad )
}
PNS::ITEM* PNS_KICAD_IFACE::syncTrack( TRACK* aTrack )
std::unique_ptr< PNS::SEGMENT > PNS_KICAD_IFACE::syncTrack( TRACK* aTrack )
{
PNS::SEGMENT* s =
new PNS::SEGMENT( SEG( aTrack->GetStart(), aTrack->GetEnd() ), aTrack->GetNetCode() );
std::unique_ptr< PNS::SEGMENT > segment(
new PNS::SEGMENT( SEG( aTrack->GetStart(), aTrack->GetEnd() ), aTrack->GetNetCode() )
);
s->SetWidth( aTrack->GetWidth() );
s->SetLayers( LAYER_RANGE( aTrack->GetLayer() ) );
s->SetParent( aTrack );
return s;
segment->SetWidth( aTrack->GetWidth() );
segment->SetLayers( LAYER_RANGE( aTrack->GetLayer() ) );
segment->SetParent( aTrack );
if( aTrack->IsLocked() ) {
segment->Mark( PNS::MK_LOCKED );
}
return segment;
}
PNS::ITEM* PNS_KICAD_IFACE::syncVia( VIA* aVia )
std::unique_ptr< PNS::VIA > PNS_KICAD_IFACE::syncVia( VIA* aVia )
{
LAYER_ID top, bottom;
aVia->LayerPair( &top, &bottom );
PNS::VIA* v = new PNS::VIA(
std::unique_ptr<PNS::VIA> via( new PNS::VIA(
aVia->GetPosition(),
LAYER_RANGE( top, bottom ),
aVia->GetWidth(),
aVia->GetDrillValue(),
aVia->GetNetCode(),
aVia->GetViaType() );
aVia->GetViaType() )
);
v->SetParent( aVia );
via->SetParent( aVia );
return v;
if( aVia->IsLocked() ) {
via->Mark( PNS::MK_LOCKED );
}
return via;
}
@ -720,10 +728,10 @@ void PNS_KICAD_IFACE::SyncWorld( PNS::NODE *aWorld )
{
for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
{
PNS::ITEM* solid = syncPad( pad );
std::unique_ptr< PNS::SOLID > solid = syncPad( pad );
if( solid )
aWorld->Add( solid );
aWorld->Add( std::move( solid ) );
}
}
@ -732,16 +740,17 @@ void PNS_KICAD_IFACE::SyncWorld( PNS::NODE *aWorld )
KICAD_T type = t->Type();
PNS::ITEM* item = NULL;
if( type == PCB_TRACE_T )
item = syncTrack( t );
else if( type == PCB_VIA_T )
item = syncVia( static_cast<VIA*>( t ) );
if( t->IsLocked() )
item->Mark( PNS::MK_LOCKED );
if( item )
aWorld->Add( item );
if( type == PCB_TRACE_T ) {
std::unique_ptr< PNS::SEGMENT > segment = syncTrack( t );
if( segment ) {
aWorld->Add( std::move( segment ) );
}
} else if( type == PCB_VIA_T ) {
std::unique_ptr< PNS::VIA > via = syncVia( static_cast<VIA*>( t ) );
if( via ) {
aWorld->Add( std::move( via ) );
}
}
}
int worstClearance = m_board->GetDesignSettings().GetBiggestClearanceValue();

View File

@ -62,9 +62,9 @@ private:
PNS_PCBNEW_RULE_RESOLVER* m_ruleResolver;
PNS_PCBNEW_DEBUG_DECORATOR* m_debugDecorator;
PNS::ITEM* syncPad( D_PAD* aPad );
PNS::ITEM* syncTrack( TRACK* aTrack );
PNS::ITEM* syncVia( VIA* aVia );
std::unique_ptr< PNS::SOLID > syncPad( D_PAD* aPad );
std::unique_ptr< PNS::SEGMENT > syncTrack( TRACK* aTrack );
std::unique_ptr< PNS::VIA > syncVia( VIA* aVia );
KIGFX::VIEW* m_view;
KIGFX::VIEW_GROUP* m_previewItems;

View File

@ -697,17 +697,18 @@ void LINE_PLACER::splitAdjacentSegments( NODE* aNode, ITEM* aSeg, const VECTOR2I
return;
SEGMENT* s_old = static_cast<SEGMENT*>( aSeg );
SEGMENT* s_new[2];
s_new[0] = s_old->Clone();
s_new[1] = s_old->Clone();
std::unique_ptr< SEGMENT > s_new[2] = {
Clone( *s_old ),
Clone( *s_old )
};
s_new[0]->SetEnds( s_old->Seg().A, aP );
s_new[1]->SetEnds( aP, s_old->Seg().B );
aNode->Remove( s_old );
aNode->Add( s_new[0], true );
aNode->Add( s_new[1], true );
aNode->Add( std::move( s_new[0] ), true );
aNode->Add( std::move( s_new[1] ), true );
}
@ -861,7 +862,7 @@ bool LINE_PLACER::FixRoute( const VECTOR2I& aP, ITEM* aEndItem )
{
if( pl.EndsWithVia() )
{
m_lastNode->Add( pl.Via().Clone() );
m_lastNode->Add( Clone( pl.Via() ) );
Router()->CommitRouting( m_lastNode );
m_lastNode = NULL;
@ -893,15 +894,15 @@ bool LINE_PLACER::FixRoute( const VECTOR2I& aP, ITEM* aEndItem )
for( int i = 0; i < lastV; i++ )
{
const SEG& s = pl.CSegment( i );
SEGMENT* seg = new SEGMENT( s, m_currentNet );
std::unique_ptr< SEGMENT > seg( new SEGMENT( s, m_currentNet ) );
seg->SetWidth( pl.Width() );
seg->SetLayer( m_currentLayer );
m_lastNode->Add( seg );
lastSeg = seg;
lastSeg = seg.get();
m_lastNode->Add( std::move( seg ) );
}
if( pl.EndsWithVia() )
m_lastNode->Add( pl.Via().Clone() );
m_lastNode->Add( Clone( pl.Via() ) );
if( realEnd )
simplifyNewLine( m_lastNode, lastSeg );
@ -938,7 +939,7 @@ void LINE_PLACER::removeLoops( NODE* aNode, LINE& aLatest )
return;
std::set<SEGMENT *> toErase;
aNode->Add( &aLatest, true );
aNode->Add( aLatest, true );
for( int s = 0; s < aLatest.LinkCount(); s++ )
{
@ -994,7 +995,7 @@ void LINE_PLACER::simplifyNewLine( NODE* aNode, SEGMENT* aLatest )
LINE lnew( l );
aNode->Remove( &l );
lnew.SetShape( simplified );
aNode->Add( &lnew );
aNode->Add( lnew );
}
}

View File

@ -194,7 +194,7 @@ bool MEANDER_PLACER::FixRoute( const VECTOR2I& aP, ITEM* aEndItem )
return false;
m_currentTrace = LINE( m_originLine, m_finalShape );
m_currentNode->Add( &m_currentTrace );
m_currentNode->Add( m_currentTrace );
Router()->CommitRouting( m_currentNode );
return true;

View File

@ -535,6 +535,11 @@ void NODE::addSolid( SOLID* aSolid )
m_index->Add( aSolid );
}
void NODE::Add( std::unique_ptr< SOLID > aSolid )
{
aSolid->SetOwner( this );
addSolid( aSolid.release() );
}
void NODE::addVia( VIA* aVia )
{
@ -542,10 +547,15 @@ void NODE::addVia( VIA* aVia )
m_index->Add( aVia );
}
void NODE::addLine( LINE* aLine, bool aAllowRedundant )
void NODE::Add( std::unique_ptr< VIA > aVia )
{
SHAPE_LINE_CHAIN& l = aLine->Line();
aVia->SetOwner( this );
addVia( aVia.release() );
}
void NODE::addLine( LINE& aLine, bool aAllowRedundant )
{
SHAPE_LINE_CHAIN& l = aLine.Line();
for( int i = 0; i < l.SegmentCount(); i++ )
{
@ -553,7 +563,7 @@ void NODE::addLine( LINE* aLine, bool aAllowRedundant )
if( s.A != s.B )
{
SEGMENT* pseg = new SEGMENT( *aLine, s );
SEGMENT* pseg = new SEGMENT( aLine, s );
SEGMENT* psegR = NULL;
if( !aAllowRedundant )
@ -561,7 +571,7 @@ void NODE::addLine( LINE* aLine, bool aAllowRedundant )
if( psegR )
{
aLine->LinkSegment( psegR );
aLine.LinkSegment( psegR );
delete pseg;
}
@ -569,10 +579,10 @@ void NODE::addLine( LINE* aLine, bool aAllowRedundant )
{
pseg->SetOwner( this );
linkJoint( s.A, pseg->Layers(), aLine->Net(), pseg );
linkJoint( s.B, pseg->Layers(), aLine->Net(), pseg );
linkJoint( s.A, pseg->Layers(), aLine.Net(), pseg );
linkJoint( s.B, pseg->Layers(), aLine.Net(), pseg );
aLine->LinkSegment( pseg );
aLine.LinkSegment( pseg );
m_index->Add( pseg );
}
@ -580,47 +590,52 @@ void NODE::addLine( LINE* aLine, bool aAllowRedundant )
}
}
void NODE::addSegment( SEGMENT* aSeg, bool aAllowRedundant )
void NODE::Add( LINE& aLine, bool aAllowRedundant )
{
if( aSeg->Seg().A == aSeg->Seg().B )
{
wxLogTrace( "PNS", "attempting to add a segment with same end coordinates, ignoring." );
return;
addLine( aLine, aAllowRedundant );
}
if( !aAllowRedundant && findRedundantSegment( aSeg ) )
return;
aSeg->SetOwner( this );
void NODE::addSegment( SEGMENT* aSeg )
{
linkJoint( aSeg->Seg().A, aSeg->Layers(), aSeg->Net(), aSeg );
linkJoint( aSeg->Seg().B, aSeg->Layers(), aSeg->Net(), aSeg );
m_index->Add( aSeg );
}
void NODE::Add( ITEM* aItem, bool aAllowRedundant )
void NODE::Add( std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant )
{
aItem->SetOwner( this );
if( aSegment->Seg().A == aSegment->Seg().B )
{
wxLogTrace( "PNS", "attempting to add a segment with same end coordinates, ignoring." );
return;
}
if( !aAllowRedundant && findRedundantSegment( aSegment.get() ) )
return;
aSegment->SetOwner( this );
addSegment( aSegment.release() );
}
void NODE::Add( std::unique_ptr< ITEM > aItem, bool aAllowRedundant )
{
switch( aItem->Kind() )
{
case ITEM::SOLID_T:
addSolid( static_cast<SOLID*>( aItem ) );
Add( ItemCast<SOLID>( std::move( aItem ) ) );
break;
case ITEM::SEGMENT_T:
addSegment( static_cast<SEGMENT*>( aItem ), aAllowRedundant );
Add( ItemCast<SEGMENT>( std::move( aItem ) ), aAllowRedundant );
break;
case ITEM::LINE_T:
addLine( static_cast<LINE*>( aItem ), aAllowRedundant );
assert( false );
break;
case ITEM::VIA_T:
addVia( static_cast<VIA*>( aItem ) );
Add( ItemCast<VIA>( std::move( aItem ) ) );
break;
default:
@ -719,12 +734,17 @@ void NODE::removeVia( VIA* aVia )
}
void NODE::Replace( ITEM* aOldItem, ITEM* aNewItem )
void NODE::Replace( ITEM* aOldItem, std::unique_ptr< ITEM > aNewItem )
{
Remove( aOldItem );
Add( aNewItem );
Add( std::move( aNewItem ) );
}
void NODE::Replace( LINE& aOldLine, LINE& aNewLine )
{
Remove( aOldLine );
Add( aNewLine );
}
void NODE::Remove( ITEM* aItem )
{
@ -1184,7 +1204,7 @@ void NODE::Commit( NODE* aNode )
{
(*i)->SetRank( -1 );
(*i)->Unmark();
Add( *i );
Add( std::unique_ptr<ITEM>( *i ) );
}
releaseChildren();

View File

@ -273,8 +273,16 @@ public:
* @param aAllowRedundant if true, duplicate items are allowed (e.g. a segment or via
* at the same coordinates as an existing one)
*/
void Add( ITEM* aItem, bool aAllowRedundant = false );
void Add( std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant = false );
void Add( std::unique_ptr< SOLID > aSolid );
void Add( std::unique_ptr< VIA > aVia );
void Add( LINE& aLine, bool aAllowRedundant = false );
private:
void Add( std::unique_ptr< ITEM > aItem, bool aAllowRedundant = false );
public:
/**
* Function Remove()
*
@ -298,7 +306,8 @@ public:
* @param aOldItem item to be removed
* @param aNewItem item add instead
*/
void Replace( ITEM* aOldItem, ITEM* aNewItem );
void Replace( ITEM* aOldItem, std::unique_ptr< ITEM > aNewItem );
void Replace( LINE& aOldLine, LINE& aNewLine );
/**
* Function Branch()
@ -429,8 +438,8 @@ private:
///> helpers for adding/removing items
void addSolid( SOLID* aSeg );
void addSegment( SEGMENT* aSeg, bool aAllowRedundant );
void addLine( LINE* aLine, bool aAllowRedundant );
void addSegment( SEGMENT* aSeg );
void addLine( LINE& aLine, bool aAllowRedundant );
void addVia( VIA* aVia );
void removeSolid( SOLID* aSeg );
void removeLine( LINE* aLine );

View File

@ -45,7 +45,19 @@
namespace PNS {
void SHOVE::replaceItems( ITEM* aOld, ITEM* aNew )
void SHOVE::replaceItems( ITEM* aOld, std::unique_ptr< ITEM > aNew )
{
OPT_BOX2I changed_area = ChangedArea( aOld, aNew.get() );
if( changed_area )
{
m_affectedAreaSum = m_affectedAreaSum ? m_affectedAreaSum->Merge( *changed_area ) : *changed_area;
}
m_currentNode->Replace( aOld, std::move( aNew ) );
}
void SHOVE::replaceLine( LINE& aOld, LINE& aNew )
{
OPT_BOX2I changed_area = ChangedArea( aOld, aNew );
@ -57,7 +69,6 @@ void SHOVE::replaceItems( ITEM* aOld, ITEM* aNew )
m_currentNode->Replace( aOld, aNew );
}
int SHOVE::getClearance( const ITEM* aA, const ITEM* aB ) const
{
if( m_forceClearance >= 0 )
@ -349,7 +360,7 @@ SHOVE::SHOVE_STATUS SHOVE::onCollidingSegment( LINE& aCurrent, SEGMENT* aObstacl
shovedLine.SetRank( rank - 1 );
sanityCheck( &obstacleLine, &shovedLine );
replaceItems( &obstacleLine, &shovedLine );
replaceLine( obstacleLine, shovedLine );
if( !pushLine( shovedLine ) )
rv = SH_INCOMPLETE;
@ -383,7 +394,7 @@ SHOVE::SHOVE_STATUS SHOVE::onCollidingLine( LINE& aCurrent, LINE& aObstacle )
}
sanityCheck( &aObstacle, &shovedLine );
replaceItems( &aObstacle, &shovedLine );
replaceLine( aObstacle, shovedLine );
int rank = aObstacle.Rank();
shovedLine.SetRank( rank - 1 );
@ -508,7 +519,7 @@ SHOVE::SHOVE_STATUS SHOVE::onCollidingSolid( LINE& aCurrent, ITEM* aObstacle )
if(!success)
return SH_INCOMPLETE;
replaceItems( &aCurrent, &walkaroundLine );
replaceLine( aCurrent, walkaroundLine );
walkaroundLine.SetRank( nextRank );
#ifdef DEBUG
@ -607,13 +618,13 @@ SHOVE::SHOVE_STATUS SHOVE::pushVia( VIA* aVia, const VECTOR2I& aForce, int aCurr
p0_pushed += aForce.Resize( 2 ); // make sure pushed via does not overlap with any existing joint
}
VIA* pushedVia = aVia->Clone();
std::unique_ptr< VIA > pushedVia = Clone( *aVia );
pushedVia->SetPos( p0_pushed );
pushedVia->Mark( aVia->Marker() );
if( aVia->Marker() & MK_HEAD )
{
m_draggedVia = pushedVia;
m_draggedVia = pushedVia.get();
m_draggedViaHeadSet.Clear();
}
@ -645,19 +656,19 @@ SHOVE::SHOVE_STATUS SHOVE::pushVia( VIA* aVia, const VECTOR2I& aForce, int aCurr
}
}
m_draggedViaHeadSet.Add( pushedVia );
m_draggedViaHeadSet.Add( pushedVia.get() );
if( aDryRun )
return SH_OK;
replaceItems( aVia, pushedVia );
#ifdef DEBUG
m_logger.Log( aVia, 0, "obstacle-via" );
#endif
pushedVia->SetRank( aCurrentRank - 1 );
replaceItems( aVia, std::move( pushedVia ) );
#ifdef DEBUG
m_logger.Log( pushedVia, 1, "pushed-via" );
#endif
@ -678,7 +689,7 @@ SHOVE::SHOVE_STATUS SHOVE::pushVia( VIA* aVia, const VECTOR2I& aForce, int aCurr
if( lp.second.SegmentCount() )
{
replaceItems( &lp.first, &lp.second );
replaceLine( lp.first, lp.second );
lp.second.SetRank( aCurrentRank - 1 );
if( !pushLine( lp.second, true ) )
@ -820,7 +831,7 @@ SHOVE::SHOVE_STATUS SHOVE::onReverseCollidingVia( LINE& aCurrent, VIA* aObstacle
m_logger.Log( &shoved, 3, "shoved-line" );
#endif
int currentRank = aCurrent.Rank();
replaceItems( &aCurrent, &shoved );
replaceLine( aCurrent, shoved );
if( !pushLine( shoved ) )
return SH_INCOMPLETE;
@ -1092,7 +1103,7 @@ SHOVE::SHOVE_STATUS SHOVE::ShoveLines( const LINE& aCurrentHead )
m_currentNode = parent->Branch();
m_currentNode->ClearRanks();
m_currentNode->Add( &head );
m_currentNode->Add( head );
m_currentNode->LockJoint( head.CPoint(0), &head, true );
@ -1105,15 +1116,13 @@ SHOVE::SHOVE_STATUS SHOVE::ShoveLines( const LINE& aCurrentHead )
m_logger.NewGroup( "initial", 0 );
m_logger.Log( &head, 0, "head" );
VIA* headVia = NULL;
if( head.EndsWithVia() )
{
headVia = head.Via().Clone();
m_currentNode->Add( headVia );
std::unique_ptr< VIA >headVia = Clone( head.Via() );
headVia->Mark( MK_HEAD );
headVia->SetRank( 100000 );
m_logger.Log( headVia, 0, "head-via" );
m_logger.Log( headVia.get(), 0, "head-via" );
m_currentNode->Add( std::move( headVia ) );
}
if( !pushLine( head ) )
@ -1204,7 +1213,7 @@ SHOVE::SHOVE_STATUS SHOVE::ShoveMultiLines( const ITEM_SET& aHeadSet )
LINE head( *headOrig );
head.ClearSegmentLinks();
m_currentNode->Add( &head );
m_currentNode->Add( head );
head.Mark( MK_HEAD );
head.SetRank( 100000 );
@ -1217,11 +1226,11 @@ SHOVE::SHOVE_STATUS SHOVE::ShoveMultiLines( const ITEM_SET& aHeadSet )
if( head.EndsWithVia() )
{
headVia = head.Via().Clone(); // fixme: leak
m_currentNode->Add( headVia );
std::unique_ptr< VIA > headVia = Clone( head.Via() );
headVia->Mark( MK_HEAD );
headVia->SetRank( 100000 );
m_logger.Log( headVia, 0, "head-via" );
m_logger.Log( headVia.get(), 0, "head-via" );
m_currentNode->Add( std::move( headVia ) );
}
}
@ -1375,7 +1384,7 @@ void SHOVE::runOptimizer( NODE* aNode )
{
aNode->Remove( &line );
line.SetShape( optimized.CLine() );
aNode->Add( &line );
aNode->Add( line );
}
}
}

View File

@ -131,7 +131,8 @@ private:
LINE assembleLine( const SEGMENT* aSeg, int* aIndex = NULL );
void replaceItems( ITEM* aOld, ITEM* aNew );
void replaceItems( ITEM* aOld, std::unique_ptr< ITEM > aNew );
void replaceLine( LINE& aOld, LINE& aNew );
OPT_BOX2I m_affectedAreaSum;

View File

@ -50,7 +50,7 @@ bool TOPOLOGY::SimplifyLine( LINE* aLine )
LINE lnew( l );
m_world->Remove( &l );
lnew.SetShape( simplified );
m_world->Add( &lnew );
m_world->Add( lnew );
return true;
}
@ -102,7 +102,7 @@ bool TOPOLOGY::LeadingRatLine( const LINE* aTrack, SHAPE_LINE_CHAIN& aRatLine )
return false;
std::unique_ptr<NODE> tmpNode( m_world->Branch() );
tmpNode->Add( &track );
tmpNode->Add( track );
JOINT* jt = tmpNode->FindJoint( track.CPoint( -1 ), &track );

View File

@ -248,4 +248,9 @@ OPT_BOX2I ChangedArea( const ITEM* aItemA, const ITEM* aItemB )
return OPT_BOX2I();
}
OPT_BOX2I ChangedArea( const LINE& aLineA, const LINE& aLineB )
{
return aLineA.ChangedArea( &aLineB );
}
}

View File

@ -34,6 +34,7 @@ namespace PNS {
constexpr int HULL_MARGIN = 10;
class ITEM;
class LINE;
/** Various utility functions */
@ -55,14 +56,15 @@ const SHAPE_LINE_CHAIN ConvexHull( const SHAPE_CONVEX& convex, int aClearance );
SHAPE_RECT ApproximateSegmentAsRect( const SHAPE_SEGMENT& aSeg );
#if 0
OPT_BOX2I ChangedArea( const ITEM* aItemA, const ITEM* aItemB );
OPT_BOX2I ChangedArea( const LINE& aLineA, const LINE& aLineB );
#if 0
void DrawDebugPoint( VECTOR2I aP, int aColor );
void DrawDebugBox( BOX2I aB, int aColor );
void DrawDebugSeg( SEG aS, int aColor );
void DrawDebugDirs( VECTOR2D aP, int aMask, int aColor );
#endif
OPT_BOX2I ChangedArea( const ITEM* aItemA, const ITEM* aItemB );
}