KiCad PCB EDA Suite
PNS::DIFF_PAIR_PLACER Class Reference

Single track placement algorithm. More...

#include <pns_diff_pair_placer.h>

Inheritance diagram for PNS::DIFF_PAIR_PLACER:
PNS::PLACEMENT_ALGO PNS::ALGO_BASE

Public Member Functions

 DIFF_PAIR_PLACER (ROUTER *aRouter)
 
 ~DIFF_PAIR_PLACER ()
 
bool Start (const VECTOR2I &aP, ITEM *aStartItem) override
 Start routing a single track at point aP, taking item aStartItem as anchor (unless NULL). More...
 
bool Move (const VECTOR2I &aP, ITEM *aEndItem) override
 Move the end of the currently routed trace to the point aP, taking aEndItem as anchor (if not NULL). More...
 
bool FixRoute (const VECTOR2I &aP, ITEM *aEndItem, bool aForceFinish) override
 Commit the currently routed track to the parent node, taking aP as the final end point and aEndItem as the final anchor (if provided). More...
 
bool CommitPlacement () override
 
bool AbortPlacement () override
 
bool HasPlacedAnything () const override
 
bool ToggleVia (bool aEnabled) override
 Enable/disable a via at the end of currently routed trace. More...
 
bool SetLayer (int aLayer) override
 Set the current routing layer. More...
 
const ITEM_SET Traces () override
 Return the complete routed line, as a single-member ITEM_SET. More...
 
const VECTOR2ICurrentEnd () const override
 Return the current end of the line being placed. More...
 
const std::vector< int > CurrentNets () const override
 Return the net code of currently routed track. More...
 
int CurrentLayer () const override
 Return the layer of currently routed track. More...
 
NODECurrentNode (bool aLoopsRemoved=false) const override
 Return the most recent world state. More...
 
void FlipPosture () override
 Toggle the current posture (straight/diagonal) of the trace head. More...
 
void UpdateSizes (const SIZES_SETTINGS &aSizes) override
 Perform on-the-fly update of the width, via diameter & drill size from a settings class. More...
 
bool IsPlacingVia () const override
 Function IsPlacingVia() More...
 
void SetOrthoMode (bool aOrthoMode) override
 Function SetOrthoMode() More...
 
void GetModifiedNets (std::vector< int > &aNets) const override
 Function GetModifiedNets. More...
 
virtual bool UnfixRoute ()
 
ROUTERRouter () const
 Return current router settings. More...
 
ROUTING_SETTINGSSettings () const
 Return the logger object, allowing to dump geometry to a file. More...
 
virtual LOGGERLogger ()
 
void SetLogger (LOGGER *aLogger)
 
void SetDebugDecorator (DEBUG_DECORATOR *aDecorator)
 Assign a debug decorator allowing this algo to draw extra graphics for visual debugging. More...
 
DEBUG_DECORATORDbg () const
 
const BOX2IVisibleViewArea () const
 

Static Public Member Functions

static bool FindDpPrimitivePair (NODE *aWorld, const VECTOR2I &aP, ITEM *aItem, DP_PRIMITIVE_PAIR &aPair, wxString *aErrorMsg=nullptr)
 

Protected Attributes

DEBUG_DECORATORm_debugDecorator
 
ROUTERm_router
 
LOGGERm_logger
 

Private Types

enum  State { RT_START = 0 , RT_ROUTE = 1 , RT_FINISH = 2 }
 

Private Member Functions

int viaGap () const
 
int gap () const
 
bool route (const VECTOR2I &aP)
 Re-route the current track to point aP. More...
 
void updateLeadingRatLine ()
 Draw the "leading" ratsnest line, which connects the end of currently routed track and the nearest yet unrouted item. More...
 
void setWorld (NODE *aWorld)
 Set the board to route. More...
 
void initPlacement ()
 Initialize placement of a new line with given parameters. More...
 
void setInitialDirection (const DIRECTION_45 &aDirection)
 Set preferred direction of the very first track segment to be laid. More...
 
bool routeHead (const VECTOR2I &aP)
 
bool tryWalkDp (NODE *aNode, DIFF_PAIR &aPair, bool aSolidsOnly)
 route step, walk around mode More...
 
bool rhWalkOnly (const VECTOR2I &aP)
 route step, shove mode More...
 
bool rhShoveOnly (const VECTOR2I &aP)
 route step, mark obstacles mode More...
 
bool rhMarkObstacles (const VECTOR2I &aP)
 
const VIA makeVia (const VECTOR2I &aP, int aNet)
 
bool attemptWalk (NODE *aNode, DIFF_PAIR *aCurrent, DIFF_PAIR &aWalk, bool aPFirst, bool aWindCw, bool aSolidsOnly)
 
bool propagateDpHeadForces (const VECTOR2I &aP, VECTOR2I &aNewP)
 

Private Attributes

State m_state
 
bool m_chainedPlacement
 
bool m_initialDiagonal
 
bool m_startDiagonal
 
bool m_fitOk
 
int m_netP
 
int m_netN
 
DP_PRIMITIVE_PAIR m_start
 
OPT< DP_PRIMITIVE_PAIRm_prevPair
 current algorithm iteration More...
 
int m_iteration
 pointer to world to search colliding items More...
 
NODEm_world
 current routing start point (end of tail, beginning of head) More...
 
VECTOR2I m_p_start
 The shove engine. More...
 
std::unique_ptr< SHOVEm_shove
 Current world state. More...
 
NODEm_currentNode
 Postprocessed world state (including marked collisions & removed loops) More...
 
NODEm_lastNode
 
SIZES_SETTINGS m_sizes
 Are we placing a via? More...
 
bool m_placingVia
 current via diameter More...
 
int m_viaDiameter
 current via drill More...
 
int m_viaDrill
 current track width More...
 
int m_currentWidth
 
int m_currentNet
 
int m_currentLayer
 
bool m_startsOnVia
 
bool m_orthoMode
 
bool m_snapOnTarget
 
VECTOR2I m_currentEnd
 
VECTOR2I m_currentStart
 
DIFF_PAIR m_currentTrace
 
bool m_currentTraceOk
 
ITEMm_currentEndItem
 
bool m_idle
 

Detailed Description

Single track placement algorithm.

Interactively routes a track and applies shove and walk around algorithms when needed.

Definition at line 52 of file pns_diff_pair_placer.h.

Member Enumeration Documentation

◆ State

Enumerator
RT_START 
RT_ROUTE 
RT_FINISH 

Definition at line 209 of file pns_diff_pair_placer.h.

Constructor & Destructor Documentation

◆ DIFF_PAIR_PLACER()

PNS::DIFF_PAIR_PLACER::DIFF_PAIR_PLACER ( ROUTER aRouter)

Definition at line 32 of file pns_diff_pair_placer.cpp.

32 :
33 PLACEMENT_ALGO( aRouter )
34{
36 m_chainedPlacement = false;
37 m_initialDiagonal = false;
38 m_startDiagonal = false;
39 m_fitOk = false;
40 m_netP = 0;
41 m_netN = 0;
42 m_iteration = 0;
43 m_world = nullptr;
44 m_shove = nullptr;
45 m_currentNode = nullptr;
46 m_lastNode = nullptr;
47 m_placingVia = false;
48 m_viaDiameter = 0;
49 m_viaDrill = 0;
51 m_currentNet = 0;
53 m_startsOnVia = false;
54 m_orthoMode = false;
55 m_snapOnTarget = false;
56 m_currentEndItem = nullptr;
57 m_currentTraceOk = false;
58 m_idle = true;
59}
NODE * m_world
current routing start point (end of tail, beginning of head)
int m_viaDiameter
current via drill
int m_iteration
pointer to world to search colliding items
int m_viaDrill
current track width
NODE * m_currentNode
Postprocessed world state (including marked collisions & removed loops)
bool m_placingVia
current via diameter
std::unique_ptr< SHOVE > m_shove
Current world state.
PLACEMENT_ALGO(ROUTER *aRouter)

