KiCad PCB EDA Suite
pns_diff_pair_placer.cpp
Go to the documentation of this file.
1 /*
2  * KiRouter - a push-and-(sometimes-)shove PCB router
3  *
4  * Copyright (C) 2013-2015 CERN
5  * Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
6  * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
7  *
8  * This program is free software: you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License as published by the
10  * Free Software Foundation, either version 3 of the License, or (at your
11  * option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #include <board.h>
23 #include <board_item.h>
24 #include <netinfo.h>
25 
26 #include "pns_node.h"
27 #include "pns_walkaround.h"
28 #include "pns_shove.h"
29 #include "pns_utils.h"
30 #include "pns_router.h"
31 #include "pns_diff_pair_placer.h"
32 #include "pns_solid.h"
33 #include "pns_topology.h"
34 #include "pns_debug_decorator.h"
35 
36 namespace PNS {
37 
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;
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;
64  m_idle = true;
65 }
66 
68 {
69  if( m_shove )
70  delete m_shove;
71 }
72 
73 
75 {
76  m_world = aWorld;
77 }
78 
79 const VIA DIFF_PAIR_PLACER::makeVia( const VECTOR2I& aP, int aNet )
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 }
88 
89 
90 void DIFF_PAIR_PLACER::SetOrthoMode ( bool aOrthoMode )
91 {
92  m_orthoMode = aOrthoMode;
93 
94  if( !m_idle )
96 }
97 
98 
99 bool DIFF_PAIR_PLACER::ToggleVia( bool aEnabled )
100 {
101  m_placingVia = aEnabled;
102 
103  if( !m_idle )
104  Move( m_currentEnd, NULL );
105 
106  return true;
107 }
108 
109 
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 }
122 
123 
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.DiffPairWidth() );
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 }
159 
160 
162  DIFF_PAIR& aWalk, bool aPFirst, bool aWindCw, bool aSolidsOnly )
163 {
164  WALKAROUND walkaround( aNode, Router() );
166 
167  walkaround.SetSolidsOnly( aSolidsOnly );
168  walkaround.SetIterationLimit( Settings().WalkaroundIterationLimit() );
169 
170  SHOVE shove( aNode, Router() );
171  LINE walkP, walkN;
172 
173  aWalk = *aCurrent;
174 
175  int iter = 0;
176 
177  DIFF_PAIR cur( *aCurrent );
178 
179  bool currentIsP = aPFirst;
180 
181  int mask = aSolidsOnly ? ITEM::SOLID_T : ITEM::ANY_T;
182 
183  do
184  {
185  LINE preWalk = ( currentIsP ? cur.PLine() : cur.NLine() );
186  LINE preShove = ( currentIsP ? cur.NLine() : cur.PLine() );
187  LINE postWalk;
188 
189  if( !aNode->CheckColliding ( &preWalk, mask ) )
190  {
191  currentIsP = !currentIsP;
192 
193  if( !aNode->CheckColliding( &preShove, mask ) )
194  break;
195  else
196  continue;
197  }
198 
199  wf1 = walkaround.Route( preWalk, postWalk, false );
200 
201  if( wf1 != WALKAROUND::DONE )
202  return false;
203 
204  LINE postShove( preShove );
205 
206  shove.ForceClearance( true, cur.Gap() - 2 * PNS_HULL_MARGIN );
207 
209 
210  sh1 = shove.ShoveObstacleLine( postWalk, preShove, postShove );
211 
212  if( sh1 != SHOVE::SH_OK )
213  return false;
214 
215  postWalk.Line().Simplify();
216  postShove.Line().Simplify();
217 
218  cur.SetShape( postWalk.CLine(), postShove.CLine(), !currentIsP );
219 
220  currentIsP = !currentIsP;
221 
222  if( !aNode->CheckColliding( &postShove, mask ) )
223  break;
224 
225  iter++;
226  }
227  while( iter < 3 );
228 
229  if( iter == 3 )
230  return false;
231 
232  aWalk.SetShape( cur.CP(), cur.CN() );
233 
234  return true;
235 }
236 
237 
238 bool DIFF_PAIR_PLACER::tryWalkDp( NODE* aNode, DIFF_PAIR &aPair, bool aSolidsOnly )
239 {
240  DIFF_PAIR best;
241  double bestScore = 100000000000000.0;
242 
243  for( int attempt = 0; attempt <= 3; attempt++ )
244  {
245  DIFF_PAIR p;
246  NODE *tmp = m_currentNode->Branch();
247 
248  bool pfirst = ( attempt & 1 ) ? true : false;
249  bool wind_cw = ( attempt & 2 ) ? true : false;
250 
251  if( attemptWalk( tmp, &aPair, p, pfirst, wind_cw, aSolidsOnly ) )
252  {
253  // double len = p.TotalLength();
254  double cl = p.CoupledLength();
255  double skew = p.Skew();
256 
257  double score = cl + fabs( skew ) * 3.0;
258 
259  if( score < bestScore )
260  {
261  bestScore = score;
262  best = p;
263  }
264  }
265 
266  delete tmp;
267  }
268 
269  if( bestScore > 0.0 )
270  {
271  OPTIMIZER optimizer( m_currentNode );
272 
273  aPair.SetShape( best );
274  optimizer.Optimize( &aPair );
275 
276  return true;
277  }
278 
279  return false;
280 }
281 
282 
284 {
285  if( !routeHead ( aP ) )
286  return false;
287 
289 
290  return m_fitOk;
291 }
292 
293 
295 {
296  switch( m_currentMode )
297  {
298  case RM_MarkObstacles:
299  return rhMarkObstacles( aP );
300  case RM_Walkaround:
301  return rhWalkOnly( aP );
302  case RM_Shove:
303  return rhShoveOnly( aP );
304  default:
305  break;
306  }
307 
308  return false;
309 }
310 
311 
313 {
315 
316  bool ok = routeHead( aP );
317 
318  m_fitOk = false;
319 
320  if( !ok )
321  return false;
322 
323  if( !tryWalkDp( m_currentNode, m_currentTrace, true ) )
324  return false;
325 
326  LINE pLine( m_currentTrace.PLine() );
327  LINE nLine( m_currentTrace.NLine() );
328  ITEM_SET head;
329 
330  head.Add( &pLine );
331  head.Add( &nLine );
332 
333  SHOVE::SHOVE_STATUS status = m_shove->ShoveMultiLines( head );
334 
336 
337  if( status == SHOVE::SH_OK )
338  {
340 
343  {
344  m_fitOk = true;
345  }
346  }
347 
348  return m_fitOk;
349 }
350 
351 
353 {
354  ITEM_SET t;
355 
356  t.Add( &m_currentTrace.PLine() );
357  t.Add( &m_currentTrace.NLine() );
358 
359  return t;
360 }
361 
362 
364 {
366 
367  if( !m_idle )
368  Move( m_currentEnd, NULL );
369 }
370 
371 
372 NODE* DIFF_PAIR_PLACER::CurrentNode( bool aLoopsRemoved ) const
373 {
374  if( m_lastNode )
375  return m_lastNode;
376 
377  return m_currentNode;
378 }
379 
380 
381 bool DIFF_PAIR_PLACER::SetLayer( int aLayer )
382 {
383  if( m_idle )
384  {
385  m_currentLayer = aLayer;
386  return true;
387  }
388  else if( m_chainedPlacement || !m_prevPair )
389  {
390  return false;
391  }
392  else if( !m_prevPair->PrimP() || ( m_prevPair->PrimP()->OfKind( ITEM::VIA_T ) &&
393  m_prevPair->PrimP()->Layers().Overlaps( aLayer ) ) )
394  {
395  m_currentLayer = aLayer;
396  m_start = *m_prevPair;
397  initPlacement();
398  Move( m_currentEnd, NULL );
399  return true;
400  }
401 
402  return false;
403 }
404 
405 
407 {
408  switch( aItem->Kind() )
409  {
410  case ITEM::VIA_T:
411  case ITEM::SOLID_T:
412  return aItem->Anchor( 0 );
413 
414  case ITEM::ARC_T:
415  case ITEM::SEGMENT_T:
416  {
417  SEGMENT* s = static_cast<SEGMENT*>( aItem );
418 
419  JOINT* jA = aNode->FindJoint( aItem->Anchor( 0 ), aItem );
420  JOINT* jB = aNode->FindJoint( aItem->Anchor( 1 ), aItem );
421 
422  if( jA && jA->LinkCount() == 1 )
423  return s->Seg().A;
424  else if( jB && jB->LinkCount() == 1 )
425  return s->Seg().B;
426  else
427  return OPT_VECTOR2I();
428  }
429 
430  default:
431  return OPT_VECTOR2I();
432  }
433 }
434 
435 
436 
437 bool DIFF_PAIR_PLACER::FindDpPrimitivePair( NODE* aWorld, const VECTOR2I& aP, ITEM* aItem,
438  DP_PRIMITIVE_PAIR& aPair, wxString* aErrorMsg )
439 {
440  int netP, netN;
441 
442  wxLogTrace( "PNS", "world %p", aWorld );
443 
444  bool result = aWorld->GetRuleResolver()->DpNetPair( aItem, netP, netN );
445 
446  if( !result )
447  {
448  if( aErrorMsg )
449  {
450  *aErrorMsg = _( "Unable to find complementary differential pair "
451  "nets. Make sure the names of the nets belonging "
452  "to a differential pair end with either _N/_P or +/-." );
453  }
454  return false;
455  }
456 
457  int refNet = aItem->Net();
458  int coupledNet = ( refNet == netP ) ? netN : netP;
459 
460  wxLogTrace( "PNS", "result %d", !!result );
461 
462  OPT_VECTOR2I refAnchor = getDanglingAnchor( aWorld, aItem );
463  ITEM* primRef = aItem;
464 
465  wxLogTrace( "PNS", "refAnchor %p", aItem );
466 
467  if( !refAnchor )
468  {
469  if( aErrorMsg )
470  {
471  *aErrorMsg = _( "Can't find a suitable starting point. If starting "
472  "from an existing differential pair make sure you are "
473  "at the end." );
474  }
475  return false;
476  }
477 
478  std::set<ITEM*> coupledItems;
479 
480  aWorld->AllItemsInNet( coupledNet, coupledItems );
481  double bestDist = std::numeric_limits<double>::max();
482  bool found = false;
483 
484  for( ITEM* item : coupledItems )
485  {
486  if( item->Kind() == aItem->Kind() )
487  {
488  OPT_VECTOR2I anchor = getDanglingAnchor( aWorld, item );
489  if( !anchor )
490  continue;
491 
492  double dist = ( *anchor - *refAnchor ).EuclideanNorm();
493 
494  bool shapeMatches = true;
495 
496  if( item->OfKind( ITEM::SOLID_T ) && item->Layers() != aItem->Layers() )
497  {
498  shapeMatches = false;
499  }
500 
501  if( dist < bestDist && shapeMatches )
502  {
503  found = true;
504  bestDist = dist;
505 
506  if( refNet != netP )
507  {
508  aPair = DP_PRIMITIVE_PAIR ( item, primRef );
509  aPair.SetAnchors( *anchor, *refAnchor );
510  }
511  else
512  {
513  aPair = DP_PRIMITIVE_PAIR( primRef, item );
514  aPair.SetAnchors( *refAnchor, *anchor );
515  }
516  }
517  }
518  }
519 
520  if( !found )
521  {
522  if( aErrorMsg )
523  {
524  *aErrorMsg = wxString::Format( _( "Can't find a suitable starting point "
525  "for coupled net \"%s\"." ),
526  aWorld->GetRuleResolver()->NetName( coupledNet ) );
527  }
528  return false;
529  }
530 
531  return true;
532 }
533 
534 
536 {
537  return std::max( m_sizes.DiffPairViaGap(),
539 }
540 
541 
543 {
545 }
546 
547 
548 bool DIFF_PAIR_PLACER::Start( const VECTOR2I& aP, ITEM* aStartItem )
549 {
550  VECTOR2I p( aP );
551 
552  setWorld( Router()->GetWorld() );
554 
555  if( !FindDpPrimitivePair( m_currentNode, aP, aStartItem, m_start ) )
556  return false;
557 
558  m_netP = m_start.PrimP()->Net();
559  m_netN = m_start.PrimN()->Net();
560 
561  m_currentStart = p;
562  m_currentEnd = p;
563  m_placingVia = false;
564  m_chainedPlacement = false;
565 
566  initPlacement();
567 
568  return true;
569 }
570 
571 
573 {
574  m_idle = false;
575  m_orthoMode = false;
578 
579  NODE* world = Router()->GetWorld();
580 
581  world->KillChildren();
582  NODE* rootNode = world->Branch();
583 
584  setWorld( rootNode );
585 
586  m_lastNode = NULL;
587  m_currentNode = rootNode;
589 
590  if( m_shove )
591  delete m_shove;
592 
593  m_shove = NULL;
594 
596  {
597  m_shove = new SHOVE( m_currentNode, Router() );
598  }
599 }
600 
601 
603 {
604  m_fitOk = false;
605 
606  DP_GATEWAYS gwsEntry( gap() );
607  DP_GATEWAYS gwsTarget( gap() );
608 
609  if( !m_prevPair )
611 
613 
614  DP_PRIMITIVE_PAIR target;
615 
617  {
618  gwsTarget.BuildFromPrimitivePair( target, m_startDiagonal );
619  m_snapOnTarget = true;
620  }
621  else
622  {
623  VECTOR2I fp;
624 
625  if( !propagateDpHeadForces( aP, fp ) )
626  return false;
627 
628  VECTOR2I midp, dirV;
629  m_prevPair->CursorOrientation( fp, midp, dirV );
630 
631  VECTOR2I fpProj = SEG( midp, midp + dirV ).LineProject( fp );
632 
633  // compute 'leader point' distance from the cursor (project cursor position
634  // on the extension of the starting segment pair of the DP)
635  int lead_dist = ( fpProj - fp ).EuclideanNorm();
636 
637  gwsTarget.SetFitVias( m_placingVia, m_sizes.ViaDiameter(), viaGap() );
638 
639  // far from the initial segment extension line -> allow a 45-degree obtuse turn
640  if( lead_dist > m_sizes.DiffPairGap() + m_sizes.DiffPairWidth() )
641  {
642  gwsTarget.BuildForCursor( fp );
643  }
644  // close to the initial segment extension line -> keep straight part only, project as close
645  // as possible to the cursor
646  else
647  {
648  gwsTarget.BuildForCursor( fpProj );
650  }
651 
652  m_snapOnTarget = false;
653  }
654 
658 
659  bool result = gwsEntry.FitGateways( gwsEntry, gwsTarget, m_startDiagonal, m_currentTrace );
660 
661  if( result )
662  {
666 
667  if( m_placingVia )
668  {
670  makeVia( m_currentTrace.CN().CPoint( -1 ), m_netN ) );
671  }
672 
673  return true;
674  }
675 
676  return false;
677 }
678 
679 
680 bool DIFF_PAIR_PLACER::Move( const VECTOR2I& aP , ITEM* aEndItem )
681 {
682  m_currentEndItem = aEndItem;
683  m_fitOk = false;
684 
685  delete m_lastNode;
686  m_lastNode = NULL;
687 
688  bool retval = route( aP );
689 
690  NODE* latestNode = m_currentNode;
691  m_lastNode = latestNode->Branch();
692 
693  assert( m_lastNode != NULL );
694  m_currentEnd = aP;
695 
697 
698  return retval;
699 }
700 
701 
703 {
704  m_sizes = aSizes;
705 
706  if( !m_idle )
707  {
710 
712  {
715  }
716  }
717 }
718 
719 
720 bool DIFF_PAIR_PLACER::FixRoute( const VECTOR2I& aP, ITEM* aEndItem, bool aForceFinish )
721 {
722  if( !m_fitOk && !Settings().CanViolateDRC() )
723  return false;
724 
725  if( m_currentTrace.CP().SegmentCount() < 1 ||
726  m_currentTrace.CN().SegmentCount() < 1 )
727  return false;
728 
729  if( m_currentTrace.CP().SegmentCount() > 1 )
730  m_initialDiagonal = !DIRECTION_45( m_currentTrace.CP().CSegment( -2 ) ).IsDiagonal();
731 
732  TOPOLOGY topo( m_lastNode );
733 
734  if( !m_snapOnTarget && !m_currentTrace.EndsWithVias() && !aForceFinish )
735  {
738 
739  if( newP.SegmentCount() > 1 && newN.SegmentCount() > 1 )
740  {
741  newP.Remove( -1, -1 );
742  newN.Remove( -1, -1 );
743  }
744 
745  m_currentTrace.SetShape( newP, newN );
746  }
747 
749  {
752  m_chainedPlacement = false;
753  }
754  else
755  {
756  m_chainedPlacement = !m_snapOnTarget && !aForceFinish;
757  }
758 
759  LINE lineP( m_currentTrace.PLine() );
760  LINE lineN( m_currentTrace.NLine() );
761 
762  m_lastNode->Add( lineP );
763  m_lastNode->Add( lineN );
764 
765  topo.SimplifyLine( &lineP );
766  topo.SimplifyLine( &lineN );
767 
769 
770  CommitPlacement();
771  m_placingVia = false;
772 
773  if( m_snapOnTarget || aForceFinish )
774  {
775  m_idle = true;
776  return true;
777  }
778  else
779  {
780  initPlacement();
781  return false;
782  }
783 }
784 
785 
787 {
789  return true;
790 }
791 
792 
794 {
795  return m_currentTrace.CP().SegmentCount() > 0 ||
797 }
798 
799 
801 {
802  if( m_lastNode )
804 
805  m_lastNode = NULL;
807  return true;
808 }
809 
810 
811 void DIFF_PAIR_PLACER::GetModifiedNets( std::vector<int> &aNets ) const
812 {
813  aNets.push_back( m_netP );
814  aNets.push_back( m_netN );
815 }
816 
817 
819 {
820  SHAPE_LINE_CHAIN ratLineN, ratLineP;
821  TOPOLOGY topo( m_lastNode );
822 
823  if( topo.LeadingRatLine( &m_currentTrace.PLine(), ratLineP ) )
824  m_router->GetInterface()->DisplayRatline( ratLineP, 1 );
825 
826  if( topo.LeadingRatLine ( &m_currentTrace.NLine(), ratLineN ) )
827  m_router->GetInterface()->DisplayRatline( ratLineN, 3 );
828 }
829 
830 
831 const std::vector<int> DIFF_PAIR_PLACER::CurrentNets() const
832 {
833  std::vector<int> rv;
834  rv.push_back( m_netP );
835  rv.push_back( m_netN );
836  return rv;
837 }
838 
839 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:148
const SHAPE_LINE_CHAIN & CLine() const
Definition: pns_line.h:137
bool rhWalkOnly(const VECTOR2I &aP)
route step, shove mode
Base class for PNS router board items.
Definition: pns_item.h:55
SIZES_SETTINGS m_sizes
Are we placing a via?
ROUTER * Router() const
Return current router settings.
Definition: pns_algo_base.h:54
bool FitGateways(DP_GATEWAYS &aEntry, DP_GATEWAYS &aTarget, bool aPrefDiagonal, DIFF_PAIR &aDp)
void BuildForCursor(const VECTOR2I &aCursorPos)
bool attemptWalk(NODE *aNode, DIFF_PAIR *aCurrent, DIFF_PAIR &aWalk, bool aPFirst, bool aWindCw, bool aSolidsOnly)
Keep the router "world" - i.e.
Definition: pns_node.h:149
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 a...
void SetShape(const SHAPE_LINE_CHAIN &aP, const SHAPE_LINE_CHAIN &aN, bool aSwapLanes=false)
SHOVE.
Definition: pns_shove.h:48
int Gap() const
SHAPE_LINE_CHAIN & Simplify(bool aRemoveColinear=true)
Function Simplify()
void GetModifiedNets(std::vector< int > &aNets) const override
Function GetModifiedNets.
void SetLayer(int aLayer)
Definition: pns_item.h:153
bool route(const VECTOR2I &aP)
Re-route the current track to point aP.
void AppendVias(const VIA &aViaP, const VIA &aViaN)
bool EndsWithVias() const
bool rhShoveOnly(const VECTOR2I &aP)
route step, mark obstacles mode
void CommitRouting()
Definition: pns_router.cpp:647
const SHAPE_LINE_CHAIN & CN() const
int m_iteration
pointer to world to search colliding items
void FilterByOrientation(int aAngleMask, DIRECTION_45 aRefOrientation)
bool PushoutForce(NODE *aNode, const VECTOR2I &aDirection, VECTOR2I &aForce, bool aSolidsOnly=true, int aMaxIterations=10)
Definition: pns_via.cpp:32
SHOVE * m_shove
Current world state.
#define PNS_HULL_MARGIN
Definition: pns_line.h:44
int m_viaDiameter
current via drill
WALKAROUND_STATUS Route(const LINE &aInitialPath, LINE &aWalkPath, bool aOptimize=true)
NODE * CurrentNode(bool aLoopsRemoved=false) const override
Return the most recent world state.
double CoupledLength() const
virtual void DisplayRatline(const SHAPE_LINE_CHAIN &aRatline, int aColor=-1)=0
NODE * m_world
current routing start point (end of tail, beginning of head)
const SEG & Seg() const
Definition: pns_segment.h:84
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
Definition: pns_line.h:60
SHOVE_STATUS ShoveObstacleLine(const LINE &aCurLine, const LINE &aObstacleLine, LINE &aResultLine)
Definition: pns_shove.cpp:312
const VIA makeVia(const VECTOR2I &aP, int aNet)
void Add(const LINE &aLine)
Definition: pns_itemset.cpp:32
bool routeHead(const VECTOR2I &aP)
NODE * Branch()
Create a lightweight copy (called branch) of self that tracks the changes (added/removed items) wrs t...
Definition: pns_node.cpp:124
ITEM * PrimP() const
void SetNet(int aNet)
Definition: pns_item.h:147
VIATYPE ViaType() const
int m_viaDrill
current track width
void SetDiameter(int aDiameter)
Definition: pns_via.h:109
ROUTING_SETTINGS & Settings() const
Return the logger object, allowing to dump geometry to a file.
const VECTOR2I & CPoint(int aIndex) const
Function Point()
bool HasPlacedAnything() const override
Represents a 2D point on a given set of layers and belonging to a certain net, that links together a ...
Definition: pns_joint.h:42
void BuildFromPrimitivePair(const DP_PRIMITIVE_PAIR &aPair, bool aPreferDiagonal)
void SetGap(int aGap)
bool propagateDpHeadForces(const VECTOR2I &aP, VECTOR2I &aNewP)
int Diameter() const
Definition: pns_via.h:107
VECTOR2I LineProject(const VECTOR2I &aP) const
Compute the perpendicular projection point of aP on a line passing through ends of the segment.
Definition: seg.h:389
ROUTER * m_router
Definition: pns_algo_base.h:87
void KillChildren()
Definition: pns_node.cpp:1292
#define NULL
void SetFitVias(bool aEnable, int aDiameter=0, int aViaGap=-1)
bool LeadingRatLine(const LINE *aTrack, SHAPE_LINE_CHAIN &aRatLine)
OPT< VECTOR2I > OPT_VECTOR2I
Definition: seg.h:39
bool ToggleVia(bool aEnabled) override
Enable/disable a via at the end of currently routed trace.
int Net() const
Definition: pns_item.h:148
Represent route directions & corner angles in a 45-degree metric.
Definition: direction45.h:36
void UpdateSizes(const SIZES_SETTINGS &aSizes) override
Perform on-the-fly update of the width, via diameter & drill size from a settings class.
OPT_VECTOR2I getDanglingAnchor(NODE *aNode, ITEM *aItem)
static bool Optimize(LINE *aLine, int aEffortLevel, NODE *aWorld, const VECTOR2I aV=VECTOR2I(0, 0))
bool Start(const VECTOR2I &aP, ITEM *aStartItem) override
Start routing a single track at point aP, taking item aStartItem as anchor (unless NULL).
const ITEM_SET Traces() override
Return the complete routed line, as a single-member ITEM_SET.
PNS_MODE Mode() const
Set the routing mode.
bool m_placingVia
current via diameter
DIFF_PAIR_PLACER(ROUTER *aRouter)
void SetViaDiameter(int aDiameter)
void SetSolidsOnly(bool aSolidsOnly)
void SetWidth(int aWidth)
void Remove(int aStartIndex, int aEndIndex)
Function Remove()
double Skew() const
int SegmentCount() const
Function SegmentCount()
JOINT * FindJoint(const VECTOR2I &aPos, int aLayer, int aNet)
Search for a joint at a given position, layer and belonging to given net.
Definition: pns_node.cpp:1027
SHAPE_LINE_CHAIN & Line()
Definition: pns_line.h:136
bool SimplifyLine(LINE *aLine)
RULE_RESOLVER * GetRuleResolver() const
Return the number of joints.
Definition: pns_node.h:182
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
virtual VECTOR2I Anchor(int n) const
Definition: pns_item.h:213
Definition: seg.h:41
DIFF_PAIR.
void FlipPosture() override
Toggle the current posture (straight/diagonal) of the trace head.
Guess what's better, try to make least mess on the PCB.
const SHAPE_LINE_CHAIN & CP() const
NODE * m_currentNode
Postprocessed world state (including marked collisions & removed loops)
void updateLeadingRatLine()
Draw the "leading" ratsnest line, which connects the end of currently routed track and the nearest ye...
Ignore collisions, mark obstacles.
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).
void ForceClearance(bool aEnabled, int aClearance)
Definition: pns_shove.h:75
ITEM * PrimN() const
DP_PRIMITIVE_PAIR.
const SEG CSegment(int aIndex) const
Function CSegment()
std::unique_ptr< typename std::remove_const< T >::type > Clone(const T &aItem)
Definition: pns_item.h:257
#define _(s)
Definition: 3d_actions.cpp:33
SHAPE_LINE_CHAIN.
void AllItemsInNet(int aNet, std::set< ITEM * > &aItems, int aKindMask=-1)
Definition: pns_node.cpp:1298
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:427
VECTOR2I A
Definition: seg.h:49
void initPlacement()
Initialize placement of a new line with given parameters.
static bool FindDpPrimitivePair(NODE *aWorld, const VECTOR2I &aP, ITEM *aItem, DP_PRIMITIVE_PAIR &aPair, wxString *aErrorMsg=nullptr)
Only walk around.
bool SetLayer(int aLayer) override
Set the current routing layer.
PnsKind Kind() const
Return the type (kind) of the item.
Definition: pns_item.h:126
Perform various optimizations of the lines being routed, attempting to make the lines shorter and les...
Definition: pns_optimizer.h:94
const std::vector< int > CurrentNets() const override
Return the net code of currently routed track.
virtual wxString NetName(int aNet)=0
OPT< DP_PRIMITIVE_PAIR > m_prevPair
current algorithm iteration
bool tryWalkDp(NODE *aNode, DIFF_PAIR &aPair, bool aSolidsOnly)
route step, walk around mode
void SetOrthoMode(bool aOrthoMode) override
Function SetOrthoMode()
int LinkCount(int aMask=-1) const
Definition: pns_joint.h:210
void setWorld(NODE *aWorld)
Set the board to route.
virtual bool DpNetPair(const ITEM *aItem, int &aNetP, int &aNetN)=0
SHOVE_STATUS ShoveMultiLines(const ITEM_SET &aHeadSet)
Definition: pns_shove.cpp:1413
const VIA & Via() const
Definition: pns_line.h:196
DP_GATEWAYS.
void SetViaDrill(int aDrill)
Push and Shove diff pair dimensions (gap) settings dialog.
NODE * GetWorld() const
Definition: pns_router.h:158
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
Definition: pns_node.cpp:615
ROUTER_IFACE * GetInterface() const
Definition: pns_router.h:215
NODE * CurrentNode()
Definition: pns_shove.cpp:1664
void SetIterationLimit(const int aIterLimit)
Represent a contiguous set of PCB layers.
Definition: pns_layerset.h:31
const LAYER_RANGE & Layers() const
Definition: pns_item.h:150
DP_PRIMITIVE_PAIR EndingPrimitives()
void SetAnchors(const VECTOR2I &aAnchorP, const VECTOR2I &aAnchorN)
void SetNets(int aP, int aN)
bool rhMarkObstacles(const VECTOR2I &aP)
VECTOR2I B
Definition: seg.h:50