Re-implement some commented-out hole clearance checking in router.
(cherry picked from commit 5e18287ff9
)
This commit is contained in:
parent
dba36c07fe
commit
aa1910a834
|
@ -2,7 +2,7 @@
|
|||
* KiRouter - a push-and-(sometimes-)shove PCB router
|
||||
*
|
||||
* Copyright (C) 2013-2017 CERN
|
||||
* Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2016-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
|
@ -32,7 +32,6 @@
|
|||
#include "pns_topology.h"
|
||||
#include "pns_walkaround.h"
|
||||
#include "pns_mouse_trail_tracer.h"
|
||||
#include "pns_utils.h"
|
||||
|
||||
#include <wx/log.h>
|
||||
|
||||
|
@ -392,29 +391,8 @@ bool LINE_PLACER::mergeHead()
|
|||
}
|
||||
|
||||
|
||||
VECTOR2I closestProjectedPoint( const SHAPE_LINE_CHAIN& line, const VECTOR2I& p )
|
||||
{
|
||||
// Keep distances squared for performance
|
||||
SEG::ecoord min_dist_sq = VECTOR2I::ECOORD_MAX;
|
||||
VECTOR2I closest;
|
||||
|
||||
for( int i = 0; i < line.SegmentCount(); i++ )
|
||||
{
|
||||
const SEG& s = line.CSegment( i );
|
||||
VECTOR2I a = s.NearestPoint( p );
|
||||
int d_sq = (a - p).SquaredEuclideanNorm();
|
||||
|
||||
if( d_sq < min_dist_sq )
|
||||
{
|
||||
min_dist_sq = d_sq;
|
||||
closest = a;
|
||||
}
|
||||
}
|
||||
|
||||
return closest;
|
||||
}
|
||||
|
||||
bool LINE_PLACER::clipAndCheckCollisions( VECTOR2I aP, SHAPE_LINE_CHAIN aL, SHAPE_LINE_CHAIN& aOut, int &thresholdDist )
|
||||
bool LINE_PLACER::clipAndCheckCollisions( const VECTOR2I& aP, const SHAPE_LINE_CHAIN& aL,
|
||||
SHAPE_LINE_CHAIN& aOut, int &thresholdDist )
|
||||
{
|
||||
SHAPE_LINE_CHAIN l( aL );
|
||||
int idx = l.Split( aP );
|
||||
|
@ -448,7 +426,8 @@ bool LINE_PLACER::clipAndCheckCollisions( VECTOR2I aP, SHAPE_LINE_CHAIN aL, SHAP
|
|||
}
|
||||
|
||||
|
||||
bool LINE_PLACER::cursorDistMinimum( const SHAPE_LINE_CHAIN& aL, const VECTOR2I& aCursor, double lengthThreshold, SHAPE_LINE_CHAIN &aOut )
|
||||
bool LINE_PLACER::cursorDistMinimum( const SHAPE_LINE_CHAIN& aL, const VECTOR2I& aCursor,
|
||||
double lengthThreshold, SHAPE_LINE_CHAIN &aOut )
|
||||
{
|
||||
std::vector<int> dists;
|
||||
std::vector<VECTOR2I> pts;
|
||||
|
@ -657,16 +636,15 @@ bool LINE_PLACER::rhWalkBase( const VECTOR2I& aP, LINE& aWalkLine, int aCollisio
|
|||
|
||||
PNS_DBG( Dbg(), AddItem, &wr.lineCcw, RED, 20000, wxT( "wf-result-ccw-postopt" ) );
|
||||
len_ccw = wr.lineCcw.CLine().Length();
|
||||
|
||||
if( len_ccw < len_cw )
|
||||
{
|
||||
bestLine = wr.lineCcw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int bestLength = len_cw < len_ccw ? len_cw : len_ccw;
|
||||
|
||||
if( bestLength < hugThresholdLengthComplete && bestLine.has_value() )
|
||||
{
|
||||
{
|
||||
walkFull.SetShape( bestLine->CLine() );
|
||||
walkP = walkFull.CLine().CPoint(-1);
|
||||
PNS_DBGN( Dbg(), EndGroup );
|
||||
|
@ -681,41 +659,41 @@ bool LINE_PLACER::rhWalkBase( const VECTOR2I& aP, LINE& aWalkLine, int aCollisio
|
|||
SHAPE_LINE_CHAIN l_cw, l_ccw;
|
||||
|
||||
if( wr.statusCw != WALKAROUND::STUCK )
|
||||
{
|
||||
{
|
||||
validCw = cursorDistMinimum( wr.lineCw.CLine(), aP, hugThresholdLength, l_cw );
|
||||
|
||||
if( validCw )
|
||||
{
|
||||
distCw = ( aP - l_cw.CPoint( -1 ) ).EuclideanNorm();
|
||||
}
|
||||
PNS_DBG( Dbg(), AddShape, &l_cw, MAGENTA, 200000,
|
||||
wxString::Format( "wh-result-cw %s",
|
||||
validCw ? "non-colliding" : "colliding" ) );
|
||||
}
|
||||
|
||||
PNS_DBG( Dbg(), AddShape, &l_cw, MAGENTA, 200000, wxString::Format( "wh-result-cw %s",
|
||||
validCw ? "non-colliding"
|
||||
: "colliding" ) );
|
||||
}
|
||||
|
||||
if( wr.statusCcw != WALKAROUND::STUCK )
|
||||
{
|
||||
validCcw = cursorDistMinimum( wr.lineCcw.CLine(), aP, hugThresholdLength, l_ccw );
|
||||
|
||||
if( validCcw )
|
||||
{
|
||||
distCcw = ( aP - l_ccw.CPoint( -1 ) ).EuclideanNorm();
|
||||
}
|
||||
PNS_DBG( Dbg(), AddShape, &l_ccw, MAGENTA, 200000,
|
||||
wxString::Format( "wh-result-ccw %s",
|
||||
validCcw ? "non-colliding" : "colliding" ) );
|
||||
|
||||
PNS_DBG( Dbg(), AddShape, &l_ccw, MAGENTA, 200000, wxString::Format( "wh-result-ccw %s",
|
||||
validCcw ? "non-colliding"
|
||||
: "colliding" ) );
|
||||
}
|
||||
|
||||
|
||||
if( distCw < distCcw && validCw )
|
||||
{
|
||||
walkFull.SetShape( l_cw );
|
||||
{
|
||||
walkFull.SetShape( l_cw );
|
||||
walkP = l_cw.CPoint(-1);
|
||||
}
|
||||
}
|
||||
else if( validCcw )
|
||||
{
|
||||
walkFull.SetShape( l_ccw );
|
||||
{
|
||||
walkFull.SetShape( l_ccw );
|
||||
walkP = l_ccw.CPoint(-1);
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
PNS_DBGN( Dbg(), EndGroup );
|
||||
return false;
|
||||
|
@ -835,9 +813,7 @@ bool LINE_PLACER::rhMarkObstacles( const VECTOR2I& aP, LINE& aNewHead, LINE& aNe
|
|||
auto nearest = hull.NearestPoint( aP );
|
||||
|
||||
if( ( nearest - aP ).EuclideanNorm() < m_head.Width() / 2 )
|
||||
{
|
||||
buildInitialLine( nearest, m_head );
|
||||
}
|
||||
}
|
||||
|
||||
// Note: Something like the below could be used to implement a "stop at first obstacle" mode,
|
||||
|
@ -900,13 +876,9 @@ bool LINE_PLACER::splitHeadTail( const LINE& aNewLine, const LINE& aOldTail, LIN
|
|||
newHead.Clear();
|
||||
|
||||
if( i == 0 )
|
||||
{
|
||||
newTail.Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
else
|
||||
newTail.SetShape( l2.CLine().Slice( 0, i ) );
|
||||
}
|
||||
|
||||
newHead.SetShape( l2.CLine().Slice( i, -1 ) );
|
||||
}
|
||||
|
@ -922,11 +894,11 @@ bool LINE_PLACER::splitHeadTail( const LINE& aNewLine, const LINE& aOldTail, LIN
|
|||
aNewTail = newTail;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool LINE_PLACER::rhShoveOnly( const VECTOR2I& aP, LINE& aNewHead, LINE& aNewTail )
|
||||
{
|
||||
{
|
||||
LINE walkSolids;
|
||||
|
||||
bool viaOk = false;
|
||||
|
@ -948,9 +920,7 @@ bool LINE_PLACER::rhShoveOnly( const VECTOR2I& aP, LINE& aNewHead, LINE& aNewTai
|
|||
LINE newHead( walkSolids );
|
||||
|
||||
if( walkSolids.EndsWithVia() )
|
||||
{
|
||||
PNS_DBG( Dbg(), AddPoint, newHead.Via().Pos(), RED, 1000000, wxString::Format( "SVIA [%d]", viaOk?1:0 ) );
|
||||
}
|
||||
|
||||
if( m_placingVia && viaOk )
|
||||
{
|
||||
|
@ -1004,9 +974,7 @@ bool LINE_PLACER::rhShoveOnly( const VECTOR2I& aP, LINE& aNewHead, LINE& aNewTai
|
|||
return false;
|
||||
|
||||
if( newHead.EndsWithVia() )
|
||||
{
|
||||
aNewHead.AppendVia( newHead.Via() );
|
||||
}
|
||||
|
||||
optimizer.SetEffortLevel( effort );
|
||||
optimizer.SetCollisionMask( ITEM::ANY_T );
|
||||
|
@ -1087,7 +1055,6 @@ bool LINE_PLACER::optimizeTailHeadTransition()
|
|||
// If so, replace the (threshold) last tail points and the head with
|
||||
// the optimized line
|
||||
|
||||
|
||||
PNS_DBG( Dbg(), AddItem, &new_head, LIGHTCYAN, 10000, wxT( "ht-newline" ) );
|
||||
|
||||
if( OPTIMIZER::Optimize( &new_head, OPTIMIZER::MERGE_SEGMENTS, m_currentNode ) )
|
||||
|
@ -1109,13 +1076,9 @@ bool LINE_PLACER::optimizeTailHeadTransition()
|
|||
void LINE_PLACER::updatePStart( const LINE& tail )
|
||||
{
|
||||
if( tail.CLine().PointCount() )
|
||||
{
|
||||
m_p_start = tail.CLine().CPoint(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_p_start = m_currentStart;
|
||||
}
|
||||
m_p_start = tail.CLine().CPoint(-1);
|
||||
else
|
||||
m_p_start = m_currentStart;
|
||||
}
|
||||
|
||||
void LINE_PLACER::routeStep( const VECTOR2I& aP )
|
||||
|
@ -1127,9 +1090,9 @@ void LINE_PLACER::routeStep( const VECTOR2I& aP )
|
|||
|
||||
|
||||
PNS_DBG( Dbg(), Message, wxString::Format( "routeStep: direction: %s head: %d, tail: %d shapes" ,
|
||||
m_direction.Format(),
|
||||
m_head.ShapeCount(),
|
||||
m_tail.ShapeCount() ) );
|
||||
m_direction.Format(),
|
||||
m_head.ShapeCount(),
|
||||
m_tail.ShapeCount() ) );
|
||||
|
||||
PNS_DBG( Dbg(), BeginGroup, wxT( "route-step" ), 0 );
|
||||
|
||||
|
@ -1446,8 +1409,7 @@ void LINE_PLACER::initPlacement()
|
|||
bool LINE_PLACER::Move( const VECTOR2I& aP, ITEM* aEndItem )
|
||||
{
|
||||
LINE current;
|
||||
VECTOR2I p = aP;
|
||||
int eiDepth = -1;
|
||||
int eiDepth = -1;
|
||||
|
||||
if( aEndItem && aEndItem->Owner() )
|
||||
eiDepth = static_cast<const NODE*>( aEndItem->Owner() )->Depth();
|
||||
|
@ -1460,7 +1422,7 @@ bool LINE_PLACER::Move( const VECTOR2I& aP, ITEM* aEndItem )
|
|||
|
||||
m_endItem = aEndItem;
|
||||
|
||||
bool reachesEnd = route( p );
|
||||
bool reachesEnd = route( aP );
|
||||
|
||||
current = Trace();
|
||||
|
||||
|
@ -1886,8 +1848,8 @@ void LINE_PLACER::UpdateSizes( const SIZES_SETTINGS& aSizes )
|
|||
// If the track width continues from an existing track, we don't want to change the width.
|
||||
// Disallow changing width after the first segment has been fixed because we don't want to
|
||||
// go back and rip up tracks or allow DRC errors
|
||||
if( m_sizes.TrackWidthIsExplicit() || ( !HasPlacedAnything()
|
||||
&& ( !m_startItem || m_startItem->Kind() != ITEM::SEGMENT_T ) ) )
|
||||
if( m_sizes.TrackWidthIsExplicit()
|
||||
|| ( !HasPlacedAnything() && ( !m_startItem || m_startItem->Kind() != ITEM::SEGMENT_T ) ) )
|
||||
{
|
||||
m_head.SetWidth( m_sizes.TrackWidth() );
|
||||
m_tail.SetWidth( m_sizes.TrackWidth() );
|
||||
|
@ -1925,9 +1887,8 @@ bool LINE_PLACER::buildInitialLine( const VECTOR2I& aP, LINE& aHead, bool aForce
|
|||
SHAPE_LINE_CHAIN l;
|
||||
DIRECTION_45 guessedDir = m_mouseTrailTracer.GetPosture( aP );
|
||||
|
||||
PNS_DBG( Dbg(), Message,
|
||||
wxString::Format( "buildInitialLine: m_direction %s, guessedDir %s, tail points %d",
|
||||
m_direction.Format(), guessedDir.Format(), m_tail.PointCount() ) );
|
||||
PNS_DBG( Dbg(), Message, wxString::Format( wxT( "buildInitialLine: m_direction %s, guessedDir %s, tail points %d" ),
|
||||
m_direction.Format(), guessedDir.Format(), m_tail.PointCount() ) );
|
||||
|
||||
DIRECTION_45::CORNER_MODE cornerMode = Settings().GetCornerMode();
|
||||
// Rounded corners don't make sense when routing orthogonally (single track at a time)
|
||||
|
@ -1988,26 +1949,23 @@ bool LINE_PLACER::buildInitialLine( const VECTOR2I& aP, LINE& aHead, bool aForce
|
|||
for( int attempt = 0; attempt < 2; attempt++)
|
||||
{
|
||||
VECTOR2I lead = aP - m_p_start;
|
||||
VECTOR2I force;
|
||||
VECTOR2I force;
|
||||
|
||||
if( attempt == 1 && m_last_p_end.has_value() )
|
||||
{
|
||||
lead = aP - m_last_p_end.value();
|
||||
}
|
||||
|
||||
if( v.PushoutForce( m_currentNode, lead, force, collMask, iterLimit ) )
|
||||
{
|
||||
SHAPE_LINE_CHAIN line =
|
||||
guessedDir.BuildInitialTrace( m_p_start, aP + force, false, cornerMode );
|
||||
aHead = LINE( aHead, line );
|
||||
{
|
||||
SHAPE_LINE_CHAIN line = guessedDir.BuildInitialTrace( m_p_start, aP + force, false, cornerMode );
|
||||
aHead = LINE( aHead, line );
|
||||
|
||||
v.SetPos( v.Pos() + force );
|
||||
v.SetPos( v.Pos() + force );
|
||||
|
||||
aHead.AppendVia( v );
|
||||
|
||||
PNS_DBG( Dbg(), AddPoint, v.Pos(), GREEN, 1000000, "via-force-coll-2" );
|
||||
PNS_DBG( Dbg(), AddPoint, v.Pos(), GREEN, 1000000, "via-force-coll-2" );
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -320,7 +320,7 @@ private:
|
|||
bool rhWalkBase( const VECTOR2I& aP, LINE& aWalkLine, int aCollisionMask, bool& aViaOk );
|
||||
bool splitHeadTail( const LINE& aNewLine, const LINE& aOldTail, LINE& aNewHead, LINE& aNewTail );
|
||||
bool cursorDistMinimum( const SHAPE_LINE_CHAIN& aL, const VECTOR2I& aCursor, double lengthThreshold, SHAPE_LINE_CHAIN& aOut );
|
||||
bool clipAndCheckCollisions( VECTOR2I aP, SHAPE_LINE_CHAIN aL, SHAPE_LINE_CHAIN& aOut, int &thresholdDist );
|
||||
bool clipAndCheckCollisions( const VECTOR2I& aP, const SHAPE_LINE_CHAIN& aL, SHAPE_LINE_CHAIN& aOut, int &thresholdDist );
|
||||
|
||||
void updatePStart( const LINE& tail );
|
||||
|
||||
|
|
|
@ -23,8 +23,6 @@
|
|||
#include <cassert>
|
||||
#include <math/box2.h>
|
||||
|
||||
#include <geometry/shape_compound.h>
|
||||
|
||||
#include <wx/log.h>
|
||||
|
||||
#include "pns_arc.h"
|
||||
|
@ -70,8 +68,8 @@ void SHOVE::replaceLine( LINE& aOld, LINE& aNew, bool aIncludeInChangedArea, NOD
|
|||
SHAPE_RECT r( *changed_area );
|
||||
PNS_DBG(Dbg(), AddShape, &r, BLUE, 0, wxT( "shove-changed-area" ) );
|
||||
|
||||
m_affectedArea =
|
||||
m_affectedArea ? m_affectedArea->Merge( *changed_area ) : *changed_area;
|
||||
m_affectedArea = m_affectedArea ? m_affectedArea->Merge( *changed_area )
|
||||
: *changed_area;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,7 +83,7 @@ void SHOVE::replaceLine( LINE& aOld, LINE& aNew, bool aIncludeInChangedArea, NOD
|
|||
|
||||
// Check if the shoved line already has an ancestor (e.g. line from a previous shove
|
||||
// iteration/cursor movement)
|
||||
for( auto link : aOld.Links() )
|
||||
for( LINKED_ITEM* link : aOld.Links() )
|
||||
{
|
||||
auto oldLineIter = m_rootLineHistory.find( link );
|
||||
|
||||
|
@ -100,12 +98,10 @@ void SHOVE::replaceLine( LINE& aOld, LINE& aNew, bool aIncludeInChangedArea, NOD
|
|||
// If found, use it, otherwise, create new entry in the map (we have a genuine new 'root' line)
|
||||
if( !foundPredecessor )
|
||||
{
|
||||
for( auto link : aOld.Links() )
|
||||
for( LINKED_ITEM* link : aOld.Links() )
|
||||
{
|
||||
if( ! rootLine )
|
||||
{
|
||||
rootLine = aOld.Clone();
|
||||
}
|
||||
|
||||
m_rootLineHistory[link] = rootLine;
|
||||
}
|
||||
|
@ -113,19 +109,13 @@ void SHOVE::replaceLine( LINE& aOld, LINE& aNew, bool aIncludeInChangedArea, NOD
|
|||
|
||||
// Now update the NODE (calling Replace invalidates the Links() in a LINE)
|
||||
if( aNode )
|
||||
{
|
||||
aNode->Replace( aOld, aNew );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_currentNode->Replace( aOld, aNew );
|
||||
}
|
||||
|
||||
// point the Links() of the new line to its oldest ancestor
|
||||
for( auto link : aNew.Links() )
|
||||
{
|
||||
for( LINKED_ITEM* link : aNew.Links() )
|
||||
m_rootLineHistory[ link ] = rootLine;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -138,17 +128,6 @@ int SHOVE::getClearance( const ITEM* aA, const ITEM* aB ) const
|
|||
}
|
||||
|
||||
|
||||
int SHOVE::getHoleClearance( const ITEM* aA, const ITEM* aB ) const
|
||||
{
|
||||
/* if( m_forceClearance >= 0 )
|
||||
return m_forceClearance;
|
||||
|
||||
return m_currentNode->GetHoleClearance( aA, aB );*/
|
||||
|
||||
return -1; // fixme hole
|
||||
}
|
||||
|
||||
|
||||
void SHOVE::sanityCheck( LINE* aOld, LINE* aNew )
|
||||
{
|
||||
assert( aOld->CPoint( 0 ) == aNew->CPoint( 0 ) );
|
||||
|
@ -230,14 +209,14 @@ SHOVE::SHOVE_STATUS SHOVE::shoveLineFromLoneVia( const LINE& aCurLine, const LIN
|
|||
{
|
||||
// Build a hull for aCurLine's via and re-walk aObstacleLine around it.
|
||||
|
||||
int obstacleLineWidth = aObstacleLine.Width();
|
||||
int clearance = getClearance( &aCurLine, &aObstacleLine );
|
||||
int obstacleLineWidth = aObstacleLine.Width();
|
||||
const VIA& via = aCurLine.Via();
|
||||
int clearance = getClearance( &via, &aObstacleLine );
|
||||
HOLE* viaHole = via.Hole();
|
||||
int holeClearance = getClearance( viaHole, &aObstacleLine );
|
||||
|
||||
/* int holeClearance = getHoleClearance( &aCurLine.Via(), &aObstacleLine );
|
||||
|
||||
if( holeClearance + aCurLine.Via().Drill() / 2 > clearance + aCurLine.Via().Diameter() / 2 )
|
||||
clearance = holeClearance + aCurLine.Via().Drill() / 2 - aCurLine.Via().Diameter() / 2;
|
||||
*/
|
||||
if( holeClearance + via.Drill() / 2 > clearance + via.Diameter() / 2 )
|
||||
clearance = holeClearance + via.Drill() / 2 - via.Diameter() / 2;
|
||||
|
||||
SHAPE_LINE_CHAIN hull = aCurLine.Via().Hull( clearance, obstacleLineWidth, aCurLine.Layer() );
|
||||
SHAPE_LINE_CHAIN path_cw;
|
||||
|
@ -452,20 +431,15 @@ SHOVE::SHOVE_STATUS SHOVE::ShoveObstacleLine( const LINE& aCurLine, const LINE&
|
|||
for( int i = 0; i < currentLineSegmentCount; i++ )
|
||||
{
|
||||
SEGMENT seg( aCurLine, aCurLine.CSegment( i ) );
|
||||
int extra = 0;
|
||||
|
||||
// Arcs need additional clearance to ensure the hulls are always bigger than the arc
|
||||
if( aCurLine.CLine().IsArcSegment( i ) )
|
||||
extra = SHAPE_ARC::DefaultAccuracyForPCB();
|
||||
|
||||
if( extra > 0 )
|
||||
{
|
||||
PNS_DBG( Dbg(), Message, wxString::Format( wxT( "shove add-extra-clearance %d" ),
|
||||
extra ) );
|
||||
{
|
||||
PNS_DBG( Dbg(), Message, wxString::Format( wxT( "shove add-extra-clearance %d" ), SHAPE_ARC::DefaultAccuracyForPCB() ) );
|
||||
clearance += KiROUND( SHAPE_ARC::DefaultAccuracyForPCB() );
|
||||
}
|
||||
|
||||
SHAPE_LINE_CHAIN hull =
|
||||
seg.Hull( clearance + extra, obstacleLineWidth, aObstacleLine.Layer() );
|
||||
SHAPE_LINE_CHAIN hull = seg.Hull( clearance, obstacleLineWidth, aObstacleLine.Layer() );
|
||||
|
||||
hulls.push_back( hull );
|
||||
}
|
||||
|
@ -473,11 +447,12 @@ SHOVE::SHOVE_STATUS SHOVE::ShoveObstacleLine( const LINE& aCurLine, const LINE&
|
|||
if( viaOnEnd )
|
||||
{
|
||||
const VIA& via = aCurLine.Via();
|
||||
int viaClearance = getClearance( &via, &aObstacleLine );
|
||||
/*int holeClearance = getHoleClearance( &via, &aObstacleLine );
|
||||
int viaClearance = getClearance( &via, &aObstacleLine );
|
||||
HOLE* viaHole = via.Hole();
|
||||
int holeClearance = getClearance( viaHole, &aObstacleLine );
|
||||
|
||||
if( holeClearance + via.Drill() / 2 > viaClearance + via.Diameter() / 2 )
|
||||
viaClearance = holeClearance + via.Drill() / 2 - via.Diameter() / 2;*/
|
||||
viaClearance = holeClearance + via.Drill() / 2 - via.Diameter() / 2;
|
||||
|
||||
hulls.push_back( aCurLine.Via().Hull( viaClearance, obstacleLineWidth ) );
|
||||
}
|
||||
|
@ -689,13 +664,10 @@ SHOVE::SHOVE_STATUS SHOVE::onCollidingSolid( LINE& aCurrent, ITEM* aObstacle, OB
|
|||
std::set<ITEM*> cluster = topo.AssembleCluster( aObstacle, aCurrent.Layers().Start() );
|
||||
|
||||
|
||||
|
||||
PNS_DBG( Dbg(), BeginGroup, "walk-cluster", 1 );
|
||||
|
||||
for( auto item : cluster )
|
||||
{
|
||||
for( ITEM* item : cluster )
|
||||
PNS_DBG( Dbg(), AddItem, item, RED, 10000, wxT( "cl-item" ) );
|
||||
}
|
||||
|
||||
PNS_DBGN( Dbg(), EndGroup );
|
||||
|
||||
|
@ -713,15 +685,9 @@ SHOVE::SHOVE_STATUS SHOVE::onCollidingSolid( LINE& aCurrent, ITEM* aObstacle, OB
|
|||
for( int attempt = 0; attempt < 2; attempt++ )
|
||||
{
|
||||
if( attempt == 1 || Settings().JumpOverObstacles() )
|
||||
{
|
||||
|
||||
nextRank = currentRank - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
nextRank = currentRank + 10000;
|
||||
}
|
||||
|
||||
|
||||
WALKAROUND::WALKAROUND_STATUS status = walkaround.Route( aCurrent, walkaroundLine, false );
|
||||
|
||||
|
@ -881,8 +847,7 @@ SHOVE::SHOVE_STATUS SHOVE::pushOrShoveVia( VIA* aVia, const VECTOR2I& aForce, in
|
|||
|
||||
if( !jt )
|
||||
{
|
||||
PNS_DBG( Dbg(), Message,
|
||||
wxString::Format( wxT( "weird, can't find the center-of-via joint\n" ) ) );
|
||||
PNS_DBG( Dbg(), Message, wxT( "weird, can't find the center-of-via joint\n" ) );
|
||||
return SH_INCOMPLETE;
|
||||
}
|
||||
|
||||
|
@ -970,7 +935,6 @@ SHOVE::SHOVE_STATUS SHOVE::pushOrShoveVia( VIA* aVia, const VECTOR2I& aForce, in
|
|||
replaceLine( lp.first, lp.second );
|
||||
lp.second.SetRank( aCurrentRank - 1 );
|
||||
|
||||
|
||||
PNS_DBG( Dbg(), Message, wxString::Format("PushViaF %p %d\n", &lp.second, lp.second.SegmentCount() ) );
|
||||
|
||||
if( !pushLineStack( lp.second, true ) )
|
||||
|
@ -1166,7 +1130,9 @@ void SHOVE::unwindLineStack( const LINKED_ITEM* aSeg )
|
|||
i = m_lineStack.erase( i );
|
||||
}
|
||||
else
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
d++;
|
||||
}
|
||||
|
@ -1340,7 +1306,7 @@ SHOVE::SHOVE_STATUS SHOVE::shoveIteration( int aIter )
|
|||
Dbg()->SetIteration( aIter );
|
||||
}
|
||||
|
||||
PNS_DBG( Dbg(), AddItem, ¤tLine, RED, currentLine.Width(), wxString::Format( "current-coll-chk rank %d", currentLine.Rank() ) );
|
||||
PNS_DBG( Dbg(), AddItem, ¤tLine, RED, currentLine.Width(), wxString::Format( wxT( "current-coll-chk rank %d" ), currentLine.Rank() ) );
|
||||
|
||||
for( ITEM::PnsKind search_order : { ITEM::HOLE_T, ITEM::SOLID_T, ITEM::VIA_T, ITEM::SEGMENT_T } )
|
||||
{
|
||||
|
@ -1351,11 +1317,12 @@ SHOVE::SHOVE_STATUS SHOVE::shoveIteration( int aIter )
|
|||
|
||||
if( nearest )
|
||||
{
|
||||
PNS_DBG( Dbg(), Message,
|
||||
wxString::Format( wxT( "nearest %p %s rank %d" ), nearest->m_item,
|
||||
nearest->m_item->KindStr(), nearest->m_item->Rank() ) );
|
||||
PNS_DBG( Dbg(), Message, wxString::Format( wxT( "nearest %p %s rank %d" ),
|
||||
nearest->m_item,
|
||||
nearest->m_item->KindStr(),
|
||||
nearest->m_item->Rank() ) );
|
||||
|
||||
PNS_DBG( Dbg(), AddShape, nearest->m_item->Shape(), YELLOW, 10000, wxT("nearest") );
|
||||
PNS_DBG( Dbg(), AddShape, nearest->m_item->Shape(), YELLOW, 10000, wxT( "nearest" ) );
|
||||
}
|
||||
|
||||
if( nearest )
|
||||
|
@ -1365,13 +1332,13 @@ SHOVE::SHOVE_STATUS SHOVE::shoveIteration( int aIter )
|
|||
if( !nearest )
|
||||
{
|
||||
m_lineStack.pop_back();
|
||||
PNS_DBG( Dbg(), Message, "no-nearest-item ");
|
||||
PNS_DBG( Dbg(), Message, wxT( "no-nearest-item ") );
|
||||
return SH_OK;
|
||||
}
|
||||
|
||||
bool viaFixup = fixupViaCollisions( ¤tLine, *nearest );
|
||||
|
||||
PNS_DBG( Dbg(), Message, wxString::Format( "iter %d: VF %d", aIter, viaFixup?1:0 ) );
|
||||
PNS_DBG( Dbg(), Message, wxString::Format( wxT( "iter %d: VF %d" ), aIter, viaFixup?1:0 ) );
|
||||
|
||||
|
||||
ITEM* ni = nearest->m_item;
|
||||
|
@ -1392,7 +1359,7 @@ SHOVE::SHOVE_STATUS SHOVE::shoveIteration( int aIter )
|
|||
{
|
||||
case ITEM::VIA_T:
|
||||
{
|
||||
PNS_DBG( Dbg(), BeginGroup, wxString::Format( "iter %d: reverse-collide-via", aIter ).ToStdString(), 0 );
|
||||
PNS_DBG( Dbg(), BeginGroup, wxString::Format( wxT( "iter %d: reverse-collide-via" ), aIter ), 0 );
|
||||
|
||||
if( currentLine.EndsWithVia() && nearest->m_item->Collide( ¤tLine.Via(), m_currentNode ) )
|
||||
{
|
||||
|
@ -1410,8 +1377,8 @@ SHOVE::SHOVE_STATUS SHOVE::shoveIteration( int aIter )
|
|||
|
||||
case ITEM::SEGMENT_T:
|
||||
{
|
||||
PNS_DBG( Dbg(), BeginGroup, wxString::Format( "iter %d: reverse-collide-segment ",
|
||||
aIter ).ToStdString(), 0 );
|
||||
PNS_DBG( Dbg(), BeginGroup, wxString::Format( wxT( "iter %d: reverse-collide-segment " ),
|
||||
aIter ), 0 );
|
||||
LINE revLine = assembleLine( static_cast<SEGMENT*>( ni ) );
|
||||
|
||||
popLineStack();
|
||||
|
@ -1432,7 +1399,7 @@ SHOVE::SHOVE_STATUS SHOVE::shoveIteration( int aIter )
|
|||
case ITEM::ARC_T:
|
||||
{
|
||||
//TODO(snh): Handle Arc shove separate from track
|
||||
PNS_DBG( Dbg(), BeginGroup, wxString::Format( "iter %d: reverse-collide-arc ", aIter ).ToStdString(), 0 );
|
||||
PNS_DBG( Dbg(), BeginGroup, wxString::Format( wxT( "iter %d: reverse-collide-arc " ), aIter ), 0 );
|
||||
LINE revLine = assembleLine( static_cast<ARC*>( ni ) );
|
||||
|
||||
popLineStack();
|
||||
|
@ -1457,7 +1424,7 @@ SHOVE::SHOVE_STATUS SHOVE::shoveIteration( int aIter )
|
|||
switch( ni->Kind() )
|
||||
{
|
||||
case ITEM::SEGMENT_T:
|
||||
PNS_DBG( Dbg(), BeginGroup, wxString::Format( "iter %d: collide-segment ", aIter ), 0 );
|
||||
PNS_DBG( Dbg(), BeginGroup, wxString::Format( wxT( "iter %d: collide-segment " ), aIter ), 0 );
|
||||
|
||||
st = onCollidingSegment( currentLine, (SEGMENT*) ni );
|
||||
|
||||
|
@ -1470,7 +1437,7 @@ SHOVE::SHOVE_STATUS SHOVE::shoveIteration( int aIter )
|
|||
|
||||
//TODO(snh): Customize Arc collide
|
||||
case ITEM::ARC_T:
|
||||
PNS_DBG( Dbg(), BeginGroup, wxString::Format( "iter %d: collide-arc ", aIter ), 0 );
|
||||
PNS_DBG( Dbg(), BeginGroup, wxString::Format( wxT( "iter %d: collide-arc " ), aIter ), 0 );
|
||||
|
||||
st = onCollidingArc( currentLine, static_cast<ARC*>( ni ) );
|
||||
|
||||
|
@ -1482,7 +1449,7 @@ SHOVE::SHOVE_STATUS SHOVE::shoveIteration( int aIter )
|
|||
break;
|
||||
|
||||
case ITEM::VIA_T:
|
||||
PNS_DBG( Dbg(), BeginGroup, wxString::Format( "iter %d: collide-via (fixup: %d)", aIter, 0 ), 0 );
|
||||
PNS_DBG( Dbg(), BeginGroup, wxString::Format( wxT( "iter %d: collide-via (fixup: %d)" ), aIter, 0 ), 0 );
|
||||
st = onCollidingVia( ¤tLine, (VIA*) ni, *nearest );
|
||||
|
||||
if( st == SH_TRY_WALK )
|
||||
|
@ -1494,7 +1461,7 @@ SHOVE::SHOVE_STATUS SHOVE::shoveIteration( int aIter )
|
|||
|
||||
case ITEM::HOLE_T:
|
||||
case ITEM::SOLID_T:
|
||||
PNS_DBG( Dbg(), BeginGroup, wxString::Format( "iter %d: walk-solid ", aIter ), 0);
|
||||
PNS_DBG( Dbg(), BeginGroup, wxString::Format( wxT( "iter %d: walk-solid " ), aIter ), 0);
|
||||
st = onCollidingSolid( currentLine, ni, *nearest );
|
||||
|
||||
PNS_DBGN( Dbg(), EndGroup );
|
||||
|
@ -1751,7 +1718,7 @@ SHOVE::SHOVE_STATUS SHOVE::ShoveMultiLines( const ITEM_SET& aHeadSet )
|
|||
m_currentNode->RemoveByMarker( MK_HEAD );
|
||||
|
||||
PNS_DBG( Dbg(), Message, wxString::Format( "Shove status : %s after %d iterations",
|
||||
( st == SH_OK ? "OK" : "FAILURE"), m_iter ) );
|
||||
( st == SH_OK ? "OK" : "FAILURE"), m_iter ) );
|
||||
|
||||
if( st == SH_OK )
|
||||
{
|
||||
|
@ -1866,9 +1833,9 @@ SHOVE::SHOVE_STATUS SHOVE::ShoveDraggingVia( const VIA_HANDLE aOldVia, const VEC
|
|||
|
||||
LINE* SHOVE::findRootLine( LINE *aLine )
|
||||
{
|
||||
for( auto link : aLine->Links() )
|
||||
for( LINKED_ITEM* link : aLine->Links() )
|
||||
{
|
||||
if( auto seg = dyn_cast<SEGMENT*>( link ) )
|
||||
if( SEGMENT* seg = dyn_cast<SEGMENT*>( link ) )
|
||||
{
|
||||
auto it = m_rootLineHistory.find( seg );
|
||||
|
||||
|
@ -1911,7 +1878,6 @@ void SHOVE::runOptimizer( NODE* aNode )
|
|||
|
||||
case OE_MEDIUM:
|
||||
optFlags |= OPTIMIZER::MERGE_SEGMENTS;
|
||||
|
||||
n_passes = 2;
|
||||
break;
|
||||
|
||||
|
@ -1959,10 +1925,10 @@ void SHOVE::runOptimizer( NODE* aNode )
|
|||
if( optimizer.Optimize( &line, &optimized, root ) )
|
||||
{
|
||||
PNS_DBG( Dbg(), AddShape, &line.CLine(), BLUE, 0, wxT( "shove-pre-opt" ) );
|
||||
|
||||
if( root )
|
||||
{
|
||||
PNS_DBG( Dbg(), AddItem, root, RED, 0, wxT( "shove-root-opt" ) );
|
||||
}
|
||||
|
||||
replaceLine( line, optimized, false, aNode );
|
||||
line = optimized; // keep links in the lines in the queue up to date
|
||||
|
||||
|
|
|
@ -161,7 +161,6 @@ private:
|
|||
SHOVE_STATUS shoveMainLoop();
|
||||
|
||||
int getClearance( const ITEM* aA, const ITEM* aB ) const;
|
||||
int getHoleClearance( const ITEM* aA, const ITEM* aB ) const;
|
||||
bool fixupViaCollisions( const LINE* aCurrent, OBSTACLE& obs );
|
||||
void sanityCheck( LINE* aOld, LINE* aNew );
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* KiRouter - a push-and-(sometimes-)shove PCB router
|
||||
*
|
||||
* Copyright (C) 2013-2014 CERN
|
||||
* Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2016-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
|
@ -25,7 +25,6 @@
|
|||
|
||||
#include "pns_walkaround.h"
|
||||
#include "pns_optimizer.h"
|
||||
#include "pns_utils.h"
|
||||
#include "pns_router.h"
|
||||
#include "pns_debug_decorator.h"
|
||||
#include "pns_solid.h"
|
||||
|
@ -74,12 +73,10 @@ void WALKAROUND::RestrictToSet( bool aEnabled, const std::set<ITEM*>& aSet )
|
|||
else
|
||||
m_restrictedSet.clear();
|
||||
|
||||
for( auto item : aSet )
|
||||
for( ITEM* item : aSet )
|
||||
{
|
||||
if( auto solid = dyn_cast<SOLID*>( item ) )
|
||||
{
|
||||
if( SOLID* solid = dyn_cast<SOLID*>( item ) )
|
||||
m_restrictedVertices.push_back( solid->Anchor( 0 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,8 +245,7 @@ WALKAROUND::WALKAROUND_STATUS WALKAROUND::Route( const LINE& aInitialPath, LINE&
|
|||
// special case for via-in-the-middle-of-track placement
|
||||
if( aInitialPath.PointCount() <= 1 )
|
||||
{
|
||||
if( aInitialPath.EndsWithVia() && m_world->CheckColliding( &aInitialPath.Via(),
|
||||
m_itemMask ) )
|
||||
if( aInitialPath.EndsWithVia() && m_world->CheckColliding( &aInitialPath.Via(), m_itemMask ) )
|
||||
return STUCK;
|
||||
|
||||
aWalkPath = aInitialPath;
|
||||
|
|
Loading…
Reference in New Issue