References m_chainedPlacement, m_currentEndItem, m_currentLayer, m_currentNet, m_currentNode, m_currentTraceOk, m_currentWidth, m_fitOk, m_idle, m_initialDiagonal, m_iteration, m_lastNode, m_netN, m_netP, m_orthoMode, m_placingVia, m_shove, m_snapOnTarget, m_startDiagonal, m_startsOnVia, m_state, m_viaDiameter, m_viaDrill, m_world, and RT_START.

◆ ~DIFF_PAIR_PLACER()

PNS::DIFF_PAIR_PLACER::~DIFF_PAIR_PLACER ( )

Definition at line 61 of file pns_diff_pair_placer.cpp.

62{}

Member Function Documentation

◆ AbortPlacement()

bool PNS::DIFF_PAIR_PLACER::AbortPlacement ( )
overridevirtual

Reimplemented from PNS::PLACEMENT_ALGO.

Definition at line 814 of file pns_diff_pair_placer.cpp.

815{
817 return true;
818}
void KillChildren()
Definition: pns_node.cpp:1451

References PNS::NODE::KillChildren(), and m_world.

◆ attemptWalk()

bool PNS::DIFF_PAIR_PLACER::attemptWalk ( NODE aNode,
DIFF_PAIR aCurrent,
DIFF_PAIR aWalk,
bool  aPFirst,
bool  aWindCw,
bool  aSolidsOnly 
)
private

Definition at line 188 of file pns_diff_pair_placer.cpp.

190{
191 WALKAROUND walkaround( aNode, Router() );
193
194 walkaround.SetSolidsOnly( aSolidsOnly );
195 walkaround.SetIterationLimit( Settings().WalkaroundIterationLimit() );
196
197 SHOVE shove( aNode, Router() );
198 LINE walkP, walkN;
199
200 aWalk = *aCurrent;
201
202 int iter = 0;
203
204 DIFF_PAIR cur( *aCurrent );
205
206 bool currentIsP = aPFirst;
207
208 int mask = aSolidsOnly ? ITEM::SOLID_T : ITEM::ANY_T;
209
210 do
211 {
212 LINE preWalk = ( currentIsP ? cur.PLine() : cur.NLine() );
213 LINE preShove = ( currentIsP ? cur.NLine() : cur.PLine() );
214 LINE postWalk;
215
216 if( !aNode->CheckColliding ( &preWalk, mask ) )
217 {
218 currentIsP = !currentIsP;
219
220 if( !aNode->CheckColliding( &preShove, mask ) )
221 break;
222 else
223 continue;
224 }
225
226 wf1 = walkaround.Route( preWalk, postWalk, false );
227
228 if( wf1 != WALKAROUND::DONE )
229 return false;
230
231 LINE postShove( preShove );
232
233 shove.ForceClearance( true, cur.Gap() - 2 * PNS_HULL_MARGIN );
234
236
237 sh1 = shove.ShoveObstacleLine( postWalk, preShove, postShove );
238
239 if( sh1 != SHOVE::SH_OK )
240 return false;
241
242 postWalk.Line().Simplify();
243 postShove.Line().Simplify();
244
245 cur.SetShape( postWalk.CLine(), postShove.CLine(), !currentIsP );
246
247 currentIsP = !currentIsP;
248
249 if( !aNode->CheckColliding( &postShove, mask ) )
250 break;
251
252 iter++;
253 }
254 while( iter < 3 );
255
256 if( iter == 3 )
257 return false;
258
259 aWalk.SetShape( cur.CP(), cur.CN() );
260
261 return true;
262}
ROUTER * Router() const
Return current router settings.
Definition: pns_algo_base.h:54
ROUTING_SETTINGS & Settings() const
Return the logger object, allowing to dump geometry to a file.
@ SOLID_T
Definition: pns_item.h:63
#define PNS_HULL_MARGIN
Definition: pns_line.h:44

References PNS::ITEM::ANY_T, PNS::NODE::CheckColliding(), PNS::LINE::CLine(), PNS::DIFF_PAIR::CN(), PNS::DIFF_PAIR::CP(), PNS::WALKAROUND::DONE, PNS::SHOVE::ForceClearance(), PNS::DIFF_PAIR::Gap(), PNS::LINE::Line(), PNS::DIFF_PAIR::NLine(), PNS::DIFF_PAIR::PLine(), PNS_HULL_MARGIN, PNS::WALKAROUND::Route(), PNS::ALGO_BASE::Router(), PNS::WALKAROUND::SetIterationLimit(), PNS::DIFF_PAIR::SetShape(), PNS::WALKAROUND::SetSolidsOnly(), PNS::ALGO_BASE::Settings(), PNS::SHOVE::SH_OK, PNS::SHOVE::ShoveObstacleLine(), SHAPE_LINE_CHAIN::Simplify(), and PNS::ITEM::SOLID_T.

Referenced by tryWalkDp().

◆ CommitPlacement()

bool PNS::DIFF_PAIR_PLACER::CommitPlacement ( )
overridevirtual

Reimplemented from PNS::PLACEMENT_ALGO.

Definition at line 827 of file pns_diff_pair_placer.cpp.

828{
829 if( m_lastNode )
831
832 m_lastNode = nullptr;
833 m_currentNode = nullptr;
834 return true;
835}
void CommitRouting()
Definition: pns_router.cpp:728

References PNS::ROUTER::CommitRouting(), m_currentNode, m_lastNode, and PNS::ALGO_BASE::Router().

Referenced by FixRoute().

◆ CurrentEnd()

const VECTOR2I & PNS::DIFF_PAIR_PLACER::CurrentEnd ( ) const
inlineoverridevirtual

Return the current end of the line being placed.

It may not be equal to the cursor position due to collisions.

Implements PNS::PLACEMENT_ALGO.

Definition at line 110 of file pns_diff_pair_placer.h.

111 {
112 return m_currentEnd;
113 }

References m_currentEnd.

◆ CurrentLayer()

int PNS::DIFF_PAIR_PLACER::CurrentLayer ( ) const
inlineoverridevirtual

Return the layer of currently routed track.

Implements PNS::PLACEMENT_ALGO.

Definition at line 123 of file pns_diff_pair_placer.h.

124 {
125 return m_currentLayer;
126 }

References m_currentLayer.

◆ CurrentNets()

const std::vector< int > PNS::DIFF_PAIR_PLACER::CurrentNets ( ) const
overridevirtual

Return the net code of currently routed track.

Implements PNS::PLACEMENT_ALGO.

Definition at line 858 of file pns_diff_pair_placer.cpp.

859{
860 std::vector<int> rv;
861 rv.push_back( m_netP );
862 rv.push_back( m_netN );
863 return rv;
864}

References m_netN, and m_netP.

◆ CurrentNode()

NODE * PNS::DIFF_PAIR_PLACER::CurrentNode ( bool  aLoopsRemoved = false) const
overridevirtual

Return the most recent world state.

Implements PNS::PLACEMENT_ALGO.

Definition at line 399 of file pns_diff_pair_placer.cpp.

400{
401 if( m_lastNode )
402 return m_lastNode;
403
404 return m_currentNode;
405}

References m_currentNode, and m_lastNode.

◆ Dbg()

DEBUG_DECORATOR * PNS::ALGO_BASE::Dbg ( ) const
inlineinherited

◆ FindDpPrimitivePair()

