KiCad PCB EDA Suite
PNS::DIFF_PAIR_PLACER Class Reference

Class LINE_PLACER. 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
 Function Start() More...
 
bool Move (const VECTOR2I &aP, ITEM *aEndItem) override
 Function Move() More...
 
bool FixRoute (const VECTOR2I &aP, ITEM *aEndItem) override
 Function FixRoute() More...
 
bool ToggleVia (bool aEnabled) override
 Function ToggleVia() More...
 
bool SetLayer (int aLayer) override
 Function SetLayer() More...
 
const ITEM_SET Traces () override
 Function Traces() More...
 
const VECTOR2ICurrentEnd () const override
 Function CurrentEnd() More...
 
const std::vector< int > CurrentNets () const override
 Function CurrentNets() More...
 
int CurrentLayer () const override
 Function CurrentLayer() More...
 
NODECurrentNode (bool aLoopsRemoved=false) const override
 Function CurrentNode() More...
 
void FlipPosture () override
 Function FlipPosture() More...
 
void UpdateSizes (const SIZES_SETTINGS &aSizes) override
 Function UpdateSizes() 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...
 
ROUTERRouter () const
 

Returns the instance of our router

More...
 
ROUTING_SETTINGSSettings () const
 

Returns current router settings

More...
 
virtual LOGGERLogger ()
 

Returns the logger object, allowing to dump geometry to a file.

More...
 
void SetDebugDecorator (DEBUG_DECORATOR *aDecorator)
 Function SetDebugDecorator. More...
 
DEBUG_DECORATORDbg () const
 

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)
 Function route() More...
 
void updateLeadingRatLine ()
 Function updateLeadingRatLine() More...
 
void setWorld (NODE *aWorld)
 Function setWorld() More...
 
void initPlacement ()
 Function startPlacement() More...
 
void setInitialDirection (const DIRECTION_45 &aDirection)
 Function setInitialDirection() More...
 
bool routeHead (const VECTOR2I &aP)
 
bool tryWalkDp (NODE *aNode, DIFF_PAIR &aPair, bool aSolidsOnly)
 
bool rhWalkOnly (const VECTOR2I &aP)
 

route step, walkaround mode

More...
 
bool rhShoveOnly (const VECTOR2I &aP)
 

route step, shove mode

More...
 
bool rhMarkObstacles (const VECTOR2I &aP)
 

route step, mark obstacles mode

More...
 
const VIA makeVia (const VECTOR2I &aP, int aNet)
 
bool findDpPrimitivePair (const VECTOR2I &aP, ITEM *aItem, DP_PRIMITIVE_PAIR &aPair, wxString *aErrorMsg=nullptr)
 
OPT_VECTOR2I getDanglingAnchor (NODE *aNode, ITEM *aItem)
 
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
 
int m_iteration
 

current algorithm iteration

More...
 
NODEm_world
 

pointer to world to search colliding items

More...
 
VECTOR2I m_p_start
 

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

More...
 
SHOVEm_shove
 

The shove engine

More...
 
NODEm_currentNode
 

Current world state

More...
 
NODEm_lastNode
 

Postprocessed world state (including marked collisions & removed loops)

More...
 
SIZES_SETTINGS m_sizes
 
bool m_placingVia
 

Are we placing a via?

More...
 
int m_viaDiameter
 

current via diameter

More...
 
int m_viaDrill
 

current via drill

More...
 
int m_currentWidth
 

current track width

More...
 
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
 
ITEMm_currentEndItem
 
PNS_MODE m_currentMode
 
bool m_idle
 

Detailed Description

Class LINE_PLACER.

Single track placement algorithm. Interactively routes a track. Applies shove and walkaround algorithms when needed.

Definition at line 55 of file pns_diff_pair_placer.h.

Member Enumeration Documentation

Enumerator
RT_START 
RT_ROUTE 
RT_FINISH 

Definition at line 234 of file pns_diff_pair_placer.h.

Constructor & Destructor Documentation

PNS::DIFF_PAIR_PLACER::DIFF_PAIR_PLACER ( ROUTER aRouter)

Definition at line 38 of file pns_diff_pair_placer.cpp.

References m_chainedPlacement, m_currentEndItem, m_currentLayer, m_currentMode, m_currentNet, m_currentNode, 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, PNS::RM_MarkObstacles, and RT_START.

38  :
39  PLACEMENT_ALGO( aRouter )
40 {
41  m_state = RT_START;
42  m_chainedPlacement = false;
43  m_initialDiagonal = false;
44  m_startDiagonal = false;
45  m_fitOk = false;
46  m_netP = 0;
47  m_netN = 0;
48  m_iteration = 0;
49  m_world = NULL;
50  m_shove = NULL;
51  m_currentNode = NULL;
52  m_lastNode = NULL;
53  m_placingVia = false;
54  m_viaDiameter = 0;
55  m_viaDrill = 0;
56  m_currentWidth = 0;
57  m_currentNet = 0;
58  m_currentLayer = 0;
59  m_startsOnVia = false;
60  m_orthoMode = false;
61  m_snapOnTarget = false;
62  m_currentEndItem = NULL;
64  m_idle = true;
65 }
int m_iteration
current algorithm iteration
SHOVE * m_shove
The shove engine
int m_viaDiameter
current via diameter
NODE * m_world
pointer to world to search colliding items
int m_viaDrill
current via drill
bool m_placingVia
Are we placing a via?
NODE * m_currentNode
Current world state
PLACEMENT_ALGO(ROUTER *aRouter)
int m_currentWidth
current track width
NODE * m_lastNode
Postprocessed world state (including marked collisions & removed loops)
PNS::DIFF_PAIR_PLACER::~DIFF_PAIR_PLACER ( )

Definition at line 67 of file pns_diff_pair_placer.cpp.

References m_shove.

68 {
69  if( m_shove )
70  delete m_shove;
71 }
SHOVE * m_shove
The shove engine

Member Function Documentation

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

Definition at line 161 of file pns_diff_pair_placer.cpp.

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::ROUTER::GetRuleResolver(), PNS::LINE::Line(), PNS::DIFF_PAIR::NetN(), PNS::DIFF_PAIR::NetP(), PNS::DIFF_PAIR::NLine(), PNS::RULE_RESOLVER::OverrideClearance(), PNS::DIFF_PAIR::PLine(), PNS_HULL_MARGIN, PNS::SHOVE::ProcessSingleLine(), 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, SHAPE_LINE_CHAIN::Simplify(), and PNS::ITEM::SOLID_T.

