PNS: fix some weirdness identified by PVS
This commit is contained in:
parent
e0f26fd525
commit
c9040a5c53
|
@ -30,7 +30,9 @@
|
|||
namespace PNS {
|
||||
|
||||
DRAGGER::DRAGGER( ROUTER* aRouter ) :
|
||||
DRAG_ALGO( aRouter )
|
||||
DRAG_ALGO( aRouter ),
|
||||
m_initialVia( {} ),
|
||||
m_draggedVia( {} )
|
||||
{
|
||||
m_world = NULL;
|
||||
m_lastNode = NULL;
|
||||
|
|
|
@ -32,14 +32,14 @@ ITEM_SET::~ITEM_SET()
|
|||
void ITEM_SET::Add( const LINE& aLine )
|
||||
{
|
||||
LINE* copy = aLine.Clone();
|
||||
m_items.push_back( ENTRY( copy, true ) );
|
||||
m_items.emplace_back( ENTRY( copy, true ) );
|
||||
}
|
||||
|
||||
|
||||
void ITEM_SET::Prepend( const LINE& aLine )
|
||||
{
|
||||
LINE* copy = aLine.Clone();
|
||||
m_items.insert( m_items.begin(), ENTRY( copy, true ) );
|
||||
m_items.emplace( m_items.begin(), ENTRY( copy, true ) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ public:
|
|||
ITEM_SET( ITEM* aInitialItem = NULL, bool aBecomeOwner = false )
|
||||
{
|
||||
if( aInitialItem )
|
||||
m_items.push_back( ENTRY( aInitialItem, aBecomeOwner ) );
|
||||
m_items.emplace_back( ENTRY( aInitialItem, aBecomeOwner ) );
|
||||
}
|
||||
|
||||
ITEM_SET( const ITEM_SET& aOther )
|
||||
|
@ -119,7 +119,7 @@ public:
|
|||
int n = 0;
|
||||
|
||||
if( aKindMask == -1 || aKindMask == ITEM::ANY_T )
|
||||
return m_items.size();
|
||||
return static_cast<int>( m_items.size() );
|
||||
|
||||
for( ITEM* item : m_items )
|
||||
{
|
||||
|
@ -162,15 +162,15 @@ public:
|
|||
|
||||
int Size() const
|
||||
{
|
||||
return m_items.size();
|
||||
return static_cast<int>( m_items.size() );
|
||||
}
|
||||
|
||||
void Add( const LINE& aLine );
|
||||
void Prepend( const LINE& aLine );
|
||||
|
||||
ITEM* operator[] ( int index ) const
|
||||
ITEM* operator[]( size_t aIndex ) const
|
||||
{
|
||||
return m_items[index].item;
|
||||
return m_items[aIndex].item;
|
||||
}
|
||||
|
||||
ENTRIES::iterator begin() { return m_items.begin(); }
|
||||
|
@ -180,12 +180,12 @@ public:
|
|||
|
||||
void Add( ITEM* aItem, bool aBecomeOwner = false )
|
||||
{
|
||||
m_items.push_back( ENTRY( aItem, aBecomeOwner ) );
|
||||
m_items.emplace_back( ENTRY( aItem, aBecomeOwner ) );
|
||||
}
|
||||
|
||||
void Prepend( ITEM* aItem, bool aBecomeOwner = false )
|
||||
{
|
||||
m_items.insert( m_items.begin(), ENTRY( aItem, aBecomeOwner ) );
|
||||
m_items.emplace( m_items.begin(), ENTRY( aItem, aBecomeOwner ) );
|
||||
}
|
||||
|
||||
void Clear()
|
||||
|
|
|
@ -697,7 +697,7 @@ public:
|
|||
|
||||
~PNS_PCBNEW_DEBUG_DECORATOR()
|
||||
{
|
||||
Clear();
|
||||
PNS_PCBNEW_DEBUG_DECORATOR::Clear();
|
||||
delete m_items;
|
||||
}
|
||||
|
||||
|
|
|
@ -361,8 +361,9 @@ bool LINE::Walkaround( const SHAPE_LINE_CHAIN& aObstacle, SHAPE_LINE_CHAIN& aPat
|
|||
// current vertex lies on the hull? first look for the hull/path vertex with the index (N+1)
|
||||
for( VERTEX* vn: v->neighbours)
|
||||
{
|
||||
|
||||
if( vn->type == ON_EDGE && (vn->indexp == (v->indexp + 1) ) && ( (vn->indexh == (v->indexh + 1) ) % hnew.PointCount() ) )
|
||||
if( vn->type == ON_EDGE &&
|
||||
( vn->indexp == ( v->indexp + 1 ) ) &&
|
||||
( vn->indexh == ( ( v->indexh + 1 ) % hnew.PointCount() ) ) )
|
||||
{
|
||||
v_next = vn;
|
||||
break;
|
||||
|
@ -388,7 +389,7 @@ bool LINE::Walkaround( const SHAPE_LINE_CHAIN& aObstacle, SHAPE_LINE_CHAIN& aPat
|
|||
{
|
||||
for( VERTEX* vn: v->neighbours)
|
||||
{
|
||||
if ( v->type == ON_EDGE )
|
||||
if ( vn->type == ON_EDGE )
|
||||
{
|
||||
if( vn->indexh == ( (v->indexh + 1) % hnew.PointCount() ) )
|
||||
{
|
||||
|
|
|
@ -47,9 +47,10 @@ void LOGGER::Save( const std::string& aFilename )
|
|||
|
||||
wxLogTrace( "PNS", "Saving to '%s' [%p]", aFilename.c_str(), f );
|
||||
|
||||
for( const auto evt : m_events )
|
||||
for( const EVENT_ENTRY& evt : m_events )
|
||||
{
|
||||
uint64_t id = 0;
|
||||
|
||||
if( evt.item && evt.item->Parent() )
|
||||
{
|
||||
const char* idString = evt.item->Parent()->m_Uuid.AsString().c_str();
|
||||
|
|
|
@ -201,7 +201,6 @@ struct NODE::DEFAULT_OBSTACLE_VISITOR : public OBSTACLE_VISITOR
|
|||
int m_kindMask; ///< (solids, vias, segments, etc...)
|
||||
int m_limitCount;
|
||||
int m_matchCount;
|
||||
int m_extraClearance;
|
||||
bool m_differentNetsOnly;
|
||||
|
||||
DEFAULT_OBSTACLE_VISITOR( NODE::OBSTACLES& aTab, const ITEM* aItem, int aKindMask,
|
||||
|
@ -211,7 +210,6 @@ struct NODE::DEFAULT_OBSTACLE_VISITOR : public OBSTACLE_VISITOR
|
|||
m_kindMask( aKindMask ),
|
||||
m_limitCount( -1 ),
|
||||
m_matchCount( 0 ),
|
||||
m_extraClearance( 0 ),
|
||||
m_differentNetsOnly( aDifferentNetsOnly )
|
||||
{
|
||||
if( aItem && aItem->Kind() == ITEM::LINE_T )
|
||||
|
@ -892,7 +890,9 @@ void NODE::followLine( LINKED_ITEM* aCurrent, bool aScanDirection, int& aPos, in
|
|||
|
||||
if( count && guard == p )
|
||||
{
|
||||
aSegments[aPos] = NULL;
|
||||
if( aPos >= 0 && aPos < aLimit )
|
||||
aSegments[aPos] = NULL;
|
||||
|
||||
aGuardHit = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -785,10 +785,10 @@ OPTIMIZER::BREAKOUT_LIST OPTIMIZER::rectBreakouts( int aWidth, const SHAPE* aSha
|
|||
VECTOR2I d_vert = VECTOR2I( 0, s.y / 2 + aWidth );
|
||||
VECTOR2I d_horiz = VECTOR2I( s.x / 2 + aWidth, 0 );
|
||||
|
||||
breakouts.push_back( SHAPE_LINE_CHAIN( { c, c + d_horiz } ) );
|
||||
breakouts.push_back( SHAPE_LINE_CHAIN( { c, c - d_horiz } ) );
|
||||
breakouts.push_back( SHAPE_LINE_CHAIN( { c, c + d_vert } ) );
|
||||
breakouts.push_back( SHAPE_LINE_CHAIN( { c, c - d_vert } ) );
|
||||
breakouts.emplace_back( SHAPE_LINE_CHAIN( { c, c + d_horiz } ) );
|
||||
breakouts.emplace_back( SHAPE_LINE_CHAIN( { c, c - d_horiz } ) );
|
||||
breakouts.emplace_back( SHAPE_LINE_CHAIN( { c, c + d_vert } ) );
|
||||
breakouts.emplace_back( SHAPE_LINE_CHAIN( { c, c - d_vert } ) );
|
||||
|
||||
if( aPermitDiagonal )
|
||||
{
|
||||
|
@ -797,25 +797,25 @@ OPTIMIZER::BREAKOUT_LIST OPTIMIZER::rectBreakouts( int aWidth, const SHAPE* aSha
|
|||
|
||||
if( s.x >= s.y )
|
||||
{
|
||||
breakouts.push_back(
|
||||
breakouts.emplace_back(
|
||||
SHAPE_LINE_CHAIN( { c, c + d_offset, c + d_offset + VECTOR2I( l, l ) } ) );
|
||||
breakouts.push_back(
|
||||
breakouts.emplace_back(
|
||||
SHAPE_LINE_CHAIN( { c, c + d_offset, c + d_offset - VECTOR2I( -l, l ) } ) );
|
||||
breakouts.push_back(
|
||||
breakouts.emplace_back(
|
||||
SHAPE_LINE_CHAIN( { c, c - d_offset, c - d_offset + VECTOR2I( -l, l ) } ) );
|
||||
breakouts.push_back(
|
||||
breakouts.emplace_back(
|
||||
SHAPE_LINE_CHAIN( { c, c - d_offset, c - d_offset - VECTOR2I( l, l ) } ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
// fixme: this could be done more efficiently
|
||||
breakouts.push_back(
|
||||
breakouts.emplace_back(
|
||||
SHAPE_LINE_CHAIN( { c, c + d_offset, c + d_offset + VECTOR2I( l, l ) } ) );
|
||||
breakouts.push_back(
|
||||
breakouts.emplace_back(
|
||||
SHAPE_LINE_CHAIN( { c, c - d_offset, c - d_offset - VECTOR2I( -l, l ) } ) );
|
||||
breakouts.push_back(
|
||||
breakouts.emplace_back(
|
||||
SHAPE_LINE_CHAIN( { c, c + d_offset, c + d_offset + VECTOR2I( -l, l ) } ) );
|
||||
breakouts.push_back(
|
||||
breakouts.emplace_back(
|
||||
SHAPE_LINE_CHAIN( { c, c - d_offset, c - d_offset - VECTOR2I( l, l ) } ) );
|
||||
}
|
||||
}
|
||||
|
@ -1453,7 +1453,7 @@ void Tighten( NODE *aNode, const SHAPE_LINE_CHAIN& aOldLine, const LINE& aNewLin
|
|||
|
||||
SHAPE_LINE_CHAIN current ( aNewLine.CLine() );
|
||||
|
||||
for( int step = 0; step < 3; step++)
|
||||
for( int step = 0; step < 3; step++ )
|
||||
{
|
||||
current.Simplify();
|
||||
|
||||
|
@ -1461,16 +1461,16 @@ void Tighten( NODE *aNode, const SHAPE_LINE_CHAIN& aOldLine, const LINE& aNewLin
|
|||
{
|
||||
SHAPE_LINE_CHAIN l_in, l_out;
|
||||
|
||||
l_in = current.Slice(i, i+3);
|
||||
l_in = current.Slice( i, i + 3 );
|
||||
|
||||
for( int dir = 0; dir < 1; dir++)
|
||||
for( int dir = 0; dir <= 1; dir++ )
|
||||
{
|
||||
if( tightenSegment( dir ? true : false, aNode, aNewLine, l_in, l_out ) )
|
||||
{
|
||||
SHAPE_LINE_CHAIN opt = current;
|
||||
opt.Replace(i, i + 3, l_out);
|
||||
auto optArea = std::abs(shovedArea( aOldLine, opt ));
|
||||
auto prevArea = std::abs(shovedArea( aOldLine, current ));
|
||||
auto optArea = std::abs( shovedArea( aOldLine, opt ) );
|
||||
auto prevArea = std::abs( shovedArea( aOldLine, current ) );
|
||||
|
||||
if( optArea < prevArea )
|
||||
current = opt;
|
||||
|
|
Loading…
Reference in New Issue