bool PNS::DIFF_PAIR_PLACER::FindDpPrimitivePair ( NODE aWorld,
const VECTOR2I aP,
ITEM aItem,
DP_PRIMITIVE_PAIR aPair,
wxString *  aErrorMsg = nullptr 
)
static

Definition at line 464 of file pns_diff_pair_placer.cpp.

466{
467 int netP, netN;
468
469 bool result = aWorld->GetRuleResolver()->DpNetPair( aItem, netP, netN );
470
471 if( !result )
472 {
473 if( aErrorMsg )
474 {
475 *aErrorMsg = _( "Unable to find complementary differential pair "
476 "nets. Make sure the names of the nets belonging "
477 "to a differential pair end with either N/P or +/-." );
478 }
479 return false;
480 }
481
482 int refNet = aItem->Net();
483 int coupledNet = ( refNet == netP ) ? netN : netP;
484
485 OPT_VECTOR2I refAnchor = getDanglingAnchor( aWorld, aItem );
486 ITEM* primRef = aItem;
487
488 if( !refAnchor )
489 {
490 if( aErrorMsg )
491 {
492 *aErrorMsg = _( "Can't find a suitable starting point. If starting "
493 "from an existing differential pair make sure you are "
494 "at the end." );
495 }
496
497 return false;
498 }
499
500 std::set<ITEM*> coupledItems;
501
502 aWorld->AllItemsInNet( coupledNet, coupledItems );
503 double bestDist = std::numeric_limits<double>::max();
504 bool found = false;
505
506 for( ITEM* item : coupledItems )
507 {
508 if( item->Kind() == aItem->Kind() )
509 {
510 OPT_VECTOR2I anchor = getDanglingAnchor( aWorld, item );
511
512 if( !anchor )
513 continue;
514
515 double dist = ( *anchor - *refAnchor ).EuclideanNorm();
516
517 bool shapeMatches = true;
518
519 if( item->OfKind( ITEM::SOLID_T | ITEM::VIA_T ) && item->Layers() != aItem->Layers() )
520 {
521 shapeMatches = false;
522 }
523
524 if( dist < bestDist && shapeMatches )
525 {
526 found = true;
527 bestDist = dist;
528
529 if( refNet != netP )
530 {
531 aPair = DP_PRIMITIVE_PAIR ( item, primRef );
532 aPair.SetAnchors( *anchor, *refAnchor );
533 }
534 else
535 {
536 aPair = DP_PRIMITIVE_PAIR( primRef, item );
537 aPair.SetAnchors( *refAnchor, *anchor );
538 }
539 }
540 }
541 }
542
543 if( !found )
544 {
545 if( aErrorMsg )
546 {
547 *aErrorMsg = wxString::Format( _( "Can't find a suitable starting point "
548 "for coupled net \"%s\"." ),
549 aWorld->GetRuleResolver()->NetName( coupledNet ) );
550 }
551
552 return false;
553 }
554
555 return true;
556}
#define _(s)
OPT_VECTOR2I getDanglingAnchor(NODE *aNode, ITEM *aItem)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
OPT< VECTOR2I > OPT_VECTOR2I
Definition: seg.h:39
double EuclideanNorm(const VECTOR2I &vector)
Definition: trigo.h:129

References _, PNS::NODE::AllItemsInNet(), anchor, PNS::RULE_RESOLVER::DpNetPair(), EuclideanNorm(), Format(), PNS::getDanglingAnchor(), PNS::NODE::GetRuleResolver(), PNS::ITEM::Kind(), PNS::ITEM::Layers(), PNS::ITEM::Net(), PNS::RULE_RESOLVER::NetName(), PNS::DP_PRIMITIVE_PAIR::SetAnchors(), PNS::ITEM::SOLID_T, and PNS::ITEM::VIA_T.

Referenced by PNS::ROUTER::isStartingPointRoutable(), routeHead(), and Start().

◆ FixRoute()

bool PNS::DIFF_PAIR_PLACER::FixRoute ( const VECTOR2I aP,
ITEM aEndItem,
bool  aForceFinish 
)
overridevirtual

Commit the currently routed track to the parent node, taking aP as the final end point and aEndItem as the final anchor (if provided).

Returns
true if route has been committed. May return false if the routing result is violating design rules. In such cases, the track is only committed if #Settings.CanViolateDRC() is on.

Implements PNS::PLACEMENT_ALGO.

Definition at line 748 of file pns_diff_pair_placer.cpp.

