pcbnew: Correct optimizer breakout calculation

The previous fix for optimizer breakout length calculation was providing
better scores to longer traces rather than longer breakouts as intended.

This limits the length scoring to breakout only.
This commit is contained in:
Seth Hillbrand 2019-10-24 23:18:16 -07:00
parent 9c8ae217a6
commit 133772e964
1 changed files with 13 additions and 11 deletions

View File

@ -711,7 +711,8 @@ OPTIMIZER::BREAKOUT_LIST OPTIMIZER::rectBreakouts( int aWidth,
const SHAPE* aShape, bool aPermitDiagonal ) const const SHAPE* aShape, bool aPermitDiagonal ) const
{ {
const SHAPE_RECT* rect = static_cast<const SHAPE_RECT*>(aShape); const SHAPE_RECT* rect = static_cast<const SHAPE_RECT*>(aShape);
VECTOR2I s = rect->GetSize(), c = rect->GetPosition() + VECTOR2I( s.x / 2, s.y / 2 ); VECTOR2I s = rect->GetSize();
VECTOR2I c = rect->GetPosition() + VECTOR2I( s.x / 2, s.y / 2 );
BREAKOUT_LIST breakouts; BREAKOUT_LIST breakouts;
VECTOR2I d_offset; VECTOR2I d_offset;
@ -833,7 +834,7 @@ int OPTIMIZER::smartPadsSingle( LINE* aLine, ITEM* aPad, bool aEnd, int aEndVert
const int ForbiddenAngles = DIRECTION_45::ANG_ACUTE | DIRECTION_45::ANG_RIGHT | const int ForbiddenAngles = DIRECTION_45::ANG_ACUTE | DIRECTION_45::ANG_RIGHT |
DIRECTION_45::ANG_HALF_FULL | DIRECTION_45::ANG_UNDEFINED; DIRECTION_45::ANG_HALF_FULL | DIRECTION_45::ANG_UNDEFINED;
typedef std::pair<int, SHAPE_LINE_CHAIN> RtVariant; typedef std::tuple<int, long long int, SHAPE_LINE_CHAIN> RtVariant;
std::vector<RtVariant> variants; std::vector<RtVariant> variants;
SOLID* solid = dyn_cast<SOLID*>( aPad ); SOLID* solid = dyn_cast<SOLID*>( aPad );
@ -888,9 +889,10 @@ int OPTIMIZER::smartPadsSingle( LINE* aLine, ITEM* aPad, bool aEnd, int aEndVert
if( cc == 0 ) if( cc == 0 )
{ {
RtVariant vp; RtVariant vp;
vp.first = p; std::get<0>( vp ) = p;
vp.second = aEnd ? v.Reverse() : v; std::get<1>( vp ) = breakout.Length();
vp.second.Simplify(); std::get<2>( vp ) = aEnd ? v.Reverse() : v;
std::get<2>( vp ).Simplify();
variants.push_back( vp ); variants.push_back( vp );
} }
} }
@ -902,23 +904,23 @@ int OPTIMIZER::smartPadsSingle( LINE* aLine, ITEM* aPad, bool aEnd, int aEndVert
// here is that if the pad is oblong, the track should not exit the shorter side and parallel // here is that if the pad is oblong, the track should not exit the shorter side and parallel
// the pad but should follow the pad's preferential direction before exiting. // the pad but should follow the pad's preferential direction before exiting.
int min_cost = INT_MAX; int min_cost = INT_MAX;
int max_length = 0; long long int max_length = 0;
SHAPE_LINE_CHAIN l_best; SHAPE_LINE_CHAIN l_best;
bool found = false; bool found = false;
int p_best = -1; int p_best = -1;
for( RtVariant& vp : variants ) for( RtVariant& vp : variants )
{ {
LINE tmp( *aLine, vp.second ); LINE tmp( *aLine, std::get<2>( vp ) );
int cost = COST_ESTIMATOR::CornerCost( vp.second ); int cost = COST_ESTIMATOR::CornerCost( std::get<2>( vp ) );
int len = vp.second.Length(); long long int len = std::get<1>( vp );
if( !checkColliding( &tmp ) ) if( !checkColliding( &tmp ) )
{ {
if( cost < min_cost || ( cost == min_cost && len > max_length ) ) if( cost < min_cost || ( cost == min_cost && len > max_length ) )
{ {
l_best = vp.second; l_best = std::get<2>( vp );
p_best = vp.first; p_best = std::get<0>( vp );
found = true; found = true;
if( cost <= min_cost ) if( cost <= min_cost )