2015-02-18 00:29:54 +00:00
|
|
|
/*
|
|
|
|
* KiRouter - a push-and-(sometimes-)shove PCB router
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013-2014 CERN
|
2023-08-22 12:06:33 +00:00
|
|
|
* Copyright (C) 2016-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2015-02-18 00:29:54 +00:00
|
|
|
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2022-08-25 22:50:47 +00:00
|
|
|
#include <optional>
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
#include <base_units.h> // God forgive me doing this...
|
|
|
|
|
|
|
|
#include "pns_node.h"
|
|
|
|
#include "pns_itemset.h"
|
|
|
|
#include "pns_topology.h"
|
|
|
|
#include "pns_dp_meander_placer.h"
|
|
|
|
#include "pns_diff_pair.h"
|
|
|
|
#include "pns_router.h"
|
2021-04-05 00:27:22 +00:00
|
|
|
#include "pns_solid.h"
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-29 14:38:11 +00:00
|
|
|
namespace PNS {
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
DP_MEANDER_PLACER::DP_MEANDER_PLACER( ROUTER* aRouter ) :
|
|
|
|
MEANDER_PLACER_BASE( aRouter )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2021-07-19 23:56:05 +00:00
|
|
|
m_world = nullptr;
|
|
|
|
m_currentNode = nullptr;
|
2015-05-15 12:49:11 +00:00
|
|
|
|
2020-01-12 13:00:42 +00:00
|
|
|
m_padToDieP = 0;
|
|
|
|
m_padToDieN = 0;
|
|
|
|
|
2015-05-15 12:49:11 +00:00
|
|
|
// Init temporary variables (do not leave uninitialized members)
|
2021-07-19 23:56:05 +00:00
|
|
|
m_initialSegment = nullptr;
|
2020-01-12 13:00:42 +00:00
|
|
|
m_lastLength = 0;
|
|
|
|
m_lastStatus = TOO_SHORT;
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
DP_MEANDER_PLACER::~DP_MEANDER_PLACER()
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
const LINE DP_MEANDER_PLACER::Trace() const
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
return m_currentTraceP;
|
|
|
|
}
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
NODE* DP_MEANDER_PLACER::CurrentNode( bool aLoopsRemoved ) const
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2015-02-18 16:53:46 +00:00
|
|
|
if( !m_currentNode )
|
2015-02-18 00:29:54 +00:00
|
|
|
return m_world;
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
return m_currentNode;
|
|
|
|
}
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
bool DP_MEANDER_PLACER::Start( const VECTOR2I& aP, ITEM* aStartItem )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2021-01-04 13:54:29 +00:00
|
|
|
if( !aStartItem || !aStartItem->OfKind( ITEM::SEGMENT_T | ITEM::ARC_T ) )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2015-02-18 16:53:46 +00:00
|
|
|
Router()->SetFailureReason( _( "Please select a track whose length you want to tune." ) );
|
2015-02-18 00:29:54 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-01-04 13:54:29 +00:00
|
|
|
m_initialSegment = static_cast<LINKED_ITEM*>( aStartItem );
|
|
|
|
m_currentNode = nullptr;
|
|
|
|
m_currentStart = getSnappedStartPoint( m_initialSegment, aP );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
m_world = Router()->GetWorld()->Branch();
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
TOPOLOGY topo( m_world );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
if( !topo.AssembleDiffPair( m_initialSegment, m_originPair ) )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
Router()->SetFailureReason( _( "Unable to find complementary differential pair "
|
2021-07-19 23:56:05 +00:00
|
|
|
"net for length tuning. Make sure the names of the nets "
|
|
|
|
"belonging to a differential pair end with either _N/_P "
|
|
|
|
"or +/-." ) );
|
2015-02-18 00:29:54 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-07-02 14:10:02 +00:00
|
|
|
if( m_originPair.Gap() < 0 )
|
2015-07-02 14:11:15 +00:00
|
|
|
m_originPair.SetGap( Router()->Sizes().DiffPairGap() );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
if( !m_originPair.PLine().SegmentCount() || !m_originPair.NLine().SegmentCount() )
|
2015-02-18 00:29:54 +00:00
|
|
|
return false;
|
|
|
|
|
2022-08-02 03:23:07 +00:00
|
|
|
m_tunedPathP = topo.AssembleTuningPath( m_originPair.PLine().GetLink( 0 ), &m_startPad_p, &m_endPad_p );
|
2021-04-05 00:27:22 +00:00
|
|
|
|
|
|
|
m_padToDieP = 0;
|
|
|
|
|
2022-08-02 03:23:07 +00:00
|
|
|
if( m_startPad_p )
|
|
|
|
m_padToDieP += m_startPad_p->GetPadToDie();
|
2021-04-05 00:27:22 +00:00
|
|
|
|
2022-08-02 03:23:07 +00:00
|
|
|
if( m_endPad_p )
|
|
|
|
m_padToDieP += m_endPad_p->GetPadToDie();
|
2021-04-05 00:27:22 +00:00
|
|
|
|
2022-08-02 03:23:07 +00:00
|
|
|
m_tunedPathN = topo.AssembleTuningPath( m_originPair.NLine().GetLink( 0 ), &m_startPad_n, &m_endPad_n );
|
2021-04-05 00:27:22 +00:00
|
|
|
|
|
|
|
m_padToDieN = 0;
|
|
|
|
|
2022-08-02 03:23:07 +00:00
|
|
|
if( m_startPad_n )
|
|
|
|
m_padToDieN += m_startPad_n->GetPadToDie();
|
2021-04-05 00:27:22 +00:00
|
|
|
|
2022-08-02 03:23:07 +00:00
|
|
|
if( m_endPad_n )
|
|
|
|
m_padToDieN += m_endPad_n->GetPadToDie();
|
2021-04-05 00:27:22 +00:00
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
m_world->Remove( m_originPair.PLine() );
|
|
|
|
m_world->Remove( m_originPair.NLine() );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
m_currentWidth = m_originPair.Width();
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
void DP_MEANDER_PLACER::release()
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2019-09-03 23:38:58 +00:00
|
|
|
long long int DP_MEANDER_PLACER::origPathLength() const
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2022-11-12 16:25:42 +00:00
|
|
|
long long int totalP = m_padToDieP + lineLength( m_tunedPathP, m_startPad_p, m_endPad_p );
|
|
|
|
long long int totalN = m_padToDieN + lineLength( m_tunedPathN, m_startPad_n, m_endPad_n );
|
2015-02-18 16:53:46 +00:00
|
|
|
return std::max( totalP, totalN );
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
const SEG DP_MEANDER_PLACER::baselineSegment( const DIFF_PAIR::COUPLED_SEGMENTS& aCoupledSegs )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
const VECTOR2I a( ( aCoupledSegs.coupledP.A + aCoupledSegs.coupledN.A ) / 2 );
|
|
|
|
const VECTOR2I b( ( aCoupledSegs.coupledP.B + aCoupledSegs.coupledN.B ) / 2 );
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
return SEG( a, b );
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-10-18 11:48:19 +00:00
|
|
|
bool DP_MEANDER_PLACER::pairOrientation( const DIFF_PAIR::COUPLED_SEGMENTS& aPair )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
VECTOR2I midp = ( aPair.coupledP.A + aPair.coupledN.A ) / 2;
|
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
//DrawDebugPoint(midp, 6);
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
return aPair.coupledP.Side( midp ) > 0;
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
bool DP_MEANDER_PLACER::Move( const VECTOR2I& aP, ITEM* aEndItem )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2023-10-07 03:00:25 +00:00
|
|
|
if( m_currentStart == aP )
|
|
|
|
return false;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
DIFF_PAIR::COUPLED_SEGMENTS_VEC coupledSegments;
|
2015-07-02 14:10:49 +00:00
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
if( m_currentNode )
|
2015-02-18 00:29:54 +00:00
|
|
|
delete m_currentNode;
|
|
|
|
|
|
|
|
m_currentNode = m_world->Branch();
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
SHAPE_LINE_CHAIN preP, tunedP, postP;
|
|
|
|
SHAPE_LINE_CHAIN preN, tunedN, postN;
|
|
|
|
|
2023-10-07 02:11:26 +00:00
|
|
|
m_originPair.CP().Split( m_currentStart, aP, preP, tunedP, postP );
|
|
|
|
m_originPair.CN().Split( m_currentStart, aP, preN, tunedN, postN );
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2023-01-29 03:25:46 +00:00
|
|
|
auto updateStatus =
|
|
|
|
[&]()
|
|
|
|
{
|
|
|
|
int comp = compareWithTolerance( m_lastLength - m_settings.m_targetLength, 0,
|
|
|
|
m_settings.m_lengthTolerance );
|
|
|
|
|
|
|
|
if( comp > 0 )
|
|
|
|
m_lastStatus = TOO_LONG;
|
|
|
|
else if( comp < 0 )
|
|
|
|
m_lastStatus = TOO_SHORT;
|
|
|
|
else
|
|
|
|
m_lastStatus = TUNED;
|
|
|
|
};
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
DIFF_PAIR tuned( m_originPair );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
tuned.SetShape( tunedP, tunedN );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2015-07-02 14:10:49 +00:00
|
|
|
tuned.CoupledSegmentPairs( coupledSegments );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2015-07-02 14:10:49 +00:00
|
|
|
if( coupledSegments.size() == 0 )
|
2023-01-29 03:25:46 +00:00
|
|
|
{
|
|
|
|
// Tuning started at an uncoupled area of the DP; we won't get a valid result until the
|
|
|
|
// cursor is moved far enough along a coupled area. Prevent the track from disappearing and
|
|
|
|
// the length from being zero by just using the original.
|
|
|
|
m_finalShapeP = m_originPair.CP();
|
|
|
|
m_finalShapeN = m_originPair.CN();
|
|
|
|
m_lastLength = origPathLength();
|
|
|
|
updateStatus();
|
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
return false;
|
2023-01-29 03:25:46 +00:00
|
|
|
}
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
m_result = MEANDERED_LINE( this, true );
|
2015-02-18 16:53:46 +00:00
|
|
|
m_result.SetWidth( tuned.Width() );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
int offset = ( tuned.Gap() + tuned.Width() ) / 2;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2018-10-18 11:48:19 +00:00
|
|
|
if( pairOrientation( coupledSegments[0] ) )
|
2015-02-18 16:53:46 +00:00
|
|
|
offset *= -1;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
m_result.SetBaselineOffset( offset );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
for( const ITEM* item : m_tunedPathP.CItems() )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
if( const LINE* l = dyn_cast<const LINE*>( item ) )
|
2023-02-01 17:36:52 +00:00
|
|
|
{
|
2022-02-26 01:42:16 +00:00
|
|
|
PNS_DBG( Dbg(), AddShape, &l->CLine(), YELLOW, 10000, wxT( "tuned-path-p" ) );
|
2023-02-01 17:36:52 +00:00
|
|
|
|
|
|
|
m_router->GetInterface()->DisplayPathLine( l->CLine(), 1 );
|
|
|
|
}
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
for( const ITEM* item : m_tunedPathN.CItems() )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
if( const LINE* l = dyn_cast<const LINE*>( item ) )
|
2023-02-01 17:36:52 +00:00
|
|
|
{
|
2022-02-26 01:42:16 +00:00
|
|
|
PNS_DBG( Dbg(), AddShape, &l->CLine(), YELLOW, 10000, wxT( "tuned-path-n" ) );
|
2023-02-01 17:36:52 +00:00
|
|
|
|
|
|
|
m_router->GetInterface()->DisplayPathLine( l->CLine(), 1 );
|
|
|
|
}
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
2015-07-02 14:10:49 +00:00
|
|
|
int curIndexP = 0, curIndexN = 0;
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
for( const DIFF_PAIR::COUPLED_SEGMENTS& sp : coupledSegments )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2023-10-15 16:58:28 +00:00
|
|
|
SEG base = baselineSegment( sp );
|
|
|
|
bool side = false;
|
|
|
|
|
2023-10-16 12:12:17 +00:00
|
|
|
if( m_settings.m_initialSide == 0 )
|
2023-10-15 16:58:28 +00:00
|
|
|
side = base.Side( aP ) < 0;
|
|
|
|
else
|
2023-10-16 12:12:17 +00:00
|
|
|
side = m_settings.m_initialSide < 0;
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2022-02-26 01:42:16 +00:00
|
|
|
PNS_DBG( Dbg(), AddShape, base, GREEN, 10000, wxT( "dp-baseline" ) );
|
2015-07-02 14:10:49 +00:00
|
|
|
|
2021-08-09 20:00:35 +00:00
|
|
|
while( sp.indexP >= curIndexP && curIndexP != -1 )
|
2015-07-02 14:10:49 +00:00
|
|
|
{
|
2021-08-09 20:00:35 +00:00
|
|
|
if( tunedP.IsArcSegment( curIndexP ) )
|
|
|
|
{
|
|
|
|
ssize_t arcIndex = tunedP.ArcIndex( curIndexP );
|
|
|
|
|
|
|
|
m_result.AddArcAndPt( tunedP.Arc( arcIndex ), tunedN.CPoint( curIndexN ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_result.AddCorner( tunedP.CPoint( curIndexP ), tunedN.CPoint( curIndexN ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
curIndexP = tunedP.NextShape( curIndexP );
|
2015-07-02 14:10:49 +00:00
|
|
|
}
|
|
|
|
|
2021-08-09 20:00:35 +00:00
|
|
|
while( sp.indexN >= curIndexN && curIndexN != -1 )
|
2015-07-02 14:10:49 +00:00
|
|
|
{
|
2021-08-09 20:00:35 +00:00
|
|
|
if( tunedN.IsArcSegment( curIndexN ) )
|
|
|
|
{
|
|
|
|
ssize_t arcIndex = tunedN.ArcIndex( curIndexN );
|
|
|
|
|
|
|
|
m_result.AddPtAndArc( tunedP.CPoint( sp.indexP ), tunedN.Arc( arcIndex ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_result.AddCorner( tunedP.CPoint( sp.indexP ), tunedN.CPoint( curIndexN ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
curIndexN = tunedN.NextShape( curIndexN );
|
2015-07-02 14:10:49 +00:00
|
|
|
}
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2023-10-15 16:58:28 +00:00
|
|
|
m_result.MeanderSegment( base, side );
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
2021-08-09 20:00:35 +00:00
|
|
|
while( curIndexP < tunedP.PointCount() && curIndexP != -1 )
|
|
|
|
{
|
|
|
|
if( tunedP.IsArcSegment( curIndexP ) )
|
|
|
|
{
|
|
|
|
ssize_t arcIndex = tunedP.ArcIndex( curIndexP );
|
|
|
|
|
|
|
|
m_result.AddArcAndPt( tunedP.Arc( arcIndex ), tunedN.CPoint( curIndexN ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_result.AddCorner( tunedP.CPoint( curIndexP ), tunedN.CPoint( curIndexN ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
curIndexP = tunedP.NextShape( curIndexP );
|
|
|
|
}
|
|
|
|
|
|
|
|
while( curIndexN < tunedN.PointCount() && curIndexN != -1 )
|
|
|
|
{
|
|
|
|
if( tunedN.IsArcSegment( curIndexN ) )
|
|
|
|
{
|
|
|
|
ssize_t arcIndex = tunedN.ArcIndex( curIndexN );
|
2015-07-02 14:10:49 +00:00
|
|
|
|
2021-08-09 20:00:35 +00:00
|
|
|
m_result.AddPtAndArc( tunedP.CPoint( -1 ), tunedN.Arc( arcIndex ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_result.AddCorner( tunedP.CPoint( -1 ), tunedN.CPoint( curIndexN ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
curIndexN = tunedN.NextShape( curIndexN );
|
|
|
|
}
|
2015-07-02 14:10:49 +00:00
|
|
|
|
2019-09-03 23:38:58 +00:00
|
|
|
long long int dpLen = origPathLength();
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
m_lastStatus = TUNED;
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
if( dpLen - m_settings.m_targetLength > m_settings.m_lengthTolerance )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
m_lastStatus = TOO_LONG;
|
|
|
|
m_lastLength = dpLen;
|
2015-02-18 16:53:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_lastLength = dpLen - std::max( tunedP.Length(), tunedN.Length() );
|
|
|
|
tuneLineLength( m_result, m_settings.m_targetLength - dpLen );
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
if( m_lastStatus != TOO_LONG )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
tunedP.Clear();
|
|
|
|
tunedN.Clear();
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
for( MEANDER_SHAPE* m : m_result.Meanders() )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
if( m->Type() != MT_EMPTY )
|
|
|
|
{
|
2016-08-15 15:16:53 +00:00
|
|
|
tunedP.Append( m->CLine( 0 ) );
|
|
|
|
tunedN.Append( m->CLine( 1 ) );
|
2015-02-18 16:53:46 +00:00
|
|
|
}
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
m_lastLength += std::max( tunedP.Length(), tunedN.Length() );
|
2023-01-29 03:25:46 +00:00
|
|
|
updateStatus();
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
m_finalShapeP.Clear();
|
2015-02-18 00:29:54 +00:00
|
|
|
m_finalShapeP.Append( preP );
|
|
|
|
m_finalShapeP.Append( tunedP );
|
|
|
|
m_finalShapeP.Append( postP );
|
|
|
|
m_finalShapeP.Simplify();
|
2015-02-18 16:53:46 +00:00
|
|
|
|
|
|
|
m_finalShapeN.Clear();
|
2015-02-18 00:29:54 +00:00
|
|
|
m_finalShapeN.Append( preN );
|
|
|
|
m_finalShapeN.Append( tunedN );
|
|
|
|
m_finalShapeN.Append( postN );
|
|
|
|
m_finalShapeN.Simplify();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-06-19 17:29:36 +00:00
|
|
|
bool DP_MEANDER_PLACER::FixRoute( const VECTOR2I& aP, ITEM* aEndItem, bool aForceFinish )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
LINE lP( m_originPair.PLine(), m_finalShapeP );
|
|
|
|
LINE lN( m_originPair.NLine(), m_finalShapeN );
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2016-08-30 15:28:35 +00:00
|
|
|
m_currentNode->Add( lP );
|
|
|
|
m_currentNode->Add( lN );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2020-03-06 17:55:20 +00:00
|
|
|
CommitPlacement();
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
return true;
|
|
|
|
}
|
2015-02-18 16:53:46 +00:00
|
|
|
|
|
|
|
|
2020-03-06 17:55:20 +00:00
|
|
|
bool DP_MEANDER_PLACER::AbortPlacement()
|
|
|
|
{
|
|
|
|
m_world->KillChildren();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DP_MEANDER_PLACER::HasPlacedAnything() const
|
|
|
|
{
|
2021-07-19 23:56:05 +00:00
|
|
|
return m_originPair.CP().SegmentCount() > 0 || m_originPair.CN().SegmentCount() > 0;
|
2020-03-06 17:55:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DP_MEANDER_PLACER::CommitPlacement()
|
|
|
|
{
|
|
|
|
if( m_currentNode )
|
|
|
|
Router()->CommitRouting( m_currentNode );
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
m_currentNode = nullptr;
|
2020-03-06 17:55:20 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
bool DP_MEANDER_PLACER::CheckFit( MEANDER_SHAPE* aShape )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
LINE l1( m_originPair.PLine(), aShape->CLine( 0 ) );
|
|
|
|
LINE l2( m_originPair.NLine(), aShape->CLine( 1 ) );
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
if( m_currentNode->CheckColliding( &l1 ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( m_currentNode->CheckColliding( &l2 ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
int w = aShape->Width();
|
|
|
|
int clearance = w + m_settings.m_spacing;
|
|
|
|
|
|
|
|
return m_result.CheckSelfIntersections( aShape, clearance );
|
|
|
|
}
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
const ITEM_SET DP_MEANDER_PLACER::Traces()
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
m_currentTraceP = LINE( m_originPair.PLine(), m_finalShapeP );
|
|
|
|
m_currentTraceN = LINE( m_originPair.NLine(), m_finalShapeN );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
ITEM_SET traces;
|
2015-02-18 16:53:46 +00:00
|
|
|
|
|
|
|
traces.Add( &m_currentTraceP );
|
|
|
|
traces.Add( &m_currentTraceN );
|
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
return traces;
|
|
|
|
}
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2022-09-12 19:43:36 +00:00
|
|
|
const VECTOR2I& DP_MEANDER_PLACER::CurrentStart() const
|
|
|
|
{
|
|
|
|
return m_currentStart;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
const VECTOR2I& DP_MEANDER_PLACER::CurrentEnd() const
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
return m_currentEnd;
|
|
|
|
}
|
2015-02-18 16:53:46 +00:00
|
|
|
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
int DP_MEANDER_PLACER::CurrentLayer() const
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
return m_initialSegment->Layers().Start();
|
|
|
|
}
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2019-12-20 14:11:39 +00:00
|
|
|
const wxString DP_MEANDER_PLACER::TuningInfo( EDA_UNITS aUnits ) const
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
wxString status;
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
switch( m_lastStatus )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2015-10-05 16:28:41 +00:00
|
|
|
case TOO_LONG:
|
|
|
|
status = _( "Too long: " );
|
|
|
|
break;
|
|
|
|
case TOO_SHORT:
|
|
|
|
status = _("Too short: " );
|
|
|
|
break;
|
|
|
|
case TUNED:
|
|
|
|
status = _( "Tuned: " );
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return _( "?" );
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
2022-09-16 04:38:10 +00:00
|
|
|
status += EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, aUnits, m_lastLength );
|
2022-02-05 02:06:25 +00:00
|
|
|
status += wxT( "/" );
|
2022-09-16 04:38:10 +00:00
|
|
|
status += EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, aUnits, m_settings.m_targetLength );
|
2022-02-05 02:06:25 +00:00
|
|
|
status += wxT( " (gap: " );
|
2022-09-16 04:38:10 +00:00
|
|
|
status += EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, aUnits, m_originPair.Gap() );
|
2022-02-05 02:06:25 +00:00
|
|
|
status += wxT( ")" );
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
DP_MEANDER_PLACER::TUNING_STATUS DP_MEANDER_PLACER::TuningStatus() const
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
return m_lastStatus;
|
|
|
|
}
|
2015-08-21 14:35:34 +00:00
|
|
|
|
2023-01-29 03:25:46 +00:00
|
|
|
|
2023-08-22 12:06:33 +00:00
|
|
|
const std::vector<NET_HANDLE> DP_MEANDER_PLACER::CurrentNets() const
|
2015-08-21 14:35:34 +00:00
|
|
|
{
|
2023-08-22 12:06:33 +00:00
|
|
|
std::vector<NET_HANDLE> rv;
|
2015-08-21 14:35:34 +00:00
|
|
|
rv.push_back( m_originPair.NetP() );
|
|
|
|
rv.push_back( m_originPair.NetN() );
|
|
|
|
return rv;
|
|
|
|
}
|
2016-08-29 14:38:11 +00:00
|
|
|
|
|
|
|
}
|