749{
750 if( !m_fitOk && !Settings().AllowDRCViolations() )
751 return false;
752
754 return false;
755
756 if( m_currentTrace.CP().SegmentCount() > 1 )
758
759 TOPOLOGY topo( m_lastNode );
760
761 if( !m_snapOnTarget && !m_currentTrace.EndsWithVias() && !aForceFinish &&
762 !Settings().GetFixAllSegments() )
763 {
766
767 if( newP.SegmentCount() > 1 && newN.SegmentCount() > 1 )
768 {
769 newP.Remove( -1, -1 );
770 newN.Remove( -1, -1 );
771 }
772
773 m_currentTrace.SetShape( newP, newN );
774 }
775
777 {
780 m_chainedPlacement = false;
781 }
782 else
783 {
784 m_chainedPlacement = !m_snapOnTarget && !aForceFinish;
785 }
786
787 LINE lineP( m_currentTrace.PLine() );
788 LINE lineN( m_currentTrace.NLine() );
789
790 m_lastNode->Add( lineP );
791 m_lastNode->Add( lineN );
792
793 topo.SimplifyLine( &lineP );
794 topo.SimplifyLine( &lineN );
795
797
799 m_placingVia = false;
800
801 if( m_snapOnTarget || aForceFinish )
802 {
803 m_idle = true;
804 return true;
805 }
806 else
807 {
809 return false;
810 }
811}
Represent route directions & corner angles in a 45-degree metric.
Definition: direction45.h:37
bool IsDiagonal() const
Returns true if the direction is diagonal (e.g.
Definition: direction45.h:213
OPT< DP_PRIMITIVE_PAIR > m_prevPair
current algorithm iteration
void initPlacement()
Initialize placement of a new line with given parameters.
const SHAPE_LINE_CHAIN & CN() const
DP_PRIMITIVE_PAIR EndingPrimitives()
void SetShape(const SHAPE_LINE_CHAIN &aP, const SHAPE_LINE_CHAIN &aN, bool aSwapLanes=false)
bool EndsWithVias() const
const SHAPE_LINE_CHAIN & CP() const
const VIA & Via() const
Definition: pns_line.h:194
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
Definition: pns_node.cpp:656
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
int SegmentCount() const
Return the number of segments in this line chain.
const SEG CSegment(int aIndex) const
Return a constant copy of the aIndex segment in the line chain.
std::unique_ptr< typename std::remove_const< T >::type > Clone(const T &aItem)
Definition: pns_item.h:271

References PNS::NODE::Add(), PNS::Clone(), PNS::DIFF_PAIR::CN(), CommitPlacement(), PNS::DIFF_PAIR::CP(), SHAPE_LINE_CHAIN::CSegment(), PNS::DIFF_PAIR::EndingPrimitives(), PNS::DIFF_PAIR::EndsWithVias(), initPlacement(), DIRECTION_45::IsDiagonal(), m_chainedPlacement, m_currentTrace, m_fitOk, m_idle, m_initialDiagonal, m_lastNode, m_placingVia, m_prevPair, m_snapOnTarget, PNS::DIFF_PAIR::NLine(), PNS::DIFF_PAIR::PLine(), SHAPE_LINE_CHAIN::Remove(), SHAPE_LINE_CHAIN::SegmentCount(), PNS::DIFF_PAIR::SetShape(), PNS::ALGO_BASE::Settings(), PNS::TOPOLOGY::SimplifyLine(), and PNS::LINE::Via().

◆ FlipPosture()

void PNS::DIFF_PAIR_PLACER::FlipPosture ( )
overridevirtual

Toggle the current posture (straight/diagonal) of the trace head.

Reimplemented from PNS::PLACEMENT_ALGO.

Definition at line 390 of file pns_diff_pair_placer.cpp.

391{
393
394 if( !m_idle )
395 Move( m_currentEnd, nullptr );
396}
bool Move(const VECTOR2I &aP, ITEM *aEndItem) override
Move the end of the currently routed trace to the point aP, taking aEndItem as anchor (if not NULL).

References m_currentEnd, m_idle, m_startDiagonal, and Move().

◆ gap()

int PNS::DIFF_PAIR_PLACER::gap ( ) const
private

Definition at line 566 of file pns_diff_pair_placer.cpp.

567{
569}
SIZES_SETTINGS m_sizes
Are we placing a via?

References PNS::SIZES_SETTINGS::DiffPairGap(), PNS::SIZES_SETTINGS::DiffPairWidth(), and m_sizes.

Referenced by routeHead().

◆ GetModifiedNets()

void PNS::DIFF_PAIR_PLACER::GetModifiedNets ( std::vector< int > &  aNets) const
overridevirtual

Function GetModifiedNets.

Returns the net codes of all currently routed trace(s)

Reimplemented from PNS::PLACEMENT_ALGO.

Definition at line 838 of file pns_diff_pair_placer.cpp.

839{
840 aNets.push_back( m_netP );
841 aNets.push_back( m_netN );
842}

References m_netN, and m_netP.

◆ HasPlacedAnything()

bool PNS::DIFF_PAIR_PLACER::HasPlacedAnything ( ) const
overridevirtual

◆ initPlacement()

void PNS::DIFF_PAIR_PLACER::initPlacement ( )
private

Initialize placement of a new line with given parameters.

Definition at line 604 of file pns_diff_pair_placer.cpp.

605{
606 m_idle = false;
607 m_orthoMode = false;
608 m_currentEndItem = nullptr;
610
611 NODE* world = Router()->GetWorld();
612
613 world->KillChildren();
614 NODE* rootNode = world->Branch();
615
616 setWorld( rootNode );
617
618 m_lastNode = nullptr;
619 m_currentNode = rootNode;
620
621 m_shove = std::make_unique<SHOVE>( m_currentNode, Router() );
622}
void setWorld(NODE *aWorld)
Set the board to route.
NODE * GetWorld() const
Definition: pns_router.h:154

References PNS::NODE::Branch(), PNS::ROUTER::GetWorld(), PNS::NODE::KillChildren(), m_currentEndItem, m_currentNode, m_idle, m_initialDiagonal, m_lastNode, m_orthoMode, m_shove, m_startDiagonal, PNS::ALGO_BASE::Router(), and setWorld().

Referenced by FixRoute(), SetLayer(), and Start().

◆ IsPlacingVia()

bool PNS::DIFF_PAIR_PLACER::IsPlacingVia ( ) const
inlineoverridevirtual

Function IsPlacingVia()

Returns true if the placer is placing a via (or more vias).

Reimplemented from PNS::PLACEMENT_ALGO.

Definition at line 145 of file pns_diff_pair_placer.h.

145{ return m_placingVia; }

References m_placingVia.

◆ Logger()

LOGGER * PNS::ALGO_BASE::Logger ( )
virtualinherited

Reimplemented in PNS::SHOVE.

Definition at line 34 of file pns_algo_base.cpp.

35{
36 return nullptr;
37}

Referenced by PNS::LINE_PLACER::rhShoveOnly(), PNS::LINE_PLACER::rhWalkOnly(), PNS::DRAGGER::Start(), and PNS::DRAGGER::tryWalkaround().

◆ makeVia()

const VIA PNS::DIFF_PAIR_PLACER::makeVia ( const VECTOR2I aP,
int  aNet 
)
private

Definition at line 71 of file pns_diff_pair_placer.cpp.

72{
74
75 VIA v( aP, layers, m_sizes.ViaDiameter(), m_sizes.ViaDrill(), -1, m_sizes.ViaType() );
76 v.SetNet( aNet );
77
78 return v;
79}
Represent a contiguous set of PCB layers.
Definition: pns_layerset.h:32
VIATYPE ViaType() const
@ VIA
Normal via.
Definition: router_tool.cpp:76

References PNS::SIZES_SETTINGS::GetLayerBottom(), PNS::SIZES_SETTINGS::GetLayerTop(), m_sizes, PNS::ITEM::SetNet(), PNS::SIZES_SETTINGS::ViaDiameter(), PNS::SIZES_SETTINGS::ViaDrill(), and PNS::SIZES_SETTINGS::ViaType().

Referenced by propagateDpHeadForces(), and routeHead().

◆ Move()

bool PNS::DIFF_PAIR_PLACER::Move ( const VECTOR2I aP,
ITEM aEndItem 
)
overridevirtual

Move the end of the currently routed trace to the point aP, taking aEndItem as anchor (if not NULL).

Implements PNS::PLACEMENT_ALGO.

Definition at line 708 of file pns_diff_pair_placer.cpp.

709{
710 m_currentEndItem = aEndItem;
711 m_fitOk = false;
712
713 delete m_lastNode;
714 m_lastNode = nullptr;
715
716 bool retval = route( aP );
717
718 NODE* latestNode = m_currentNode;
719 m_lastNode = latestNode->Branch();
720
721 assert( m_lastNode != nullptr );
722 m_currentEnd = aP;
723
725
726 return retval;
727}
bool route(const VECTOR2I &aP)
Re-route the current track to point aP.
void updateLeadingRatLine()
Draw the "leading" ratsnest line, which connects the end of currently routed track and the nearest ye...
NODE * Branch()
Create a lightweight copy (called branch) of self that tracks the changes (added/removed items) wrs t...
Definition: pns_node.cpp:139

References PNS::NODE::Branch(), m_currentEnd, m_currentEndItem, m_currentNode, m_fitOk, m_lastNode, route(), and updateLeadingRatLine().

Referenced by FlipPosture(), SetLayer(), SetOrthoMode(), and ToggleVia().

◆ propagateDpHeadForces()

bool PNS::DIFF_PAIR_PLACER::propagateDpHeadForces ( const VECTOR2I aP,
VECTOR2I aNewP 
)
private

Definition at line 116 of file pns_diff_pair_placer.cpp.

117{
118 VIA virtHead = makeVia( aP, -1 );
119
120 if( m_placingVia )
121 {
122 virtHead.SetDiameter( viaGap() + 2 * virtHead.Diameter() );
123 }
124 else
125 {
126 virtHead.SetLayer( m_currentLayer );
127 virtHead.SetDiameter( m_sizes.DiffPairGap() + 2 * m_sizes.DiffPairWidth() );
128 }
129
130 bool solidsOnly = true;
131
132 if( Settings().Mode() == RM_MarkObstacles )
133 {
134 aNewP = aP;
135 return true;
136 }
137 else if( Settings().Mode() == RM_Walkaround )
138 {
139 solidsOnly = false;
140 }
141
142 // fixme: I'm too lazy to do it well. Circular approximaton will do for the moment.
143
144 // Note: this code is lifted from VIA::PushoutForce and then optimized for this use case and to
145 // check proper clearances to the diff pair line. It can be removed if some specialized
146 // pushout for traces / diff pairs is implemented. Just calling VIA::PushoutForce does not work
147 // as the via may have different resolved clearance to items than the diff pair should.
148 int maxIter = 40;
149 int iter = 0;
150 bool collided = false;
151 VECTOR2I force, totalForce;
152 std::set<ITEM*> handled;
153
154 while( iter < maxIter )
155 {
156 NODE::OPT_OBSTACLE obs = m_currentNode->CheckColliding( &virtHead, solidsOnly ?
158 ITEM::ANY_T );
159 if( !obs || handled.count( obs->m_item ) )
160 break;
161
162 int clearance = m_currentNode->GetClearance( obs->m_item, &m_currentTrace.PLine() );
163
164 if( obs->m_item->Shape()->Collide( virtHead.Shape(), clearance, &force ) )
165 {
166 collided = true;
167 totalForce += force;
168 virtHead.SetPos( virtHead.Pos() + force );
169 }
170
171 handled.insert( obs->m_item );
172
173 iter++;
174 }
175
176 bool succeeded = ( !collided || iter != maxIter );
177
178 if( succeeded )
179 {
180 aNewP = aP + force;
181 return true;
182 }
183
184 return false;
185}
const VIA makeVia(const VECTOR2I &aP, int aNet)
int GetClearance(const ITEM *aA, const ITEM *aB, bool aUseClearanceEpsilon=true) const
Definition: pns_node.cpp:103
OPT_OBSTACLE CheckColliding(const ITEM *aItem, int aKindMask=ITEM::ANY_T)
Check if the item collides with anything else in the world, and if found, returns the obstacle.
Definition: pns_node.cpp:468
OPT< OBSTACLE > OPT_OBSTACLE
Definition: pns_node.h:160
@ RM_MarkObstacles
Ignore collisions, mark obstacles.
@ RM_Walkaround
Only walk around.

References PNS::ITEM::ANY_T, PNS::NODE::CheckColliding(), PNS::VIA::Diameter(), PNS::SIZES_SETTINGS::DiffPairGap(), PNS::SIZES_SETTINGS::DiffPairWidth(), PNS::NODE::GetClearance(), m_currentLayer, m_currentNode, m_currentTrace, m_placingVia, m_sizes, makeVia(), PNS::DIFF_PAIR::PLine(), PNS::VIA::Pos(), PNS::RM_MarkObstacles, PNS::RM_Walkaround, PNS::VIA::SetDiameter(), PNS::ITEM::SetLayer(), PNS::VIA::SetPos(), PNS::ALGO_BASE::Settings(), PNS::VIA::Shape(), PNS::ITEM::SOLID_T, and viaGap().

Referenced by routeHead().

◆ rhMarkObstacles()

bool PNS::DIFF_PAIR_PLACER::rhMarkObstacles ( const VECTOR2I aP)
private

Definition at line 102 of file pns_diff_pair_placer.cpp.

103{
104 if( !routeHead( aP ) )
105 return false;
106
107 bool collP = static_cast<bool>( m_currentNode->CheckColliding( &m_currentTrace.PLine() ) );
108 bool collN = static_cast<bool>( m_currentNode->CheckColliding( &m_currentTrace.NLine() ) );
109
110 m_fitOk = !( collP || collN ) ;
111
112 return m_fitOk;
113}
bool routeHead(const VECTOR2I &aP)

References PNS::NODE::CheckColliding(), m_currentNode, m_currentTrace, m_fitOk, PNS::DIFF_PAIR::NLine(), PNS::DIFF_PAIR::PLine(), and routeHead().

Referenced by route().

◆ rhShoveOnly()

bool PNS::DIFF_PAIR_PLACER::rhShoveOnly ( const VECTOR2I aP)
private

route step, mark obstacles mode

Definition at line 339 of file pns_diff_pair_placer.cpp.

340{
341 m_currentNode = m_shove->CurrentNode();
342
343 bool ok = routeHead( aP );
344
345 m_fitOk = false;
346
347 if( !ok )
348 return false;
349
350 if( !tryWalkDp( m_currentNode, m_currentTrace, true ) )
351 return false;
352
353 LINE pLine( m_currentTrace.PLine() );
354 LINE nLine( m_currentTrace.NLine() );
355 ITEM_SET head;
356
357 head.Add( &pLine );
358 head.Add( &nLine );
359
360 SHOVE::SHOVE_STATUS status = m_shove->ShoveMultiLines( head );
361
362 m_currentNode = m_shove->CurrentNode();
363
364 if( status == SHOVE::SH_OK )
365 {
366 m_currentNode = m_shove->CurrentNode();
367
370 {
371 m_fitOk = true;
372 }
373 }
374
375 return m_fitOk;
376}
bool tryWalkDp(NODE *aNode, DIFF_PAIR &aPair, bool aSolidsOnly)
route step, walk around mode

References PNS::ITEM_SET::Add(), PNS::NODE::CheckColliding(), m_currentNode, m_currentTrace, m_fitOk, m_shove, PNS::DIFF_PAIR::NLine(), PNS::DIFF_PAIR::PLine(), routeHead(), PNS::SHOVE::SH_OK, and tryWalkDp().

Referenced by route().

◆ rhWalkOnly()

bool PNS::DIFF_PAIR_PLACER::rhWalkOnly ( const VECTOR2I aP)
private

route step, shove mode

Definition at line 310 of file pns_diff_pair_placer.cpp.

311{
312 if( !routeHead ( aP ) )
313 return false;
314
316
317 return m_fitOk;
318}

References m_currentNode, m_currentTrace, m_fitOk, routeHead(), and tryWalkDp().

Referenced by route().

◆ route()

bool PNS::DIFF_PAIR_PLACER::route ( const VECTOR2I aP)
private

Re-route the current track to point aP.

Returns true, when routing has completed successfully (i.e. the trace end has reached point aP), and false if the trace was stuck somewhere on the way. May call routeStep() repetitively due to mouse smoothing.

Parameters
aPis the ending point of current route.
Returns
true if the routing is complete.

Definition at line 321 of file pns_diff_pair_placer.cpp.

322{
323 switch( Settings().Mode() )
324 {
325 case RM_MarkObstacles:
326 return rhMarkObstacles( aP );
327 case RM_Walkaround:
328 return rhWalkOnly( aP );
329 case RM_Shove:
330 return rhShoveOnly( aP );
331 default:
332 break;
333 }
334
335 return false;
336}
bool rhMarkObstacles(const VECTOR2I &aP)
bool rhShoveOnly(const VECTOR2I &aP)
route step, mark obstacles mode
bool rhWalkOnly(const VECTOR2I &aP)
route step, shove mode
@ RM_Shove
Only shove.

References rhMarkObstacles(), rhShoveOnly(), rhWalkOnly(), PNS::RM_MarkObstacles, PNS::RM_Shove, PNS::RM_Walkaround, and PNS::ALGO_BASE::Settings().

Referenced by Move().

◆ routeHead()

bool PNS::DIFF_PAIR_PLACER::routeHead ( const VECTOR2I aP)
private

Definition at line 625 of file pns_diff_pair_placer.cpp.

626{
627 m_fitOk = false;
628
629 DP_GATEWAYS gwsEntry( gap() );
630 DP_GATEWAYS gwsTarget( gap() );
631
632 if( !m_prevPair )
634
635 gwsEntry.BuildFromPrimitivePair( *m_prevPair, m_startDiagonal );
636
637 DP_PRIMITIVE_PAIR target;
638
640 {
641 gwsTarget.BuildFromPrimitivePair( target, m_startDiagonal );
642 m_snapOnTarget = true;
643 }
644 else
645 {
646 VECTOR2I fp;
647
648 if( !propagateDpHeadForces( aP, fp ) )
649 return false;
650
651 VECTOR2I midp, dirV;
652 m_prevPair->CursorOrientation( fp, midp, dirV );
653
654 VECTOR2I fpProj = SEG( midp, midp + dirV ).LineProject( fp );
655
656 // compute 'leader point' distance from the cursor (project cursor position
657 // on the extension of the starting segment pair of the DP)
658 int lead_dist = ( fpProj - fp ).EuclideanNorm();
659
660 gwsTarget.SetFitVias( m_placingVia, m_sizes.ViaDiameter(), viaGap() );
661
662 // far from the initial segment extension line -> allow a 45-degree obtuse turn
663 if( lead_dist > ( m_sizes.DiffPairGap() + m_sizes.DiffPairWidth() ) / 2 )
664 {
665 gwsTarget.BuildForCursor( fp );
666 }
667 else
668 {
669 // close to the initial segment extension line -> keep straight part only, project
670 // as close as possible to the cursor.
671 gwsTarget.BuildForCursor( fpProj );
672 gwsTarget.FilterByOrientation( DIRECTION_45::ANG_STRAIGHT | DIRECTION_45::ANG_HALF_FULL,
673 DIRECTION_45( dirV ) );
674 }
675
676 m_snapOnTarget = false;
677 }
678
681
682 bool result = gwsEntry.FitGateways( gwsEntry, gwsTarget, m_startDiagonal, m_currentTrace );
683
684 if( result )
685 {
686 m_currentTraceOk = true;
690
691 if( m_placingVia )
692 {
694 makeVia( m_currentTrace.CN().CPoint( -1 ), m_netN ) );
695 }
696 else
697 {
699 }
700
701 return true;
702 }
703
704 return m_currentTraceOk;
705}
bool propagateDpHeadForces(const VECTOR2I &aP, VECTOR2I &aNewP)
static bool FindDpPrimitivePair(NODE *aWorld, const VECTOR2I &aP, ITEM *aItem, DP_PRIMITIVE_PAIR &aPair, wxString *aErrorMsg=nullptr)
void AppendVias(const VIA &aViaP, const VIA &aViaN)
void SetGap(int aGap)
void SetNets(int aP, int aN)
void SetWidth(int aWidth)
void SetLayer(int aLayer)
Definition: pns_item.h:157
Definition: seg.h:42
VECTOR2I LineProject(const VECTOR2I &aP) const
Compute the perpendicular projection point of aP on a line passing through ends of the segment.
Definition: seg.cpp:302
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.

