router: compute diff pair gap on the fly when tuning the length

This commit is contained in:
Jonathan Jara-Almonte 2015-07-02 16:10:02 +02:00 committed by Maciej Suminski
parent 171d39c8d0
commit 2fd493255d
3 changed files with 17 additions and 3 deletions

View File

@ -98,7 +98,8 @@ bool PNS_DP_MEANDER_PLACER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem )
return false;
}
m_originPair.SetGap( Router()->Sizes().DiffPairGap() );
if( m_originPair.Gap() < 0 )
m_originPair.SetGap( Router()->Sizes().DiffPairGap() );
if( !m_originPair.PLine().SegmentCount() ||
!m_originPair.NLine().SegmentCount() )

View File

@ -78,7 +78,8 @@ bool PNS_MEANDER_SKEW_PLACER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem )
return false;
}
m_originPair.SetGap ( Router()->Sizes().DiffPairGap() );
if( m_originPair.Gap() < 0 )
m_originPair.SetGap ( Router()->Sizes().DiffPairGap() );
if( !m_originPair.PLine().SegmentCount() ||
!m_originPair.NLine().SegmentCount() )

View File

@ -344,8 +344,9 @@ bool PNS_TOPOLOGY::AssembleDiffPair( PNS_ITEM* aStart, PNS_DIFF_PAIR& aPair )
if( s->Layers().Start() == refSeg->Layers().Start() && s->Width() == refSeg->Width() )
{
int dist = s->Seg().Distance( refSeg->Seg() );
bool isParallel = refSeg->Seg().ApproxParallel( s->Seg() );
if( dist < minDist )
if( dist < minDist || ( dist == minDist && isParallel ) )
{
minDist = dist;
coupledSeg = s;
@ -367,9 +368,20 @@ bool PNS_TOPOLOGY::AssembleDiffPair( PNS_ITEM* aStart, PNS_DIFF_PAIR& aPair )
std::swap( lp, ln );
}
int gap = -1 ;
if( refSeg->Seg().ApproxParallel( coupledSeg->Seg() ) ) {
// Segments are parallel -> compute pair gap
const VECTOR2I refDir = refSeg->Anchor(1) - refSeg->Anchor(0);
const VECTOR2I displacement = refSeg->Anchor(1) - coupledSeg->Anchor(1);
gap = (int) abs( refDir.Cross( displacement ) / refDir.EuclideanNorm() ) - lp->Width();
}
aPair = PNS_DIFF_PAIR( *lp, *ln );
aPair.SetWidth( lp->Width() );
aPair.SetLayers( lp->Layers() );
aPair.SetGap( gap );
return true;
}