PNS: Consider pad orientation when routing

PNS: Skip smart pads when posture was manually forced

This allows a more-correct pad breakout to be chosen when
smart pads is off.
This commit is contained in:
Jon Evans 2020-12-29 01:06:46 -05:00
parent 96d49d1473
commit 81d4e06f00
5 changed files with 20 additions and 4 deletions

View File

@ -831,6 +831,7 @@ std::unique_ptr<PNS::SOLID> PNS_KICAD_IFACE_BASE::syncPad( PAD* aPad )
solid->SetNet( aPad->GetNetCode() );
solid->SetParent( aPad );
solid->SetPadToDie( aPad->GetPadToDieLength() );
solid->SetOrientation( aPad->GetOrientation() );
wxPoint wx_c = aPad->ShapePos();
wxPoint offset = aPad->GetOffset();

View File

@ -28,6 +28,7 @@
#include "pns_node.h"
#include "pns_router.h"
#include "pns_shove.h"
#include "pns_solid.h"
#include "pns_topology.h"
#include "pns_walkaround.h"
@ -702,7 +703,7 @@ bool LINE_PLACER::rhShoveOnly( const VECTOR2I& aP, LINE& aNewHead )
int effortLevel = OPTIMIZER::MERGE_OBTUSE;
if( Settings().SmartPads() )
if( Settings().SmartPads() && !m_postureSolver.IsManuallyForced() )
effortLevel = OPTIMIZER::SMART_PADS;
optimizer.SetEffortLevel( effortLevel );
@ -995,6 +996,13 @@ bool LINE_PLACER::Start( const VECTOR2I& aP, ITEM* aStartItem )
seg.B.y = -seg.B.y;
lastSegDir = DIRECTION_45( seg );
}
else if( aStartItem && aStartItem->Kind() == ITEM::SOLID_T &&
static_cast<SOLID*>( aStartItem )->Parent()->Type() == PCB_PAD_T )
{
double angle = static_cast<SOLID*>( aStartItem )->GetOrientation() / 10.0;
angle = ( angle + 22.5 ) / 45.0;
lastSegDir = DIRECTION_45( static_cast<DIRECTION_45::Directions>( int( angle ) ) );
}
m_postureSolver.Clear();
m_postureSolver.AddTrailPoint( aP );
@ -1608,9 +1616,9 @@ DIRECTION_45 POSTURE_SOLVER::GetPosture( const VECTOR2I& aP )
// Adjusts how close to p0 we unlock the posture again if one was locked already
const int unlockDistanceFactor = 4;
if( m_disabled || m_trail.PointCount() < 2 )
if( m_disabled || m_trail.PointCount() < 2 || m_manuallyForced )
{
if( m_lastSegDirection != DIRECTION_45::UNDEFINED )
if( !m_manuallyForced && m_lastSegDirection != DIRECTION_45::UNDEFINED )
m_direction = m_lastSegDirection;
return m_direction;

View File

@ -95,6 +95,8 @@ public:
void SetDisabled( bool aDisabled = true ) { m_disabled = aDisabled; }
bool IsManuallyForced() const { return m_manuallyForced; }
private:
SHAPE_LINE_CHAIN m_trail;
int m_tolerance;

View File

@ -931,7 +931,7 @@ int OPTIMIZER::smartPadsSingle( LINE* aLine, ITEM* aPad, bool aEnd, int aEndVert
DIRECTION_45 dir_bkout( breakout.CSegment( -1 ) );
if(!connect.SegmentCount())
if( !connect.SegmentCount() )
continue;
int ang1 = dir_bkout.Angle( DIRECTION_45( connect.CSegment( 0 ) ) );

View File

@ -39,6 +39,7 @@ public:
{
m_movable = false;
m_padToDie = 0;
m_orientation = 0;
}
~SOLID()
@ -130,12 +131,16 @@ public:
m_offset = aOffset;
}
double GetOrientation() const { return m_orientation; }
void SetOrientation( double aOrientation ) { m_orientation = aOrientation; }
private:
VECTOR2I m_pos;
SHAPE* m_shape;
SHAPE* m_alternateShape;
VECTOR2I m_offset;
int m_padToDie;
double m_orientation; // in 1/10 degrees, matching PAD
};
}