References DIRECTION_45::ANG_HALF_FULL, DIRECTION_45::ANG_STRAIGHT, PNS::DIFF_PAIR::AppendVias(), PNS::DP_GATEWAYS::BuildForCursor(), PNS::DP_GATEWAYS::BuildFromPrimitivePair(), PNS::DIFF_PAIR::CN(), PNS::DIFF_PAIR::CP(), SHAPE_LINE_CHAIN::CPoint(), PNS::SIZES_SETTINGS::DiffPairGap(), PNS::SIZES_SETTINGS::DiffPairWidth(), EuclideanNorm(), PNS::DP_GATEWAYS::FilterByOrientation(), FindDpPrimitivePair(), PNS::DP_GATEWAYS::FitGateways(), gap(), SEG::LineProject(), m_currentEndItem, m_currentLayer, m_currentNode, m_currentTrace, m_currentTraceOk, m_fitOk, m_netN, m_netP, m_placingVia, m_prevPair, m_sizes, m_snapOnTarget, m_start, m_startDiagonal, makeVia(), propagateDpHeadForces(), PNS::DIFF_PAIR::RemoveVias(), PNS::DP_GATEWAYS::SetFitVias(), PNS::DIFF_PAIR::SetGap(), PNS::ITEM::SetLayer(), PNS::DIFF_PAIR::SetNets(), PNS::DIFF_PAIR::SetWidth(), PNS::SIZES_SETTINGS::ViaDiameter(), and viaGap().

