router: compute (and display) DP gap dynamically when tuning length

This commit is contained in:
Tomasz Wlostowski 2015-07-02 16:10:49 +02:00 committed by Maciej Suminski
parent 0ade919a98
commit a180f70086
4 changed files with 49 additions and 96 deletions

View File

@ -119,14 +119,7 @@ bool PNS_DP_MEANDER_PLACER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem )
void PNS_DP_MEANDER_PLACER::release()
{
#if 0
BOOST_FOREACH(PNS_MEANDER *m, m_meanders)
{
delete m;
}
m_meanders.clear();
#endif
}
@ -161,82 +154,7 @@ const SEG PNS_DP_MEANDER_PLACER::baselineSegment( const PNS_DIFF_PAIR::COUPLED_S
}
#if 0
PNS_MEANDER_PLACER_BASE::TUNING_STATUS PNS_DP_MEANDER_PLACER::tuneLineLength ( PNS_MEANDERED_LINE& aTuned, int aElongation )
{
int remaining = aElongation;
bool finished = false;
BOOST_FOREACH(PNS_MEANDER_SHAPE *m, aTuned.Meanders())
{
if(m->Type() != MT_CORNER )
{
if(remaining >= 0)
remaining -= m->MaxTunableLength() - m->BaselineLength();
if(remaining < 0)
{
if(!finished)
{
PNS_MEANDER_TYPE newType;
if ( m->Type() == MT_START || m->Type() == MT_SINGLE)
newType = MT_SINGLE;
else
newType = MT_FINISH;
m->SetType ( newType );
m->Recalculate( );
finished = true;
} else {
m->MakeEmpty();
}
}
}
}
remaining = aElongation;
int meanderCount = 0;
BOOST_FOREACH(PNS_MEANDER_SHAPE *m, aTuned.Meanders())
{
if( m->Type() != MT_CORNER && m->Type() != MT_EMPTY )
{
if(remaining >= 0)
{
remaining -= m->MaxTunableLength() - m->BaselineLength();
meanderCount ++;
}
}
}
int balance = 0;
if( meanderCount )
balance = -remaining / meanderCount;
if (balance >= 0)
{
BOOST_FOREACH(PNS_MEANDER_SHAPE *m, aTuned.Meanders())
{
if(m->Type() != MT_CORNER && m->Type() != MT_EMPTY)
{
// int pre = m->MaxTunableLength();
m->Resize ( std::max( m->Amplitude() - balance / 2, m_settings.m_minAmplitude ) );
}
}
}
return TUNED;
}
#endif
bool pairOrientation( const PNS_DIFF_PAIR::COUPLED_SEGMENTS& aPair )
static bool pairOrientation( const PNS_DIFF_PAIR::COUPLED_SEGMENTS& aPair )
{
VECTOR2I midp = ( aPair.coupledP.A + aPair.coupledN.A ) / 2;
@ -250,6 +168,8 @@ bool PNS_DP_MEANDER_PLACER::Move( const VECTOR2I& aP, PNS_ITEM* aEndItem )
{
// return false;
PNS_DIFF_PAIR::COUPLED_SEGMENTS_VEC coupledSegments;
if( m_currentNode )
delete m_currentNode;
@ -265,11 +185,9 @@ bool PNS_DP_MEANDER_PLACER::Move( const VECTOR2I& aP, PNS_ITEM* aEndItem )
tuned.SetShape( tunedP, tunedN );
m_coupledSegments.clear();
tuned.CoupledSegmentPairs( coupledSegments );
tuned.CoupledSegmentPairs( m_coupledSegments );
if( m_coupledSegments.size() == 0 )
if( coupledSegments.size() == 0 )
return false;
//Router()->DisplayDebugLine ( tuned.CP(), 5, 20000 );
@ -283,7 +201,7 @@ bool PNS_DP_MEANDER_PLACER::Move( const VECTOR2I& aP, PNS_ITEM* aEndItem )
int offset = ( tuned.Gap() + tuned.Width() ) / 2;
if( !pairOrientation( m_coupledSegments[0] ) )
if( !pairOrientation( coupledSegments[0] ) )
offset *= -1;
m_result.SetBaselineOffset( offset );
@ -300,17 +218,35 @@ bool PNS_DP_MEANDER_PLACER::Move( const VECTOR2I& aP, PNS_ITEM* aEndItem )
Router()->DisplayDebugLine( l->CLine(), 5, 10000 );
}
BOOST_FOREACH( const PNS_DIFF_PAIR::COUPLED_SEGMENTS& sp, m_coupledSegments )
int curIndexP = 0, curIndexN = 0;
BOOST_FOREACH( const PNS_DIFF_PAIR::COUPLED_SEGMENTS& sp, coupledSegments )
{
SEG base = baselineSegment( sp );
// DrawDebugSeg ( base, 3 );
DrawDebugSeg ( base, 3 );
while(sp.indexP >= curIndexP)
{
m_result.AddCorner( tunedP.CPoint(curIndexP), tunedN.CPoint(curIndexN) );
curIndexP++;
}
while(sp.indexN >= curIndexN)
{
m_result.AddCorner( tunedP.CPoint(sp.indexP), tunedN.CPoint(curIndexN) );
curIndexN++;
}
m_result.AddCorner( sp.parentP.A, sp.parentN.A );
m_result.MeanderSegment( base );
m_result.AddCorner( sp.parentP.B, sp.parentN.B );
}
while(curIndexP < tunedP.PointCount() )
m_result.AddCorner( tunedP.CPoint(curIndexP++), tunedN.CPoint(curIndexN) );
while(curIndexN < tunedN.PointCount() )
m_result.AddCorner( tunedP.CPoint(-1), tunedN.CPoint(curIndexN++) );
int dpLen = origPathLength();
m_lastStatus = TUNED;
@ -454,6 +390,9 @@ const wxString PNS_DP_MEANDER_PLACER::TuningInfo() const
status += LengthDoubleToString( (double) m_lastLength, false );
status += "/";
status += LengthDoubleToString( (double) m_settings.m_targetLength, false );
status += " (gap: ";
status += LengthDoubleToString( (double) m_originPair.Gap(), false );
status += ")";
return status;
}