Referenced by IsPlacingVia(), and tryWalkDp().

163 {
164  WALKAROUND walkaround( aNode, Router() );
166 
168  aCurrent->NetP(), aCurrent->NetN(), aCurrent->Gap() );
169 
170  walkaround.SetSolidsOnly( aSolidsOnly );
171  walkaround.SetIterationLimit( Settings().WalkaroundIterationLimit() );
172 
173  SHOVE shove( aNode, Router() );
174  LINE walkP, walkN;
175 
176  aWalk = *aCurrent;
177 
178  int iter = 0;
179 
180  DIFF_PAIR cur( *aCurrent );
181 
182  bool currentIsP = aPFirst;
183 
184  int mask = aSolidsOnly ? ITEM::SOLID_T : ITEM::ANY_T;
185 
186  do
187  {
188  LINE preWalk = ( currentIsP ? cur.PLine() : cur.NLine() );
189  LINE preShove = ( currentIsP ? cur.NLine() : cur.PLine() );
190  LINE postWalk;
191 
192  if( !aNode->CheckColliding ( &preWalk, mask ) )
193  {
194  currentIsP = !currentIsP;
195 
196  if( !aNode->CheckColliding( &preShove, mask ) )
197  break;
198  else
199  continue;
200  }
201 
202  wf1 = walkaround.Route( preWalk, postWalk, false );
203 
204  if( wf1 != WALKAROUND::DONE )
205  return false;
206 
207  LINE postShove( preShove );
208 
209  shove.ForceClearance( true, cur.Gap() - 2 * PNS_HULL_MARGIN );
210 
212 
213  sh1 = shove.ProcessSingleLine( postWalk, preShove, postShove );
214 
215  if( sh1 != SHOVE::SH_OK )
216  return false;
217 
218  postWalk.Line().Simplify();
219  postShove.Line().Simplify();
220 
221  cur.SetShape( postWalk.CLine(), postShove.CLine(), !currentIsP );
222 
223  currentIsP = !currentIsP;
224 
225  if( !aNode->CheckColliding( &postShove, mask ) )
226  break;
227 
228  iter++;
229  }
230  while( iter < 3 );
231 
232  if( iter == 3 )
233  return false;
234 
235  aWalk.SetShape( cur.CP(), cur.CN() );
237 
238  return true;
239 }
#define PNS_HULL_MARGIN
Class LINE.
Definition: pns_line.h:58
ROUTING_SETTINGS & Settings() const
Returns current router settings
ROUTER * Router() const
Returns the instance of our router
Definition: pns_algo_base.h:49
RULE_RESOLVER * GetRuleResolver() const
Definition: pns_router.h:163
virtual void OverrideClearance(bool aEnable, int aNetA=0, int aNetB=0, int aClearance=0)=0
const VECTOR2I& PNS::DIFF_PAIR_PLACER::CurrentEnd ( ) const
inlineoverridevirtual

Function CurrentEnd()

Returns 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 116 of file pns_diff_pair_placer.h.

References CurrentNets(), and m_currentEnd.

117  {
118  return m_currentEnd;
119  }
int PNS::DIFF_PAIR_PLACER::CurrentLayer ( ) const
inlineoverridevirtual

Function CurrentLayer()

Returns the layer of currently routed track.

Implements PNS::PLACEMENT_ALGO.

Definition at line 133 of file pns_diff_pair_placer.h.

References CurrentNode(), FlipPosture(), m_currentLayer, and UpdateSizes().

134  {
135  return m_currentLayer;
136  }
const std::vector< int > PNS::DIFF_PAIR_PLACER::CurrentNets ( ) const
overridevirtual

Function CurrentNets()

Returns the net code of currently routed track.

Implements PNS::PLACEMENT_ALGO.

Definition at line 836 of file pns_diff_pair_placer.cpp.

References m_netN, and m_netP.

Referenced by CurrentEnd().

837 {
838  std::vector<int> rv;
839  rv.push_back( m_netP );
840  rv.push_back( m_netN );
841  return rv;
842 }
NODE * PNS::DIFF_PAIR_PLACER::CurrentNode ( bool  aLoopsRemoved = false) const
overridevirtual

Function CurrentNode()

Returns the most recent world state.

Implements PNS::PLACEMENT_ALGO.

Definition at line 376 of file pns_diff_pair_placer.cpp.

References m_currentNode, and m_lastNode.

Referenced by CurrentLayer().

377 {
378  if( m_lastNode )
379  return m_lastNode;
380 
381  return m_currentNode;
382 }
NODE * m_currentNode
Current world state
NODE * m_lastNode
Postprocessed world state (including marked collisions & removed loops)
bool PNS::DIFF_PAIR_PLACER::findDpPrimitivePair ( const VECTOR2I aP,
ITEM aItem,
DP_PRIMITIVE_PAIR aPair,
wxString *  aErrorMsg = nullptr 
)
private

Definition at line 440 of file pns_diff_pair_placer.cpp.

References PNS::NODE::AllItemsInNet(), dist, PNS::RULE_RESOLVER::DpNetPair(), EuclideanNorm(), Format(), getDanglingAnchor(), PNS::NODE::GetRuleResolver(), PNS::ITEM::Kind(), PNS::ITEM::Layers(), m_currentNode, m_world, max, PNS::ITEM::Net(), PNS::RULE_RESOLVER::NetName(), PNS::DP_PRIMITIVE_PAIR::SetAnchors(), and PNS::ITEM::SOLID_T.

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