Referenced by rhMarkObstacles(), rhShoveOnly(), and rhWalkOnly().

◆ Router()

◆ SetDebugDecorator()

void PNS::ALGO_BASE::SetDebugDecorator ( DEBUG_DECORATOR aDecorator)
inlineinherited

Assign a debug decorator allowing this algo to draw extra graphics for visual debugging.

Definition at line 73 of file pns_algo_base.h.

74 {
75 m_debugDecorator = aDecorator;
76 }

References PNS::ALGO_BASE::m_debugDecorator.

Referenced by PNS::SHOVE::onCollidingSolid(), PNS::LINE_PLACER::rhShoveOnly(), PNS::LINE_PLACER::rhWalkOnly(), PNS::SHOVE::SHOVE(), and PNS::DRAGGER::tryWalkaround().

◆ setInitialDirection()

void PNS::DIFF_PAIR_PLACER::setInitialDirection ( const DIRECTION_45 aDirection)
private

Set preferred direction of the very first track segment to be laid.

Used by posture switching mechanism.

◆ SetLayer()

bool PNS::DIFF_PAIR_PLACER::SetLayer ( int  aLayer)
overridevirtual

Set the current routing layer.

Reimplemented from PNS::PLACEMENT_ALGO.

Definition at line 408 of file pns_diff_pair_placer.cpp.

409{
410 if( m_idle )
411 {
412 m_currentLayer = aLayer;
413 return true;
414 }
415 else if( m_chainedPlacement || !m_prevPair )
416 {
417 return false;
418 }
419 else if( !m_prevPair->PrimP() || ( m_prevPair->PrimP()->OfKind( ITEM::VIA_T ) &&
420 m_prevPair->PrimP()->Layers().Overlaps( aLayer ) ) )
421 {
422 m_currentLayer = aLayer;
425 Move( m_currentEnd, nullptr );
426 return true;
427 }
428
429 return false;
430}

References initPlacement(), m_chainedPlacement, m_currentEnd, m_currentLayer, m_idle, m_prevPair, m_start, Move(), and PNS::ITEM::VIA_T.

◆ SetLogger()

void PNS::ALGO_BASE::SetLogger ( LOGGER aLogger)
inlineinherited

Definition at line 65 of file pns_algo_base.h.

66 {
67 m_logger = aLogger;
68 }
LOGGER * m_logger
Definition: pns_algo_base.h:88

References PNS::ALGO_BASE::m_logger.

Referenced by PNS::LINE_PLACER::rhShoveOnly(), PNS::LINE_PLACER::rhWalkOnly(), and PNS::DRAGGER::tryWalkaround().

◆ SetOrthoMode()

void PNS::DIFF_PAIR_PLACER::SetOrthoMode ( bool  aOrthoMode)
overridevirtual

Function SetOrthoMode()

Forces the router to place a straight 90/45 degree trace (with the end as near to the cursor as possible) instead of a standard 135 degree two-segment bend.

Reimplemented from PNS::PLACEMENT_ALGO.

Definition at line 82 of file pns_diff_pair_placer.cpp.

83{
84 m_orthoMode = aOrthoMode;
85
86 if( !m_idle )
87 Move( m_currentEnd, nullptr );
88}

References m_currentEnd, m_idle, m_orthoMode, and Move().

◆ Settings()

◆ setWorld()

void PNS::DIFF_PAIR_PLACER::setWorld ( NODE aWorld)
private

Set the board to route.

Definition at line 65 of file pns_diff_pair_placer.cpp.

66{
67 m_world = aWorld;
68}

References m_world.

Referenced by initPlacement(), and Start().

◆ Start()

bool PNS::DIFF_PAIR_PLACER::Start ( const VECTOR2I aP,
ITEM aStartItem 
)
overridevirtual

Start routing a single track at point aP, taking item aStartItem as anchor (unless NULL).

Implements PNS::PLACEMENT_ALGO.

Definition at line 572 of file pns_diff_pair_placer.cpp.

