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; return false;
} }
m_originPair.SetGap( Router()->Sizes().DiffPairGap() ); if( m_originPair.Gap() < 0 )
m_originPair.SetGap( Router()->Sizes().DiffPairGap() );
if( !m_originPair.PLine().SegmentCount() || if( !m_originPair.PLine().SegmentCount() ||
!m_originPair.NLine().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; return false;
} }
m_originPair.SetGap ( Router()->Sizes().DiffPairGap() ); if( m_originPair.Gap() < 0 )
m_originPair.SetGap ( Router()->Sizes().DiffPairGap() );
if( !m_originPair.PLine().SegmentCount() || if( !m_originPair.PLine().SegmentCount() ||
!m_originPair.NLine().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() ) if( s->Layers().Start() == refSeg->Layers().Start() && s->Width() == refSeg->Width() )
{ {
int dist = s->Seg().Distance( refSeg->Seg() ); 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; minDist = dist;
coupledSeg = s; coupledSeg = s;
@ -367,9 +368,20 @@ bool PNS_TOPOLOGY::AssembleDiffPair( PNS_ITEM* aStart, PNS_DIFF_PAIR& aPair )
std::swap( lp, ln ); 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 = PNS_DIFF_PAIR( *lp, *ln );
aPair.SetWidth( lp->Width() ); aPair.SetWidth( lp->Width() );
aPair.SetLayers( lp->Layers() ); aPair.SetLayers( lp->Layers() );
aPair.SetGap( gap );
return true; return true;
} }