View File

@ -828,7 +828,7 @@ bool PNS_LINE_PLACER::Move( const VECTOR2I& aP, PNS_ITEM* aEndItem )
m_lastNode = latestNode->Branch();
if( eiDepth >= 0 && aEndItem && latestNode->Depth() > eiDepth &&
current.SegmentCount() && current.CPoint( -1 ) == aP )
current.SegmentCount() )
{
splitAdjacentSegments( m_lastNode, aEndItem, current.CPoint( -1 ) );

View File

@ -216,6 +216,12 @@ public:
PNS_PLACEMENT_ALGO *Placer() { return m_placer; }
void SetGrid( const VECTOR2I& aOrigin, const VECTOR2I& aSize )
{
m_gridOrigin = aOrigin;
m_gridSize = aSize;
}
private:
void movePlacing( const VECTOR2I& aP, PNS_ITEM* aItem );
void moveDragging( const VECTOR2I& aP, PNS_ITEM* aItem );
@ -277,6 +283,9 @@ private:
wxString m_toolStatusbarName;
wxString m_failureReason;
VECTOR2I m_gridOrigin;
VECTOR2I m_gridSize;
};
#endif

View File

@ -24,6 +24,7 @@
#include "pns_joint.h"
#include "pns_solid.h"
#include "pns_router.h"
#include "pns_utils.h"
#include "pns_diff_pair.h"
#include "pns_topology.h"
@ -319,6 +320,7 @@ int PNS_TOPOLOGY::DpNetPolarity( int aNet )
return MatchDpSuffix( refName, dummy1, dummy2 );
}
bool commonParallelProjection( SEG n, SEG p, SEG &pClip, SEG& nClip );
bool PNS_TOPOLOGY::AssembleDiffPair( PNS_ITEM* aStart, PNS_DIFF_PAIR& aPair )
{
@ -345,8 +347,11 @@ bool PNS_TOPOLOGY::AssembleDiffPair( PNS_ITEM* aStart, PNS_DIFF_PAIR& aPair )
{
int dist = s->Seg().Distance( refSeg->Seg() );
bool isParallel = refSeg->Seg().ApproxParallel( s->Seg() );
SEG p_clip, n_clip;
if( dist < minDist || ( dist == minDist && isParallel ) )
bool isCoupled = commonParallelProjection( refSeg->Seg(), s->Seg(), p_clip, n_clip );
if( isParallel && isCoupled && dist < minDist )
{
minDist = dist;
coupledSeg = s;
@ -368,12 +373,12 @@ bool PNS_TOPOLOGY::AssembleDiffPair( PNS_ITEM* aStart, PNS_DIFF_PAIR& aPair )
std::swap( lp, ln );
}
int gap = -1 ;
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);
const VECTOR2I displacement = refSeg->Anchor(1) - coupledSeg->Anchor(1);
gap = (int) abs( refDir.Cross( displacement ) / refDir.EuclideanNorm() ) - lp->Width();
}