573{
574 VECTOR2I p( aP );
575
576 setWorld( Router()->GetWorld() );
578
579 wxString err_msg;
580
581 if( !FindDpPrimitivePair( m_currentNode, aP, aStartItem, m_start, &err_msg ) )
582 {
583 Router()->SetFailureReason( err_msg );
584 return false;
585 }
586
587 m_netP = m_start.PrimP()->Net();
588 m_netN = m_start.PrimN()->Net();
589
590 m_currentStart = p;
591 m_currentEnd = p;
592 m_placingVia = false;
593 m_chainedPlacement = false;
594 m_currentTraceOk = false;
595 m_currentTrace = DIFF_PAIR();
597
599
600 return true;
601}
ITEM * PrimN() const
ITEM * PrimP() const
int Net() const
Definition: pns_item.h:152
void SetFailureReason(const wxString &aReason)
Definition: pns_router.h:203

References FindDpPrimitivePair(), initPlacement(), m_chainedPlacement, m_currentEnd, m_currentNode, m_currentStart, m_currentTrace, m_currentTraceOk, m_netN, m_netP, m_placingVia, m_start, m_world, PNS::ITEM::Net(), PNS::DP_PRIMITIVE_PAIR::PrimN(), PNS::DP_PRIMITIVE_PAIR::PrimP(), PNS::ALGO_BASE::Router(), PNS::ROUTER::SetFailureReason(), PNS::DIFF_PAIR::SetNets(), and setWorld().

◆ ToggleVia()

bool PNS::DIFF_PAIR_PLACER::ToggleVia ( bool  aEnabled)
overridevirtual

Enable/disable a via at the end of currently routed trace.

Reimplemented from PNS::PLACEMENT_ALGO.

Definition at line 91 of file pns_diff_pair_placer.cpp.

92{
93 m_placingVia = aEnabled;
94
95 if( !m_idle )
96 Move( m_currentEnd, nullptr );
97
98 return true;
99}

References m_currentEnd, m_idle, m_placingVia, and Move().

◆ Traces()

const ITEM_SET PNS::DIFF_PAIR_PLACER::Traces ( )
overridevirtual

Return the complete routed line, as a single-member ITEM_SET.

Implements PNS::PLACEMENT_ALGO.

Definition at line 379 of file pns_diff_pair_placer.cpp.

380{
381 ITEM_SET t;
382
383 t.Add( &m_currentTrace.PLine() );
384 t.Add( &m_currentTrace.NLine() );
385
386 return t;
387}

References PNS::ITEM_SET::Add(), m_currentTrace, PNS::DIFF_PAIR::NLine(), and PNS::DIFF_PAIR::PLine().

◆ tryWalkDp()

bool PNS::DIFF_PAIR_PLACER::tryWalkDp ( NODE aNode,
DIFF_PAIR aPair,
bool  aSolidsOnly 
)
private

route step, walk around mode

Definition at line 265 of file pns_diff_pair_placer.cpp.

266{
267 DIFF_PAIR best;
268 double bestScore = 100000000000000.0;
269
270 for( int attempt = 0; attempt <= 3; attempt++ )
271 {
272 DIFF_PAIR p;
273 NODE *tmp = m_currentNode->Branch();
274
275 bool pfirst = ( attempt & 1 ) ? true : false;
276 bool wind_cw = ( attempt & 2 ) ? true : false;
277
278 if( attemptWalk( tmp, &aPair, p, pfirst, wind_cw, aSolidsOnly ) )
279 {
280 // double len = p.TotalLength();
281 double cl = 1 + p.CoupledLength();
282 double skew = p.Skew();
283
284 double score = cl + fabs( skew ) * 3.0;
285
286 if( score < bestScore )
287 {
288 bestScore = score;
289 best = p;
290 }
291 }
292
293 delete tmp;
294 }
295
296 if( bestScore > 0.0 )
297 {
298 OPTIMIZER optimizer( m_currentNode );
299
300 aPair.SetShape( best );
301 optimizer.Optimize( &aPair );
302
303 return true;
304 }
305
306 return false;
307}
bool attemptWalk(NODE *aNode, DIFF_PAIR *aCurrent, DIFF_PAIR &aWalk, bool aPFirst, bool aWindCw, bool aSolidsOnly)

References attemptWalk(), PNS::NODE::Branch(), PNS::DIFF_PAIR::CoupledLength(), m_currentNode, PNS::OPTIMIZER::Optimize(), PNS::DIFF_PAIR::SetShape(), and PNS::DIFF_PAIR::Skew().

Referenced by rhShoveOnly(), and rhWalkOnly().

◆ UnfixRoute()

virtual bool PNS::PLACEMENT_ALGO::UnfixRoute ( )
inlinevirtualinherited

Reimplemented in PNS::LINE_PLACER.

Definition at line 81 of file pns_placement_algo.h.

81{ return false; };

◆ updateLeadingRatLine()

void PNS::DIFF_PAIR_PLACER::updateLeadingRatLine ( )
private

Draw the "leading" ratsnest line, which connects the end of currently routed track and the nearest yet unrouted item.

If the routing for current net is complete, draws nothing.

Definition at line 845 of file pns_diff_pair_placer.cpp.

846{
847 SHAPE_LINE_CHAIN ratLineN, ratLineP;
848 TOPOLOGY topo( m_lastNode );
849
850 if( topo.LeadingRatLine( &m_currentTrace.PLine(), ratLineP ) )
851 m_router->GetInterface()->DisplayRatline( ratLineP, 1 );
852
853 if( topo.LeadingRatLine ( &m_currentTrace.NLine(), ratLineN ) )
854 m_router->GetInterface()->DisplayRatline( ratLineN, 3 );
855}
virtual void DisplayRatline(const SHAPE_LINE_CHAIN &aRatline, int aColor=-1)=0
ROUTER_IFACE * GetInterface() const
Definition: pns_router.h:208

References PNS::ROUTER_IFACE::DisplayRatline(), PNS::ROUTER::GetInterface(), PNS::TOPOLOGY::LeadingRatLine(), m_currentTrace, m_lastNode, PNS::ALGO_BASE::m_router, PNS::DIFF_PAIR::NLine(), and PNS::DIFF_PAIR::PLine().

Referenced by Move().

◆ UpdateSizes()

void PNS::DIFF_PAIR_PLACER::UpdateSizes ( const SIZES_SETTINGS aSizes)
overridevirtual

Perform on-the-fly update of the width, via diameter & drill size from a settings class.

Used to dynamically change these parameters as the track is routed.

Reimplemented from PNS::PLACEMENT_ALGO.

Definition at line 730 of file pns_diff_pair_placer.cpp.

731{
732 m_sizes = aSizes;
733
734 if( !m_idle )
735 {
738
740 {
743 }
744 }
745}
void SetViaDiameter(int aDiameter)
void SetViaDrill(int aDrill)

References PNS::SIZES_SETTINGS::DiffPairGap(), PNS::SIZES_SETTINGS::DiffPairWidth(), PNS::DIFF_PAIR::EndsWithVias(), m_currentTrace, m_idle, m_sizes, PNS::DIFF_PAIR::SetGap(), PNS::DIFF_PAIR::SetViaDiameter(), PNS::DIFF_PAIR::SetViaDrill(), PNS::DIFF_PAIR::SetWidth(), PNS::SIZES_SETTINGS::ViaDiameter(), and PNS::SIZES_SETTINGS::ViaDrill().

◆ viaGap()

int PNS::DIFF_PAIR_PLACER::viaGap ( ) const
private

◆ VisibleViewArea()

const BOX2I & PNS::ALGO_BASE::VisibleViewArea ( ) const
inherited

Definition at line 40 of file pns_algo_base.cpp.

41{
42 return m_router->VisibleViewArea();
43}
const BOX2I & VisibleViewArea() const
Definition: pns_router.h:211

