router: take net clearance when deskewing diff pairs.

Apply correction on DP corner radius to avoid DRC issues.
This commit is contained in:
Tomasz Wlostowski 2015-08-21 16:37:44 +02:00 committed by Maciej Suminski
parent b4135e0a33
commit a33fc223ae
5 changed files with 35 additions and 4 deletions

View File

@ -198,14 +198,34 @@ SHAPE_LINE_CHAIN PNS_MEANDER_SHAPE::circleQuad( VECTOR2D aP, VECTOR2D aDir, bool
const int ArcSegments = Settings().m_cornerArcSegments;
double radius = (double) aDir.EuclideanNorm();
double angleStep = M_PI / 2.0 / (double) ArcSegments;
double correction = 12.0 * radius * ( 1.0 - cos( angleStep / 2.0 ) );
if( !m_dual )
correction = 0.0;
else if( radius < m_meanCornerRadius )
correction = 0.0;
VECTOR2D p = aP;
lc.Append( ( int ) p.x, ( int ) p.y );
VECTOR2D dir_uu = dir_u.Resize( radius - correction );
VECTOR2D dir_vv = dir_v.Resize( radius - correction );
VECTOR2D shift = dir_u.Resize( correction );
for( int i = ArcSegments - 1; i >= 0; i-- )
{
VECTOR2D p;
double alpha = (double) i / (double) ( ArcSegments - 1 ) * M_PI / 2.0;
p = aP + dir_u * cos( alpha ) + dir_v * ( aSide ? -1.0 : 1.0 ) * ( 1.0 - sin( alpha ) );
p = aP + shift + dir_uu * cos( alpha ) + dir_vv * ( aSide ? -1.0 : 1.0 ) * ( 1.0 - sin( alpha ) );
lc.Append( ( int ) p.x, ( int ) p.y );
}
p = aP + dir_u + dir_v * ( aSide ? -1.0 : 1.0 );
lc.Append( ( int ) p.x, ( int ) p.y );
return lc;
}
@ -303,6 +323,8 @@ SHAPE_LINE_CHAIN PNS_MEANDER_SHAPE::genMeanderShape( VECTOR2D aP, VECTOR2D aDir,
cr = spc / 2;
}
m_meanCornerRadius = cr;
SHAPE_LINE_CHAIN lc;
start( &lc, aP + dir_v_b, aDir );

View File

@ -360,6 +360,8 @@ private:
int m_amplitude;
///> offset wrs the base segment (dual only)
int m_baselineOffset;
///> average radius of meander corners (for correction of DP meanders)
int m_meanCornerRadius;
///> first point of the meandered line
VECTOR2I m_p0;
///> base segment (unclipped)

View File

@ -66,6 +66,8 @@ public:
virtual int operator()( const PNS_ITEM* aA, const PNS_ITEM* aB );
virtual void OverrideClearance (bool aEnable, int aNetA = 0, int aNetB = 0, int aClearance = 0);
void UseDpGap( bool aUseDpGap ) { m_useDpGap = aUseDpGap; }
private:
struct CLEARANCE_ENT {
int coupledNet;
@ -80,6 +82,7 @@ private:
bool m_overrideEnabled;
int m_overrideNetA, m_overrideNetB;
int m_overrideClearance;
bool m_useDpGap;
};
/**

View File

@ -72,6 +72,7 @@ PNS_PCBNEW_CLEARANCE_FUNC::PNS_PCBNEW_CLEARANCE_FUNC( PNS_ROUTER* aRouter ) :
PNS_TOPOLOGY topo( world );
m_clearanceCache.resize( brd->GetNetCount() );
m_useDpGap = false;
for( unsigned int i = 0; i < brd->GetNetCount(); i++ )
{
@ -128,7 +129,7 @@ int PNS_PCBNEW_CLEARANCE_FUNC::operator()( const PNS_ITEM* aA, const PNS_ITEM* a
if( net_a == net_b )
return 0;
if( linesOnly && net_a >= 0 && net_b >= 0 && m_clearanceCache[net_a].coupledNet == net_b )
if( m_useDpGap && linesOnly && net_a >= 0 && net_b >= 0 && m_clearanceCache[net_a].coupledNet == net_b )
{
cl_a = cl_b = m_router->Sizes().DiffPairGap() - 2 * PNS_HULL_MARGIN;
}
@ -608,6 +609,8 @@ bool PNS_ROUTER::StartDragging( const VECTOR2I& aP, PNS_ITEM* aStartItem )
bool PNS_ROUTER::StartRouting( const VECTOR2I& aP, PNS_ITEM* aStartItem, int aLayer )
{
m_clearanceFunc->UseDpGap( false );
switch( m_mode )
{
case PNS_MODE_ROUTE_SINGLE:
@ -615,6 +618,7 @@ bool PNS_ROUTER::StartRouting( const VECTOR2I& aP, PNS_ITEM* aStartItem, int aLa
break;
case PNS_MODE_ROUTE_DIFF_PAIR:
m_placer = new PNS_DIFF_PAIR_PLACER( this );
m_clearanceFunc->UseDpGap( true );
break;
case PNS_MODE_TUNE_SINGLE:
m_placer = new PNS_MEANDER_PLACER( this );

View File

@ -272,7 +272,7 @@ private:
// optHoverItem m_startItem, m_endItem;
PNS_ROUTING_SETTINGS m_settings;
PNS_CLEARANCE_FUNC* m_clearanceFunc;
PNS_PCBNEW_CLEARANCE_FUNC* m_clearanceFunc;
boost::unordered_set<BOARD_CONNECTED_ITEM*> m_hiddenItems;