442 {
443  int netP, netN;
444 
445  wxLogTrace( "PNS", "world %p", m_world );
446 
447  bool result = m_world->GetRuleResolver()->DpNetPair( aItem, netP, netN );
448 
449  if( !result )
450  {
451  if( aErrorMsg )
452  {
453  *aErrorMsg = _( "Unable to find complementary differential pair "
454  "nets. Make sure the names of the nets belonging "
455  "to a differential pair end with either _N/_P or +/-." );
456  }
457  return false;
458  }
459 
460  int refNet = aItem->Net();
461  int coupledNet = ( refNet == netP ) ? netN : netP;
462 
463  wxLogTrace( "PNS", "result %d", !!result );
464 
465  OPT_VECTOR2I refAnchor = getDanglingAnchor( m_currentNode, aItem );
466  ITEM* primRef = aItem;
467 
468  wxLogTrace( "PNS", "refAnchor %p", aItem );
469 
470  if( !refAnchor )
471  {
472  if( aErrorMsg )
473  {
474  *aErrorMsg = _( "Can't find a suitable starting point. If starting "
475  "from an existing differential pair make sure you are "
476  "at the end. " );
477  }
478  return false;
479  }
480 
481  std::set<ITEM*> coupledItems;
482 
483  m_currentNode->AllItemsInNet( coupledNet, coupledItems );
484  double bestDist = std::numeric_limits<double>::max();
485  bool found = false;
486 
487  for( ITEM* item : coupledItems )
488  {
489  if( item->Kind() == aItem->Kind() )
490  {
491  OPT_VECTOR2I anchor = getDanglingAnchor( m_currentNode, item );
492  if( !anchor )
493  continue;
494 
495  double dist = ( *anchor - *refAnchor ).EuclideanNorm();
496 
497  bool shapeMatches = true;
498 
499  if( item->OfKind( ITEM::SOLID_T ) && item->Layers() != aItem->Layers() )
500  {
501  shapeMatches = false;
502  }
503 
504  if( dist < bestDist && shapeMatches )
505  {
506  found = true;
507  bestDist = dist;
508 
509  if( refNet == netP )
510  {
511  aPair = DP_PRIMITIVE_PAIR ( item, primRef );
512  aPair.SetAnchors( *anchor, *refAnchor );
513  }
514  else
515  {
516  aPair = DP_PRIMITIVE_PAIR( primRef, item );
517  aPair.SetAnchors( *refAnchor, *anchor );
518  }
519  }
520  }
521  }
522 
523  if( !found )
524  {
525  if( aErrorMsg )
526  {
527  *aErrorMsg = wxString::Format( _( "Can't find a suitable starting point "
528  "for coupled net \"%s\"." ),
529  m_world->GetRuleResolver()->NetName( coupledNet ) );
530  }
531  return false;
532  }
533 
534  return true;
535 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:112
void AllItemsInNet(int aNet, std::set< ITEM * > &aItems)
Definition: pns_node.cpp:1234
static const int dist[10][10]
Definition: dist.cpp:57
NODE * m_world
pointer to world to search colliding items
OPT< VECTOR2I > OPT_VECTOR2I
Definition: seg.h:34
virtual bool DpNetPair(ITEM *aItem, int &aNetP, int &aNetN)=0
NODE * m_currentNode
Current world state
RULE_RESOLVER * GetRuleResolver()
Definition: pns_node.h:169
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
#define max(a, b)
Definition: auxiliary.h:86
virtual wxString NetName(int aNet)=0
OPT_VECTOR2I getDanglingAnchor(NODE *aNode, ITEM *aItem)
bool PNS::DIFF_PAIR_PLACER::FixRoute ( const VECTOR2I aP,
ITEM aEndItem 
)
overridevirtual

Function FixRoute()

Commits 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 commited. May return false if the routing result is violating design rules - in such case, the track is only committed if Settings.CanViolateDRC() is on.

Implements PNS::PLACEMENT_ALGO.

Definition at line 744 of file pns_diff_pair_placer.cpp.

References PNS::NODE::Add(), PNS::Clone(), PNS::DIFF_PAIR::CN(), PNS::ROUTER::CommitRouting(), PNS::DIFF_PAIR::CP(), SHAPE_LINE_CHAIN::CSegment(), PNS::DIFF_PAIR::EndingPrimitives(), PNS::DIFF_PAIR::EndsWithVias(), initPlacement(), 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(), PNS::ALGO_BASE::Router(), SHAPE_LINE_CHAIN::SegmentCount(), PNS::DIFF_PAIR::SetShape(), PNS::TOPOLOGY::SimplifyLine(), and PNS::LINE::Via().

745 {
746  if( !m_fitOk )
747  return false;
748 
749  if( m_currentTrace.CP().SegmentCount() < 1 ||
750  m_currentTrace.CN().SegmentCount() < 1 )
751  return false;
752 
753  if( m_currentTrace.CP().SegmentCount() > 1 )
754  m_initialDiagonal = !DIRECTION_45( m_currentTrace.CP().CSegment( -2 ) ).IsDiagonal();
755 
756  TOPOLOGY topo( m_lastNode );
757 
759  {
762 
763  if( newP.SegmentCount() > 1 && newN.SegmentCount() > 1 )
764  {
765  newP.Remove( -1, -1 );
766  newN.Remove( -1, -1 );
767  }
768 
769  m_currentTrace.SetShape( newP, newN );
770  }
771 
773  {
776  m_chainedPlacement = false;
777  }
778  else
779  {
781  }
782 
783  LINE lineP( m_currentTrace.PLine() );
784  LINE lineN( m_currentTrace.NLine() );
785 
786  m_lastNode->Add( lineP );
787  m_lastNode->Add( lineN );
788 
789  topo.SimplifyLine( &lineP );
790  topo.SimplifyLine( &lineN );
791 
793 
795 
796  m_lastNode = NULL;
797  m_placingVia = false;
798 
799  if( m_snapOnTarget )
800  {
801  m_idle = true;
802  return true;
803  }
804  else
805  {
806  initPlacement();
807  return false;
808  }
809 }
const VIA & Via() const
Definition: pns_line.h:253
void SetShape(const SHAPE_LINE_CHAIN &aP, const SHAPE_LINE_CHAIN &aN, bool aSwapLanes=false)
const SHAPE_LINE_CHAIN & CN() const
const SEG CSegment(int aIndex) const
Function CSegment()
Class DIRECTION_45.
Definition: direction45.h:36
bool EndsWithVias() const
bool m_placingVia
Are we placing a via?
void Remove(int aStartIndex, int aEndIndex)
Function Remove()
ROUTER * Router() const
Returns the instance of our router
Definition: pns_algo_base.h:49
std::unique_ptr< typename std::remove_const< T >::type > Clone(const T &aItem)
Definition: pns_item.h:380
void CommitRouting(NODE *aNode)
Definition: pns_router.cpp:347
Class SHAPE_LINE_CHAIN.
void initPlacement()
Function startPlacement()
OPT< DP_PRIMITIVE_PAIR > m_prevPair
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Function Add()
Definition: pns_node.cpp:594
int SegmentCount() const
Function SegmentCount()
DP_PRIMITIVE_PAIR EndingPrimitives()
const SHAPE_LINE_CHAIN & CP() const
NODE * m_lastNode
Postprocessed world state (including marked collisions & removed loops)
void PNS::DIFF_PAIR_PLACER::FlipPosture ( )
overridevirtual

Function FlipPosture()

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

Reimplemented from PNS::PLACEMENT_ALGO.

Definition at line 367 of file pns_diff_pair_placer.cpp.

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

Referenced by CurrentLayer().

368 {
370 
371  if( !m_idle )
372  Move( m_currentEnd, NULL );
373 }
bool Move(const VECTOR2I &aP, ITEM *aEndItem) override
Function Move()
int PNS::DIFF_PAIR_PLACER::gap ( ) const
private
OPT_VECTOR2I PNS::DIFF_PAIR_PLACER::getDanglingAnchor ( NODE aNode,
ITEM aItem 
)
private

Definition at line 409 of file pns_diff_pair_placer.cpp.

References SEG::A, PNS::ITEM::Anchor(), SEG::B, PNS::NODE::FindJoint(), PNS::ITEM::Kind(), PNS::JOINT::LinkCount(), PNS::SEGMENT::Seg(), PNS::ITEM::SEGMENT_T, PNS::ITEM::SOLID_T, and PNS::ITEM::VIA_T.

Referenced by findDpPrimitivePair(), and IsPlacingVia().

410 {
411  switch( aItem->Kind() )
412  {
413  case ITEM::VIA_T:
414  case ITEM::SOLID_T:
415  return aItem->Anchor( 0 );
416 
417  case ITEM::SEGMENT_T:
418  {
419  SEGMENT* s =static_cast<SEGMENT*>( aItem );
420 
421  JOINT* jA = aNode->FindJoint( s->Seg().A, s );
422  JOINT* jB = aNode->FindJoint( s->Seg().B, s );
423 
424  if( jA->LinkCount() == 1 )
425  return s->Seg().A;
426  else if( jB->LinkCount() == 1 )
427  return s->Seg().B;
428  else
429  return OPT_VECTOR2I();
430  }
431 
432  default:
433  return OPT_VECTOR2I();
434  break;
435  }
436 }
OPT< VECTOR2I > OPT_VECTOR2I
Definition: seg.h:34
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 812 of file pns_diff_pair_placer.cpp.

References m_netN, and m_netP.

Referenced by IsPlacingVia().

813 {
814  aNets.push_back( m_netP );
815  aNets.push_back( m_netN );
816 }
void PNS::DIFF_PAIR_PLACER::initPlacement ( )
private

Function startPlacement()

Initializes placement of a new line with given parameters.

Definition at line 607 of file pns_diff_pair_placer.cpp.

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

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

608 {
609  m_idle = false;
610  m_orthoMode = false;
611  m_currentEndItem = NULL;
613 
614  NODE* world = Router()->GetWorld();
615 
616  world->KillChildren();
617  NODE* rootNode = world->Branch();
618 
619  setWorld( rootNode );
620 
621  m_lastNode = NULL;
622  m_currentNode = rootNode;
624 
625  if( m_shove )
626  delete m_shove;
627 
628  m_shove = NULL;
629 
631  {
632  m_shove = new SHOVE( m_currentNode, Router() );
633  }
634 }
PNS_MODE Mode() const
Returns the routing mode.
Ignore collisions, mark obstacles
SHOVE * m_shove
The shove engine
ROUTING_SETTINGS & Settings() const
Returns current router settings
NODE * GetWorld() const
Definition: pns_router.h:143
void KillChildren()
Destroys all child nodes. Applicable only to the root node.
Definition: pns_node.cpp:1227
ROUTER * Router() const
Returns the instance of our router
Definition: pns_algo_base.h:49
Only walkaround
NODE * m_currentNode
Current world state
void setWorld(NODE *aWorld)
Function setWorld()
NODE * m_lastNode
Postprocessed world state (including marked collisions & removed loops)
bool PNS::DIFF_PAIR_PLACER::IsPlacingVia ( ) const
inlineoverridevirtual
LOGGER * PNS::ALGO_BASE::Logger ( )
virtualinherited

Returns the logger object, allowing to dump geometry to a file.

Reimplemented in PNS::LINE_PLACER, PNS::WALKAROUND, PNS::DRAGGER, and PNS::SHOVE.

Definition at line 34 of file pns_algo_base.cpp.

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

35 {
36  return NULL;
37 }
const VIA PNS::DIFF_PAIR_PLACER::makeVia ( const VECTOR2I aP,
int  aNet 
)
private

Definition at line 79 of file pns_diff_pair_placer.cpp.

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 IsPlacingVia(), propagateDpHeadForces(), and routeHead().

80 {
82 
83  VIA v( aP, layers, m_sizes.ViaDiameter(), m_sizes.ViaDrill(), -1, m_sizes.ViaType() );
84  v.SetNet( aNet );
85 
86  return v;
87 }
VIATYPE_T ViaType() const
void SetNet(NETINFO_ITEM *aNetInfo)
Function SetNet Sets a NET_INFO object for the item.
Class LAYER_RANGE.
Definition: pns_layerset.h:32
bool PNS::DIFF_PAIR_PLACER::Move ( const VECTOR2I aP,
ITEM aEndItem 
)
overridevirtual

Function Move()

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

Implements PNS::PLACEMENT_ALGO.

Definition at line 709 of file pns_diff_pair_placer.cpp.

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

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

710 {
711  m_currentEndItem = aEndItem;
712  m_fitOk = false;
713 
714  delete m_lastNode;
715  m_lastNode = NULL;
716 
717  if( !route( aP ) )
718  return false;
719 
720  NODE* latestNode = m_currentNode;
721  m_lastNode = latestNode->Branch();
722 
723  assert( m_lastNode != NULL );
724  m_currentEnd = aP;
725 
727 
728  return true;
729 }
bool route(const VECTOR2I &aP)
Function route()
NODE * Branch()
Function Branch()
Definition: pns_node.cpp:107
NODE * m_currentNode
Current world state
void updateLeadingRatLine()
Function updateLeadingRatLine()
NODE * m_lastNode
Postprocessed world state (including marked collisions & removed loops)
bool PNS::DIFF_PAIR_PLACER::propagateDpHeadForces ( const VECTOR2I aP,
VECTOR2I aNewP 
)
private

Definition at line 124 of file pns_diff_pair_placer.cpp.

References PNS::VIA::Diameter(), PNS::SIZES_SETTINGS::DiffPairGap(), m_currentLayer, m_currentMode, m_currentNode, m_placingVia, m_sizes, makeVia(), PNS::VIA::PushoutForce(), PNS::RM_MarkObstacles, PNS::RM_Walkaround, PNS::VIA::SetDiameter(), PNS::ITEM::SetLayer(), PNS::SIZES_SETTINGS::TrackWidth(), and viaGap().

Referenced by IsPlacingVia(), and routeHead().

125 {
126  VIA virtHead = makeVia( aP, -1 );
127 
128  if( m_placingVia )
129  virtHead.SetDiameter( viaGap() + 2 * virtHead.Diameter() );
130  else
131  {
132  virtHead.SetLayer( m_currentLayer );
133  virtHead.SetDiameter( m_sizes.DiffPairGap() + 2 * m_sizes.TrackWidth() );
134  }
135 
136  VECTOR2I lead( 0, 0 );// = aP - m_currentStart ;
137  VECTOR2I force;
138  bool solidsOnly = true;
139 
141  {
142  aNewP = aP;
143  return true;
144  }
145  else if( m_currentMode == RM_Walkaround )
146  {
147  solidsOnly = false;
148  }
149 
150  // fixme: I'm too lazy to do it well. Circular approximaton will do for the moment.
151  if( virtHead.PushoutForce( m_currentNode, lead, force, solidsOnly, 40 ) )
152  {
153  aNewP = aP + force;
154  return true;
155  }
156 
157  return false;
158 }
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
const VIA makeVia(const VECTOR2I &aP, int aNet)
bool m_placingVia
Are we placing a via?
NODE * m_currentNode
Current world state
bool PNS::DIFF_PAIR_PLACER::rhMarkObstacles ( const VECTOR2I aP)
private

route step, mark obstacles mode

Definition at line 110 of file pns_diff_pair_placer.cpp.

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

Referenced by IsPlacingVia(), and route().

111 {
112  if( !routeHead( aP ) )
113  return false;
114 
115  bool collP = static_cast<bool>( m_currentNode->CheckColliding( &m_currentTrace.PLine() ) );
116  bool collN = static_cast<bool>( m_currentNode->CheckColliding( &m_currentTrace.NLine() ) );
117 
118  m_fitOk = !( collP || collN ) ;
119 
120  return m_fitOk;
121 }
bool routeHead(const VECTOR2I &aP)
NODE * m_currentNode
Current world state
OPT_OBSTACLE CheckColliding(const ITEM *aItem, int aKindMask=ITEM::ANY_T)
Function CheckColliding()
Definition: pns_node.cpp:425
bool PNS::DIFF_PAIR_PLACER::rhShoveOnly ( const VECTOR2I aP)
private

route step, shove mode

Definition at line 316 of file pns_diff_pair_placer.cpp.

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

Referenced by IsPlacingVia(), and route().

317 {
319 
320  bool ok = routeHead( aP );
321 
322  m_fitOk = false;
323 
324  if( !ok )
325  return false;
326 
327  if( !tryWalkDp( m_currentNode, m_currentTrace, true ) )
328  return false;
329 
330  LINE pLine( m_currentTrace.PLine() );
331  LINE nLine( m_currentTrace.NLine() );
332  ITEM_SET head;
333 
334  head.Add( &pLine );
335  head.Add( &nLine );
336 
337  SHOVE::SHOVE_STATUS status = m_shove->ShoveMultiLines( head );
338 
340 
341  if( status == SHOVE::SH_OK )
342  {
344 
347  {
348  m_fitOk = true;
349  }
350  }
351 
352  return m_fitOk;
353 }
SHOVE * m_shove
The shove engine
bool routeHead(const VECTOR2I &aP)
NODE * m_currentNode
Current world state
OPT_OBSTACLE CheckColliding(const ITEM *aItem, int aKindMask=ITEM::ANY_T)
Function CheckColliding()
Definition: pns_node.cpp:425
bool tryWalkDp(NODE *aNode, DIFF_PAIR &aPair, bool aSolidsOnly)
SHOVE_STATUS ShoveMultiLines(const ITEM_SET &aHeadSet)
Definition: pns_shove.cpp:1188
NODE * CurrentNode()
Definition: pns_shove.cpp:1402
bool PNS::DIFF_PAIR_PLACER::rhWalkOnly ( const VECTOR2I aP)
private

route step, walkaround mode

Definition at line 287 of file pns_diff_pair_placer.cpp.

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

Referenced by IsPlacingVia(), and route().

288 {
289  if( !routeHead ( aP ) )
290  return false;
291 
293 
294  return m_fitOk;
295 }
bool routeHead(const VECTOR2I &aP)
NODE * m_currentNode
Current world state
bool tryWalkDp(NODE *aNode, DIFF_PAIR &aPair, bool aSolidsOnly)
bool PNS::DIFF_PAIR_PLACER::route ( const VECTOR2I aP)
private

Function route()

Re-routes 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
aPending point of current route.
Returns
true, if the routing is complete.

Definition at line 298 of file pns_diff_pair_placer.cpp.

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

Referenced by IsPlacingVia(), and Move().

299 {
300  switch( m_currentMode )
301  {
302  case RM_MarkObstacles:
303  return rhMarkObstacles( aP );
304  case RM_Walkaround:
305  return rhWalkOnly( aP );
306  case RM_Shove:
307  return rhShoveOnly( aP );
308  default:
309  break;
310  }
311 
312  return false;
313 }
bool rhWalkOnly(const VECTOR2I &aP)
route step, walkaround mode
bool rhShoveOnly(const VECTOR2I &aP)
route step, shove mode
Ignore collisions, mark obstacles
bool rhMarkObstacles(const VECTOR2I &aP)
route step, mark obstacles mode
bool PNS::DIFF_PAIR_PLACER::routeHead ( const VECTOR2I aP)
private

Definition at line 637 of file pns_diff_pair_placer.cpp.

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_currentTrace, m_fitOk, m_netN, m_netP, m_placingVia, m_prevPair, m_sizes, m_snapOnTarget, m_start, m_startDiagonal, makeVia(), propagateDpHeadForces(), 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 IsPlacingVia(), rhMarkObstacles(), rhShoveOnly(), and rhWalkOnly().

638 {
639  m_fitOk = false;
640 
641  DP_GATEWAYS gwsEntry( gap() );
642  DP_GATEWAYS gwsTarget( gap() );
643 
644  if( !m_prevPair )
646 
647  gwsEntry.BuildFromPrimitivePair( *m_prevPair, m_startDiagonal );
648 
649  DP_PRIMITIVE_PAIR target;
650 
651  if( findDpPrimitivePair( aP, m_currentEndItem, target ) )
652  {
653  gwsTarget.BuildFromPrimitivePair( target, m_startDiagonal );
654  m_snapOnTarget = true;
655  }
656  else
657  {
658  VECTOR2I fp;
659 
660  if( !propagateDpHeadForces( aP, fp ) )
661  return false;
662 
663  VECTOR2I midp, dirV;
664  m_prevPair->CursorOrientation( fp, midp, dirV );
665 
666  VECTOR2I fpProj = SEG( midp, midp + dirV ).LineProject( fp );
667  int lead_dist = ( fpProj - fp ).EuclideanNorm();
668 
669  gwsTarget.SetFitVias( m_placingVia, m_sizes.ViaDiameter(), viaGap() );
670 
671  if( lead_dist > m_sizes.DiffPairGap() + m_sizes.DiffPairWidth() )
672  {
673  gwsTarget.BuildForCursor( fp );
674  }
675  else
676  {
677  gwsTarget.BuildForCursor( fpProj );
678  gwsTarget.FilterByOrientation( DIRECTION_45::ANG_STRAIGHT | DIRECTION_45::ANG_HALF_FULL, DIRECTION_45( dirV ) );
679  }
680 
681  m_snapOnTarget = false;
682  }
683 
684  m_currentTrace = DIFF_PAIR();
687 
688  bool result = gwsEntry.FitGateways( gwsEntry, gwsTarget, m_startDiagonal, m_currentTrace );
689 
690  if( result )
691  {
695 
696  if( m_placingVia )
697  {
699  makeVia( m_currentTrace.CN().CPoint( -1 ), m_netN ) );
700  }
701 
702  return true;
703  }
704 
705  return false;
706 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:112
void SetLayer(int aLayer)
Function SetLayer()
Definition: pns_item.h:199
void AppendVias(const VIA &aViaP, const VIA &aViaN)
VECTOR2I LineProject(const VECTOR2I &aP) const
Function LineProject()
Definition: seg.h:337
const SHAPE_LINE_CHAIN & CN() const
const VIA makeVia(const VECTOR2I &aP, int aNet)
bool findDpPrimitivePair(const VECTOR2I &aP, ITEM *aItem, DP_PRIMITIVE_PAIR &aPair, wxString *aErrorMsg=nullptr)
void SetGap(int aGap)
bool propagateDpHeadForces(const VECTOR2I &aP, VECTOR2I &aNewP)
Class DIRECTION_45.
Definition: direction45.h:36
bool m_placingVia
Are we placing a via?
void SetWidth(int aWidth)
Definition: seg.h:36
OPT< DP_PRIMITIVE_PAIR > m_prevPair
int DiffPairWidth() const
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
const SHAPE_LINE_CHAIN & CP() const
void SetNets(int aP, int aN)
void PNS::ALGO_BASE::SetDebugDecorator ( DEBUG_DECORATOR aDecorator)
inlineinherited

Function SetDebugDecorator.

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

Definition at line 65 of file pns_algo_base.h.

References PNS::ALGO_BASE::m_debugDecorator.

66  {
67  m_debugDecorator = aDecorator;
68  }
DEBUG_DECORATOR * m_debugDecorator
Definition: pns_algo_base.h:76
void PNS::DIFF_PAIR_PLACER::setInitialDirection ( const DIRECTION_45 aDirection)
private

Function setInitialDirection()

Sets preferred direction of the very first track segment to be laid. Used by posture switching mechanism.

Referenced by IsPlacingVia().

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

Function SetLayer()

Sets the current routing layer.

Reimplemented from PNS::PLACEMENT_ALGO.

Definition at line 385 of file pns_diff_pair_placer.cpp.

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

386 {
387  if( m_idle )
388  {
389  m_currentLayer = aLayer;
390  return true;
391  } else if( m_chainedPlacement )
392  return false;
393  else if( !m_prevPair )
394  return false;
395  else if( m_prevPair->PrimP() || ( m_prevPair->PrimP()->OfKind( ITEM::VIA_T ) &&
396  m_prevPair->PrimP()->Layers().Overlaps( aLayer ) ) )
397  {
398  m_currentLayer = aLayer;
399  m_start = *m_prevPair;
400  initPlacement();
401  Move( m_currentEnd, NULL );
402  return true;
403  }
404 
405  return false;
406 }
bool Move(const VECTOR2I &aP, ITEM *aEndItem) override
Function Move()
void initPlacement()
Function startPlacement()
OPT< DP_PRIMITIVE_PAIR > m_prevPair
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 90 of file pns_diff_pair_placer.cpp.

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

Referenced by IsPlacingVia().

91 {
92  m_orthoMode = aOrthoMode;
93 
94  if( !m_idle )
95  Move( m_currentEnd, NULL );
96 }
bool Move(const VECTOR2I &aP, ITEM *aEndItem) override
Function Move()
void PNS::DIFF_PAIR_PLACER::setWorld ( NODE aWorld)
private

Function setWorld()

Sets the board to route.

Definition at line 74 of file pns_diff_pair_placer.cpp.

References m_world.

Referenced by initPlacement(), IsPlacingVia(), and Start().

75 {
76  m_world = aWorld;
77 }
NODE * m_world
pointer to world to search colliding items
bool PNS::DIFF_PAIR_PLACER::Start ( const VECTOR2I aP,
ITEM aStartItem 
)
overridevirtual

Function Start()

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

Implements PNS::PLACEMENT_ALGO.

Definition at line 550 of file pns_diff_pair_placer.cpp.

References PNS::SIZES_SETTINGS::DiffPairGap(), PNS::SIZES_SETTINGS::DiffPairViaGap(), PNS::SIZES_SETTINGS::DiffPairWidth(), findDpPrimitivePair(), BOARD::FindNet(), BOARD::GetDesignSettings(), NETINFO_ITEM::GetNetClass(), initPlacement(), m_chainedPlacement, m_currentEnd, m_currentNode, m_currentStart, m_netN, m_netP, m_placingVia, m_sizes, m_start, BOARD_DESIGN_SETTINGS::m_TrackMinWidth, m_world, min, PNS::ITEM::Net(), PNS::DP_PRIMITIVE_PAIR::PrimN(), PNS::DP_PRIMITIVE_PAIR::PrimP(), PNS::ALGO_BASE::Router(), PNS::ROUTER::SetFailureReason(), and setWorld().

551 {
552  VECTOR2I p( aP );
553  wxString msg;
554 
555  if( !aStartItem )
556  {
557  Router()->SetFailureReason( _( "Can't start a differential pair "
558  " in the middle of nowhere." ) );
559  return false;
560  }
561 
562  setWorld( Router()->GetWorld() );
564 
565  if( !findDpPrimitivePair( aP, aStartItem, m_start, &msg ) )
566  {
567  Router()->SetFailureReason( msg );
568  return false;
569  }
570 
571  m_netP = m_start.PrimP()->Net();
572  m_netN = m_start.PrimN()->Net();
573 
574  #if 0
575  // FIXME: this also needs to be factored out but not so important right now
576  // Check if the current track/via gap & track width settings are violated
577  BOARD* brd = NULL; // FIXME Router()->GetBoard();
578  NETCLASSPTR netclassP = brd->FindNet( m_netP )->GetNetClass();
579  NETCLASSPTR netclassN = brd->FindNet( m_netN )->GetNetClass();
580  int clearance = std::min( m_sizes.DiffPairGap(), m_sizes.DiffPairViaGap() );
581 
582  if( clearance < netclassP->GetClearance() || clearance < netclassN->GetClearance() )
583  {
584  Router()->SetFailureReason( _( "Current track/via gap setting violates "
585  "design rules for this net." ) );
586  return false;
587  }
588 
590  {
591  Router()->SetFailureReason( _( "Current track width setting violates design rules." ) );
592  return false;
593  }
594  #endif
595 
596  m_currentStart = p;
597  m_currentEnd = p;
598  m_placingVia = false;
599  m_chainedPlacement = false;
600 
601  initPlacement();
602 
603  return true;
604 }
NODE * m_world
pointer to world to search colliding items
ITEM * PrimP() const
ITEM * PrimN() const
bool findDpPrimitivePair(const VECTOR2I &aP, ITEM *aItem, DP_PRIMITIVE_PAIR &aPair, wxString *aErrorMsg=nullptr)
int m_TrackMinWidth
track min value for width ((min copper size value
void SetFailureReason(const wxString &aReason)
Definition: pns_router.h:213
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:535
bool m_placingVia
Are we placing a via?
int DiffPairViaGap() const
ROUTER * Router() const
Returns the instance of our router
Definition: pns_algo_base.h:49
NODE * m_currentNode
Current world state
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
NETCLASSPTR GetNetClass()
Definition: netinfo.h:122
void initPlacement()
Function startPlacement()
NETINFO_ITEM * FindNet(int aNetcode) const
Function FindNet searches for a net with the given netcode.
int Net() const
Function Net()
Definition: pns_item.h:179
void setWorld(NODE *aWorld)
Function setWorld()
int DiffPairWidth() const
#define min(a, b)
Definition: auxiliary.h:85
bool PNS::DIFF_PAIR_PLACER::ToggleVia ( bool  aEnabled)
overridevirtual

Function ToggleVia()

Enables/disables a via at the end of currently routed trace.

Reimplemented from PNS::PLACEMENT_ALGO.

Definition at line 99 of file pns_diff_pair_placer.cpp.

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

100 {
101  m_placingVia = aEnabled;
102 
103  if( !m_idle )
104  Move( m_currentEnd, NULL );
105 
106  return true;
107 }
bool m_placingVia
Are we placing a via?
bool Move(const VECTOR2I &aP, ITEM *aEndItem) override
Function Move()
const ITEM_SET PNS::DIFF_PAIR_PLACER::Traces ( )
overridevirtual

Function Traces()

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

Implements PNS::PLACEMENT_ALGO.

Definition at line 356 of file pns_diff_pair_placer.cpp.

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

357 {
358  ITEM_SET t;
359 
360  t.Add( const_cast<LINE*>( &m_currentTrace.PLine() ) );
361  t.Add( const_cast<LINE*>( &m_currentTrace.NLine() ) );
362 
363  return t;
364 }
bool PNS::DIFF_PAIR_PLACER::tryWalkDp ( NODE aNode,
DIFF_PAIR aPair,
bool  aSolidsOnly 
)
private

Definition at line 242 of file pns_diff_pair_placer.cpp.

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 IsPlacingVia(), rhShoveOnly(), and rhWalkOnly().

243 {
244  DIFF_PAIR best;
245  double bestScore = 100000000000000.0;
246 
247  for( int attempt = 0; attempt <= 3; attempt++ )
248  {
249  DIFF_PAIR p;
250  NODE *tmp = m_currentNode->Branch();
251 
252  bool pfirst = ( attempt & 1 ) ? true : false;
253  bool wind_cw = ( attempt & 2 ) ? true : false;
254 
255  if( attemptWalk( tmp, &aPair, p, pfirst, wind_cw, aSolidsOnly ) )
256  {
257  // double len = p.TotalLength();
258  double cl = p.CoupledLength();
259  double skew = p.Skew();
260 
261  double score = cl + fabs( skew ) * 3.0;
262 
263  if( score < bestScore )
264  {
265  bestScore = score;
266  best = p;
267  }
268  }
269 
270  delete tmp;
271  }
272 
273  if( bestScore > 0.0 )
274  {
275  OPTIMIZER optimizer( m_currentNode );
276 
277  aPair.SetShape( best );
278  optimizer.Optimize( &aPair );
279 
280  return true;
281  }
282 
283  return false;
284 }
bool attemptWalk(NODE *aNode, DIFF_PAIR *aCurrent, DIFF_PAIR &aWalk, bool aPFirst, bool aWindCw, bool aSolidsOnly)
NODE * Branch()
Function Branch()
Definition: pns_node.cpp:107
NODE * m_currentNode
Current world state
void PNS::DIFF_PAIR_PLACER::updateLeadingRatLine ( )
private

Function updateLeadingRatLine()

Draws 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 819 of file pns_diff_pair_placer.cpp.

References PNS::DEBUG_DECORATOR::AddLine(), PNS::ALGO_BASE::Dbg(), PNS::TOPOLOGY::LeadingRatLine(), m_currentTrace, m_lastNode, PNS::DIFF_PAIR::NLine(), and PNS::DIFF_PAIR::PLine().

Referenced by IsPlacingVia(), and Move().

820 {
821  SHAPE_LINE_CHAIN ratLineN, ratLineP;
822  TOPOLOGY topo( m_lastNode );
823 
824  if( topo.LeadingRatLine( &m_currentTrace.PLine(), ratLineP ) )
825  {
826  Dbg()->AddLine( ratLineP, 1, 10000 );
827  }
828 
829  if( topo.LeadingRatLine ( &m_currentTrace.NLine(), ratLineN ) )
830  {
831  Dbg()->AddLine( ratLineN, 3, 10000 );
832  }
833 }
DEBUG_DECORATOR * Dbg() const
Definition: pns_algo_base.h:70
virtual void AddLine(const SHAPE_LINE_CHAIN &aLine, int aType=0, int aWidth=0)
Class SHAPE_LINE_CHAIN.
NODE * m_lastNode
Postprocessed world state (including marked collisions & removed loops)
void PNS::DIFF_PAIR_PLACER::UpdateSizes ( const SIZES_SETTINGS aSizes)
overridevirtual

Function UpdateSizes()

Performs 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 732 of file pns_diff_pair_placer.cpp.

References initPlacement(), m_currentEnd, m_idle, m_sizes, and Move().

Referenced by CurrentLayer().

733 {
734  m_sizes = aSizes;
735 
736  if( !m_idle )
737  {
738  initPlacement();
739  Move( m_currentEnd, NULL );
740  }
741 }
bool Move(const VECTOR2I &aP, ITEM *aEndItem) override
Function Move()
void initPlacement()
Function startPlacement()
int PNS::DIFF_PAIR_PLACER::viaGap ( ) const
private

Definition at line 538 of file pns_diff_pair_placer.cpp.

References PNS::SIZES_SETTINGS::DiffPairViaGap(), and m_sizes.

Referenced by IsPlacingVia(), propagateDpHeadForces(), and routeHead().

539 {
540  return m_sizes.DiffPairViaGap();
541 }
int DiffPairViaGap() const

Member Data Documentation

bool PNS::DIFF_PAIR_PLACER::m_chainedPlacement
private

Definition at line 242 of file pns_diff_pair_placer.h.

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

VECTOR2I PNS::DIFF_PAIR_PLACER::m_currentEnd
private
ITEM* PNS::DIFF_PAIR_PLACER::m_currentEndItem
private

Definition at line 294 of file pns_diff_pair_placer.h.

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

int PNS::DIFF_PAIR_PLACER::m_currentLayer
private
PNS_MODE PNS::DIFF_PAIR_PLACER::m_currentMode
private
int PNS::DIFF_PAIR_PLACER::m_currentNet
private

Definition at line 284 of file pns_diff_pair_placer.h.

Referenced by DIFF_PAIR_PLACER().

NODE* PNS::DIFF_PAIR_PLACER::m_currentNode
private
VECTOR2I PNS::DIFF_PAIR_PLACER::m_currentStart
private

Definition at line 291 of file pns_diff_pair_placer.h.

Referenced by Start().

DIFF_PAIR PNS::DIFF_PAIR_PLACER::m_currentTrace
private
int PNS::DIFF_PAIR_PLACER::m_currentWidth
private

current track width

Definition at line 282 of file pns_diff_pair_placer.h.

Referenced by DIFF_PAIR_PLACER().

bool PNS::DIFF_PAIR_PLACER::m_fitOk
private
bool PNS::DIFF_PAIR_PLACER::m_idle
private
bool PNS::DIFF_PAIR_PLACER::m_initialDiagonal
private

Definition at line 243 of file pns_diff_pair_placer.h.

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

int PNS::DIFF_PAIR_PLACER::m_iteration
private

current algorithm iteration

Definition at line 253 of file pns_diff_pair_placer.h.

Referenced by DIFF_PAIR_PLACER().

NODE* PNS::DIFF_PAIR_PLACER::m_lastNode
private

Postprocessed world state (including marked collisions & removed loops)

Definition at line 268 of file pns_diff_pair_placer.h.

Referenced by CurrentNode(), DIFF_PAIR_PLACER(), FixRoute(), initPlacement(), Move(), and updateLeadingRatLine().

int PNS::DIFF_PAIR_PLACER::m_netN
private
int PNS::DIFF_PAIR_PLACER::m_netP
private
bool PNS::DIFF_PAIR_PLACER::m_orthoMode
private

Definition at line 288 of file pns_diff_pair_placer.h.

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

VECTOR2I PNS::DIFF_PAIR_PLACER::m_p_start
private

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

Definition at line 259 of file pns_diff_pair_placer.h.

bool PNS::DIFF_PAIR_PLACER::m_placingVia
private

Are we placing a via?

Definition at line 273 of file pns_diff_pair_placer.h.

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

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

Definition at line 250 of file pns_diff_pair_placer.h.

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

SHOVE* PNS::DIFF_PAIR_PLACER::m_shove
private

The shove engine

Definition at line 262 of file pns_diff_pair_placer.h.

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

SIZES_SETTINGS PNS::DIFF_PAIR_PLACER::m_sizes
private
bool PNS::DIFF_PAIR_PLACER::m_snapOnTarget
private

Definition at line 289 of file pns_diff_pair_placer.h.

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

DP_PRIMITIVE_PAIR PNS::DIFF_PAIR_PLACER::m_start
private

Definition at line 249 of file pns_diff_pair_placer.h.

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

bool PNS::DIFF_PAIR_PLACER::m_startDiagonal
private

Definition at line 244 of file pns_diff_pair_placer.h.

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

bool PNS::DIFF_PAIR_PLACER::m_startsOnVia
private

Definition at line 287 of file pns_diff_pair_placer.h.

Referenced by DIFF_PAIR_PLACER().

State PNS::DIFF_PAIR_PLACER::m_state
private

Definition at line 240 of file pns_diff_pair_placer.h.

Referenced by DIFF_PAIR_PLACER().

int PNS::DIFF_PAIR_PLACER::m_viaDiameter
private

current via diameter

Definition at line 276 of file pns_diff_pair_placer.h.

Referenced by DIFF_PAIR_PLACER().

int PNS::DIFF_PAIR_PLACER::m_viaDrill
private

current via drill

Definition at line 279 of file pns_diff_pair_placer.h.

Referenced by DIFF_PAIR_PLACER().

NODE* PNS::DIFF_PAIR_PLACER::m_world
private

pointer to world to search colliding items

Definition at line 256 of file pns_diff_pair_placer.h.

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


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