References PNS::ALGO_BASE::m_router, and PNS::ROUTER::VisibleViewArea().

Referenced by PNS::DRAGGER::optimizeAndUpdateDraggedLine(), and PNS::SHOVE::runOptimizer().

Member Data Documentation

◆ m_chainedPlacement

bool PNS::DIFF_PAIR_PLACER::m_chainedPlacement
private

Definition at line 217 of file pns_diff_pair_placer.h.

Referenced by DIFF_PAIR_PLACER(), FixRoute(), SetLayer(), and Start().

◆ m_currentEnd

VECTOR2I PNS::DIFF_PAIR_PLACER::m_currentEnd
private

◆ m_currentEndItem

ITEM* PNS::DIFF_PAIR_PLACER::m_currentEndItem
private

Definition at line 270 of file pns_diff_pair_placer.h.

Referenced by DIFF_PAIR_PLACER(), initPlacement(), Move(), and routeHead().

◆ m_currentLayer

int PNS::DIFF_PAIR_PLACER::m_currentLayer
private

◆ m_currentNet

int PNS::DIFF_PAIR_PLACER::m_currentNet
private

Definition at line 259 of file pns_diff_pair_placer.h.

Referenced by DIFF_PAIR_PLACER().

◆ m_currentNode

NODE* PNS::DIFF_PAIR_PLACER::m_currentNode
private

Postprocessed world state (including marked collisions & removed loops)

Definition at line 240 of file pns_diff_pair_placer.h.

Referenced by CommitPlacement(), CurrentNode(), DIFF_PAIR_PLACER(), initPlacement(), Move(), propagateDpHeadForces(), rhMarkObstacles(), rhShoveOnly(), rhWalkOnly(), routeHead(), Start(), and tryWalkDp().

◆ m_currentStart

VECTOR2I PNS::DIFF_PAIR_PLACER::m_currentStart
private

Definition at line 266 of file pns_diff_pair_placer.h.

Referenced by Start().

◆ m_currentTrace

◆ m_currentTraceOk

bool PNS::DIFF_PAIR_PLACER::m_currentTraceOk
private

Definition at line 268 of file pns_diff_pair_placer.h.

Referenced by DIFF_PAIR_PLACER(), routeHead(), and Start().

◆ m_currentWidth

int PNS::DIFF_PAIR_PLACER::m_currentWidth
private

Definition at line 257 of file pns_diff_pair_placer.h.

Referenced by DIFF_PAIR_PLACER().

◆ m_debugDecorator

DEBUG_DECORATOR* PNS::ALGO_BASE::m_debugDecorator
protectedinherited

Definition at line 86 of file pns_algo_base.h.

Referenced by PNS::ALGO_BASE::Dbg(), and PNS::ALGO_BASE::SetDebugDecorator().

◆ m_fitOk

bool PNS::DIFF_PAIR_PLACER::m_fitOk
private

◆ m_idle

bool PNS::DIFF_PAIR_PLACER::m_idle
private

◆ m_initialDiagonal

bool PNS::DIFF_PAIR_PLACER::m_initialDiagonal
private

Definition at line 218 of file pns_diff_pair_placer.h.

Referenced by DIFF_PAIR_PLACER(), FixRoute(), and initPlacement().

◆ m_iteration

int PNS::DIFF_PAIR_PLACER::m_iteration
private

pointer to world to search colliding items

Definition at line 228 of file pns_diff_pair_placer.h.

Referenced by DIFF_PAIR_PLACER().

◆ m_lastNode

NODE* PNS::DIFF_PAIR_PLACER::m_lastNode
private

◆ m_logger

LOGGER* PNS::ALGO_BASE::m_logger
protectedinherited

Definition at line 88 of file pns_algo_base.h.

Referenced by PNS::ALGO_BASE::SetLogger().

◆ m_netN

int PNS::DIFF_PAIR_PLACER::m_netN
private

◆ m_netP

int PNS::DIFF_PAIR_PLACER::m_netP
private

◆ m_orthoMode

bool PNS::DIFF_PAIR_PLACER::m_orthoMode
private

Definition at line 263 of file pns_diff_pair_placer.h.

Referenced by DIFF_PAIR_PLACER(), initPlacement(), and SetOrthoMode().

◆ m_p_start

VECTOR2I PNS::DIFF_PAIR_PLACER::m_p_start
private

The shove engine.

Definition at line 234 of file pns_diff_pair_placer.h.

◆ m_placingVia

bool PNS::DIFF_PAIR_PLACER::m_placingVia
private

current via diameter

Definition at line 248 of file pns_diff_pair_placer.h.

Referenced by DIFF_PAIR_PLACER(), FixRoute(), IsPlacingVia(), propagateDpHeadForces(), routeHead(), Start(), and ToggleVia().

◆ m_prevPair

OPT<DP_PRIMITIVE_PAIR> PNS::DIFF_PAIR_PLACER::m_prevPair
private

current algorithm iteration

Definition at line 225 of file pns_diff_pair_placer.h.

Referenced by FixRoute(), routeHead(), and SetLayer().

◆ m_router

◆ m_shove

std::unique_ptr<SHOVE> PNS::DIFF_PAIR_PLACER::m_shove
private

Current world state.

Definition at line 237 of file pns_diff_pair_placer.h.

Referenced by DIFF_PAIR_PLACER(), initPlacement(), and rhShoveOnly().

◆ m_sizes

SIZES_SETTINGS PNS::DIFF_PAIR_PLACER::m_sizes
private

Are we placing a via?

Definition at line 245 of file pns_diff_pair_placer.h.

Referenced by gap(), makeVia(), propagateDpHeadForces(), routeHead(), UpdateSizes(), and viaGap().

◆ m_snapOnTarget

bool PNS::DIFF_PAIR_PLACER::m_snapOnTarget
private

Definition at line 264 of file pns_diff_pair_placer.h.

Referenced by DIFF_PAIR_PLACER(), FixRoute(), and routeHead().

◆ m_start

DP_PRIMITIVE_PAIR PNS::DIFF_PAIR_PLACER::m_start
private

Definition at line 224 of file pns_diff_pair_placer.h.

Referenced by routeHead(), SetLayer(), and Start().

◆ m_startDiagonal

bool PNS::DIFF_PAIR_PLACER::m_startDiagonal
private

Definition at line 219 of file pns_diff_pair_placer.h.

Referenced by DIFF_PAIR_PLACER(), FlipPosture(), initPlacement(), and routeHead().

◆ m_startsOnVia

bool PNS::DIFF_PAIR_PLACER::m_startsOnVia
private

Definition at line 262 of file pns_diff_pair_placer.h.

Referenced by DIFF_PAIR_PLACER().

◆ m_state

State PNS::DIFF_PAIR_PLACER::m_state
private

Definition at line 215 of file pns_diff_pair_placer.h.

Referenced by DIFF_PAIR_PLACER().

◆ m_viaDiameter

int PNS::DIFF_PAIR_PLACER::m_viaDiameter
private

current via drill

Definition at line 251 of file pns_diff_pair_placer.h.

Referenced by DIFF_PAIR_PLACER().

◆ m_viaDrill

int PNS::DIFF_PAIR_PLACER::m_viaDrill
private

current track width

Definition at line 254 of file pns_diff_pair_placer.h.

Referenced by DIFF_PAIR_PLACER().

◆ m_world

NODE* PNS::DIFF_PAIR_PLACER::m_world
private

current routing start point (end of tail, beginning of head)

Definition at line 231 of file pns_diff_pair_placer.h.

Referenced by AbortPlacement(), DIFF_PAIR_PLACER(), setWorld(), and Start().


The documentation for this class was generated from the following files: