KiCad PCB EDA Suite
pns_dragger.cpp
Go to the documentation of this file.
1/*
2 * KiRouter - a push-and-(sometimes-)shove PCB router
3 *
4 * Copyright (C) 2013-2014 CERN
5 * Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
6 * Author: Tomasz Wlostowski <[email protected]>
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 "pns_arc.h"
23
24#include "pns_dragger.h"
25#include "pns_shove.h"
26#include "pns_router.h"
27#include "pns_debug_decorator.h"
28#include "pns_walkaround.h"
29
30namespace PNS {
31
33 DRAG_ALGO( aRouter ),
34 m_initialVia( {} ),
35 m_draggedVia( {} )
36{
37 m_world = nullptr;
38 m_lastNode = nullptr;
39 m_mode = DM_SEGMENT;
40 m_draggedSegmentIndex = 0;
41 m_dragStatus = false;
42 m_currentMode = RM_MarkObstacles;
43 m_freeAngleMode = false;
44}
45
46
48{
49}
50
51
52bool DRAGGER::propagateViaForces( NODE* node, std::set<VIA*>& vias )
53{
54 VIA* via = *vias.begin();
55
56 VECTOR2I force;
58
59 const int iterLimit = Settings().ViaForcePropIterationLimit();
60
61 if( via->PushoutForce( node, lead, force, ITEM::ANY_T, iterLimit ) )
62 {
63 via->SetPos( via->Pos() + force );
64 return true;
65 }
66
67 return false;
68}
69
70
72{
73 int w2 = aSeg->Width() / 2;
74
75 auto distA = ( aP - aSeg->Seg().A ).EuclideanNorm();
76 auto distB = ( aP - aSeg->Seg().B ).EuclideanNorm();
77
78 VECTOR2I psnap;
79
80 if( distA <= w2 )
81 {
82 psnap = aSeg->Seg().A;
83 }
84 else if( distB <= w2 )
85 {
86 psnap = aSeg->Seg().B;
87 }
88 else
89 {
90 return nullptr;
91 }
92
93 JOINT *jt = m_world->FindJoint( psnap, aSeg );
94
95 if ( !jt )
96 {
97 return nullptr;
98 }
99
100 for( auto& lnk : jt->LinkList() )
101 {
102 if( lnk.item->IsVirtual() && lnk.item->OfKind( ITEM::VIA_T ))
103 {
104 return static_cast<VVIA*>( lnk.item );
105 }
106 }
107
108 return nullptr;
109}
110
111
113{
114 int w2 = aSeg->Width() / 2;
115
118
119 if( m_shove )
120 {
121 m_shove->SetInitialLine( m_draggedLine );
122 }
123
124 auto distA = ( aP - aSeg->Seg().A ).EuclideanNorm();
125 auto distB = ( aP - aSeg->Seg().B ).EuclideanNorm();
126
127 if( distA < w2 || distB < w2 )
128 {
130
131 if( distB <= distA )
133 }
134 else if( m_freeAngleMode )
135 {
136 if( distB < distA &&
138 ( !m_draggedLine.CLine().IsPtOnArc( static_cast<size_t>(m_draggedSegmentIndex) + 1 ) ) )
139 {
141 }
142
144 }
145 else
146 {
148 }
149
150 return true;
151}
152
153
154bool DRAGGER::startDragArc( const VECTOR2D& aP, ARC* aArc )
155{
157 m_shove->SetInitialLine( m_draggedLine );
158 m_mode = DM_ARC;
159
160 return true;
161}
162
163
165{
166 m_initialVia = aVia->MakeHandle();
168
169 m_mode = DM_VIA;
170
171 return true;
172}
173
175{
176 ITEM_SET rv;
177
178 JOINT* jt = aNode->FindJoint( handle.pos, handle.layers.Start(), handle.net );
179
180 if( !jt )
181 return rv;
182
183 for( ITEM* item : jt->LinkList() )
184 {
185 if( item->OfKind( ITEM::SEGMENT_T | ITEM::ARC_T ) )
186 {
187 int segIndex;
188 LINKED_ITEM* seg = ( LINKED_ITEM*) item;
189 LINE l = aNode->AssembleLine( seg, &segIndex );
190
191 if( segIndex != 0 )
192 l.Reverse();
193
194 rv.Add( l );
195 }
196 else if( item->OfKind( ITEM::VIA_T ) )
197 {
198 rv.Add( item );
199 }
200 }
201
202 return rv;
203}
204
205bool DRAGGER::Start( const VECTOR2I& aP, ITEM_SET& aPrimitives )
206{
207 if( aPrimitives.Empty() )
208 return false;
209
210 ITEM* startItem = aPrimitives[0];
211
212 m_lastNode = nullptr;
216 m_lastValidPoint = aP;
217
220
222 {
223 m_shove = std::make_unique<SHOVE>( m_world, Router() );
224 m_shove->SetLogger( Logger() );
225 m_shove->SetDebugDecorator( Dbg() );
226 }
227
228 startItem->Unmark( MK_LOCKED );
229
230 PNS_DBG( Dbg(), Message, wxString::Format( "StartDragging: item %p [kind %d]",
231 startItem, (int) startItem->Kind() ) );
232
233 switch( startItem->Kind() )
234 {
235 case ITEM::SEGMENT_T:
236 {
237 SEGMENT* seg = static_cast<SEGMENT*>( startItem );
238 VVIA* vvia = checkVirtualVia( aP, seg );
239
240 if( vvia )
241 {
242 return startDragVia( vvia );
243 }
244 else
245 {
246 return startDragSegment( aP, seg );
247 }
248 }
249 case ITEM::VIA_T:
250 return startDragVia( static_cast<VIA*>( startItem ) );
251
252 case ITEM::ARC_T:
253 return startDragArc( aP, static_cast<ARC*>( startItem ) );
254
255 default:
256 return false;
257 }
258}
259
260
262{
263 m_mode = static_cast<int>( aMode );
264}
265
266
268{
269 return static_cast<PNS::DRAG_MODE>( m_mode );
270}
271
272
273const std::vector<int> DRAGGER::CurrentNets() const
274{
275 if( m_mode == PNS::DM_VIA )
276 return std::vector<int>( 1, m_draggedVia.net );
277 else
278 return std::vector<int>( 1, m_draggedLine.Net() );
279}
280
281
283{
284 // fixme: rewrite using shared_ptr...
285 if( m_lastNode )
286 {
287 delete m_lastNode;
288 m_lastNode = nullptr;
289 }
290
292
293 switch( m_mode )
294 {
295 case DM_SEGMENT:
296 case DM_CORNER:
297 {
298 //TODO: Make threshold configurable
299 int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine.Width() / 4 : 0;
300 LINE origLine( m_draggedLine );
301 LINE dragged( m_draggedLine );
302 dragged.SetSnapThreshhold( thresh );
303 dragged.ClearLinks();
304
305 if( m_mode == DM_SEGMENT )
306 dragged.DragSegment( aP, m_draggedSegmentIndex );
307 else
309
310 m_lastNode->Remove( origLine );
311 m_lastNode->Add( dragged );
312
314 m_draggedItems.Add( dragged );
315
316 break;
317 }
318
319 case DM_VIA: // fixme...
320 {
322
323 break;
324 }
325 }
326
327 if( Settings().AllowDRCViolations() )
328 m_dragStatus = true;
329 else
331
332 return true;
333}
334
335
336bool DRAGGER::dragViaMarkObstacles( const VIA_HANDLE& aHandle, NODE* aNode, const VECTOR2I& aP )
337{
339
340 ITEM_SET fanout = findViaFanoutByHandle( aNode, aHandle );
341
342 if( fanout.Empty() )
343 {
344 return true;
345 }
346
347 for( ITEM* item : fanout.Items() )
348 {
349 if( const LINE* l = dyn_cast<const LINE*>( item ) )
350 {
351 LINE origLine( *l );
352 LINE draggedLine( *l );
353
354 draggedLine.DragCorner( aP, origLine.CLine().Find( aHandle.pos ), m_freeAngleMode );
355 draggedLine.ClearLinks();
356
357 m_draggedItems.Add( draggedLine );
358
359 m_lastNode->Remove( origLine );
360 m_lastNode->Add( draggedLine );
361 }
362 else if ( VIA *via = dyn_cast<VIA*>( item ) )
363 {
364 auto nvia = Clone( *via );
365
366 nvia->SetPos( aP );
367 m_draggedItems.Add( nvia.get() );
368
370 m_lastNode->Add( std::move( nvia ) );
371 }
372 }
373
374 return true;
375}
376
377
378bool DRAGGER::dragViaWalkaround( const VIA_HANDLE& aHandle, NODE* aNode, const VECTOR2I& aP )
379{
381
382 ITEM_SET fanout = findViaFanoutByHandle( aNode, aHandle );
383
384 if( fanout.Empty() )
385 {
386 return true;
387 }
388
389 bool viaPropOk = false;
390 VECTOR2I viaTargetPos;
391
392 for( ITEM* item : fanout.Items() )
393 {
394 if ( VIA *via = dyn_cast<VIA*>( item ) )
395 {
396 auto draggedVia = Clone( *via );
397
398 draggedVia->SetPos( aP );
399 m_draggedItems.Add( draggedVia.get() );
400
401 std::set<VIA*> vias;
402
403 vias.insert( draggedVia.get() );
404
405 bool ok = propagateViaForces( m_lastNode, vias );
406
407 if( ok )
408 {
409 viaTargetPos = draggedVia->Pos();
410 viaPropOk = true;
412 m_lastNode->Add( std::move(draggedVia) );
413 }
414 }
415 }
416
417 if( !viaPropOk ) // can't force-propagate the via? bummer...
418 return false;
419
420 for( ITEM* item : fanout.Items() )
421 {
422 if( const LINE* l = dyn_cast<const LINE*>( item ) )
423 {
424 LINE origLine( *l );
425 LINE draggedLine( *l );
426 LINE walkLine( *l );
427
428 draggedLine.DragCorner( viaTargetPos, origLine.CLine().Find( aHandle.pos ),
430 draggedLine.ClearLinks();
431
432 if ( m_world->CheckColliding( &draggedLine ) )
433 {
434 bool ok = tryWalkaround( m_lastNode, draggedLine, walkLine );
435
436 if( !ok )
437 return false;
438
439 m_lastNode->Remove( origLine );
440 optimizeAndUpdateDraggedLine( walkLine, origLine, aP );
441 }
442 else
443 {
444 m_draggedItems.Add( draggedLine );
445
446 m_lastNode->Remove( origLine );
447 m_lastNode->Add( draggedLine );
448 }
449 }
450 }
451
452 return true;
453}
454
455
456void DRAGGER::optimizeAndUpdateDraggedLine( LINE& aDragged, const LINE& aOrig, const VECTOR2I& aP )
457{
458 VECTOR2D lockV;
459 aDragged.ClearLinks();
460 aDragged.Unmark();
461
462 lockV = aDragged.CLine().NearestPoint( aP );
463
464 OPTIMIZER optimizer( m_lastNode );
465
467
468 if( Settings().SmoothDraggedSegments() )
470
471 optimizer.SetEffortLevel( effort );
472
473 OPT_BOX2I affectedArea = aDragged.ChangedArea( &aOrig );
474 VECTOR2I anchor( aP );
475
476 if( aDragged.CLine().Find( aP ) < 0 )
477 {
478 anchor = aDragged.CLine().NearestPoint( aP );
479 }
480
481 optimizer.SetPreserveVertex( anchor );
482
483 // People almost never want KiCad to reroute tracks in areas they can't even see, so restrict
484 // the area to what is visible even if we are optimizing the "entire" track.
485 if( Settings().GetOptimizeEntireDraggedTrack() )
486 affectedArea = VisibleViewArea();
487 else if( !affectedArea )
488 affectedArea = BOX2I( aP ); // No valid area yet? set to minimum to disable optimization
489
490 PNS_DBG( Dbg(), AddPoint, anchor, YELLOW, 100000, wxT( "drag-anchor" ) );
491 PNS_DBG( Dbg(), AddShape, *affectedArea, RED, 0, wxT( "drag-affected-area" ) );
492
493 optimizer.SetRestrictArea( *affectedArea );
494 optimizer.Optimize( &aDragged );
495
496 OPT_BOX2I optArea = aDragged.ChangedArea( &aOrig );
497
498 if( optArea )
499 PNS_DBG( Dbg(), AddShape, *optArea, BLUE, 0, wxT( "drag-opt-area" ) );
500
501 m_lastNode->Add( aDragged );
503 m_draggedItems.Add( aDragged );
504}
505
506
507bool DRAGGER::tryWalkaround( NODE* aNode, LINE& aOrig, LINE& aWalk )
508{
509 WALKAROUND walkaround( aNode, Router() );
510 bool ok = false;
511 walkaround.SetSolidsOnly( false );
512 walkaround.SetDebugDecorator( Dbg() );
513 walkaround.SetLogger( Logger() );
514 walkaround.SetIterationLimit( Settings().WalkaroundIterationLimit() );
515
516 aWalk = aOrig;
517
518 WALKAROUND::RESULT wr = walkaround.Route( aWalk );
519
521 {
522 if( wr.lineCw.CLine().PointCount() > 1
523 && wr.lineCw.CLine().Length() < wr.lineCcw.CLine().Length() )
524 {
525 aWalk = wr.lineCw;
526 ok = true;
527 }
528 else if( wr.lineCcw.CLine().PointCount() > 1 )
529 {
530 aWalk = wr.lineCcw;
531 ok = true;
532 }
533 }
534 else if( wr.statusCw == WALKAROUND::DONE && wr.lineCw.CLine().PointCount() > 1 )
535 {
536 aWalk = wr.lineCw;
537 ok = true;
538 }
539 else if( wr.statusCcw == WALKAROUND::DONE && wr.lineCcw.CLine().PointCount() > 1 )
540 {
541 aWalk = wr.lineCcw;
542 ok = true;
543 }
544
545 return ok;
546}
547
548
550{
551 bool ok = false;
552
553 // fixme: rewrite using shared_ptr...
554 if( m_lastNode )
555 {
556 delete m_lastNode;
557 m_lastNode = nullptr;
558 }
559
561
562 switch( m_mode )
563 {
564 case DM_SEGMENT:
565 case DM_CORNER:
566 {
567 int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine.Width() / 4 : 0;
568 LINE dragged( m_draggedLine );
569 LINE draggedWalk( m_draggedLine );
570 LINE origLine( m_draggedLine );
571
572 dragged.SetSnapThreshhold( thresh );
573
574 if( m_mode == DM_SEGMENT )
575 dragged.DragSegment( aP, m_draggedSegmentIndex );
576 else
577 dragged.DragCorner( aP, m_draggedSegmentIndex );
578
579 if ( m_world->CheckColliding( &dragged ) )
580 {
581 ok = tryWalkaround( m_lastNode, dragged, draggedWalk );
582 }
583 else
584 {
585 draggedWalk = dragged;
586 ok = true;
587 }
588
589 if( draggedWalk.CLine().PointCount() < 2 )
590 ok = false;
591
592 if( ok )
593 {
594 PNS_DBG( Dbg(), AddShape, &origLine.CLine(), BLUE, 50000, wxT( "drag-orig-line" ) );
595 PNS_DBG( Dbg(), AddShape, &draggedWalk.CLine(), CYAN, 75000, wxT( "drag-walk" ) );
596 m_lastNode->Remove( origLine );
597 optimizeAndUpdateDraggedLine( draggedWalk, origLine, aP );
598 }
599
600 break;
601 }
602 case DM_VIA: // fixme...
603 {
605 break;
606 }
607 }
608
609 m_dragStatus = ok;
610
611 return true;
612}
613
614
616{
617 bool ok = false;
618
619 if( m_lastNode )
620 {
621 delete m_lastNode;
622 m_lastNode = nullptr;
623 }
624
625 switch( m_mode )
626 {
627 case DM_SEGMENT:
628 case DM_CORNER:
629 {
630 //TODO: Make threshold configurable
631 int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine.Width() / 2 : 0;
632 LINE dragged( m_draggedLine );
633 dragged.SetSnapThreshhold( thresh );
634
635 if( m_mode == DM_SEGMENT )
636 dragged.DragSegment( aP, m_draggedSegmentIndex );
637 else
638 dragged.DragCorner( aP, m_draggedSegmentIndex );
639
640 PNS_DBG( Dbg(), AddShape, &dragged.CLine(), BLUE, 5000, wxT( "drag-shove-line" ) );
641
642 SHOVE::SHOVE_STATUS st = m_shove->ShoveLines( dragged );
643
644 if( st == SHOVE::SH_OK )
645 {
646 ok = true;
647 }
648 else if( st == SHOVE::SH_HEAD_MODIFIED )
649 {
650 dragged = m_shove->NewHead();
651 ok = true;
652 }
653
654 m_lastNode = m_shove->CurrentNode()->Branch();
655
656 if( ok )
657 {
658 VECTOR2D lockV;
659 dragged.ClearLinks();
660 dragged.Unmark();
662 m_lastDragSolution = dragged;
663 }
664 else
665 {
668 }
669
670 break;
671 }
672
673 case DM_VIA:
674 {
675 VIA_HANDLE newVia;
676
677 // corner count limiter intended to avoid excessive optimization produces mediocre results for via shoving.
678 // this is a hack that disables it, before I figure out a more reliable solution
679 m_shove->DisablePostShoveOptimizations( OPTIMIZER::LIMIT_CORNER_COUNT );
680 SHOVE::SHOVE_STATUS st = m_shove->ShoveDraggingVia( m_draggedVia, aP, newVia );
681
682 if( st == SHOVE::SH_OK || st == SHOVE::SH_HEAD_MODIFIED )
683 ok = true;
684
685 m_lastNode = m_shove->CurrentNode()->Branch();
686
687 if( newVia.valid )
688 m_draggedVia = newVia;
689
691 break;
692 }
693 }
694
695 m_dragStatus = ok;
696
697 return ok;
698}
699
700
702{
703 NODE* node = CurrentNode();
704
705 if( node )
706 {
707 // If collisions exist, we can fix in shove/smart mode because all tracks to be committed
708 // will be in valid positions (even if the current routing solution to the mouse cursor is
709 // invalid). In other modes, we can only commit if "Allow DRC violations" is enabled.
710 if( !m_dragStatus )
711 {
713 node = CurrentNode();
714
715 if( !node )
716 return false;
717 }
718
719 if( !m_dragStatus && !Settings().AllowDRCViolations() )
720 return false;
721
722 Router()->CommitRouting( node );
723 return true;
724 }
725
726 return false;
727}
728
729
730bool DRAGGER::Drag( const VECTOR2I& aP )
731{
733
734 bool ret = false;
735
736 if( m_freeAngleMode )
737 {
738 ret = dragMarkObstacles( aP );
739 }
740 else
741 {
742 switch( m_currentMode )
743 {
744 case RM_MarkObstacles: ret = dragMarkObstacles( aP ); break;
745 case RM_Shove: ret = dragShove( aP ); break;
746 case RM_Walkaround: ret = dragWalkaround( aP ); break;
747 default: break;
748 }
749 }
750
751 if( ret )
752 m_lastValidPoint = aP;
753
754 return ret;
755}
756
757
759{
760 return m_lastNode ? m_lastNode : m_world;
761}
762
763
765{
766 return m_draggedItems;
767}
768
769}
BOX2< VECTOR2I > BOX2I
Definition: box2.h:847
std::optional< BOX2I > OPT_BOX2I
Definition: box2.h:850
int Start() const
Definition: pns_layerset.h:82
const BOX2I & VisibleViewArea() const
void SetDebugDecorator(DEBUG_DECORATOR *aDecorator)
Assign a debug decorator allowing this algo to draw extra graphics for visual debugging.
Definition: pns_algo_base.h:73
void SetLogger(LOGGER *aLogger)
Definition: pns_algo_base.h:65
virtual LOGGER * Logger()
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.
DEBUG_DECORATOR * Dbg() const
Definition: pns_algo_base.h:78
ITEM_SET m_draggedItems
If true, moves the connection lines without maintaining 45 degrees corners.
Definition: pns_dragger.h:156
PNS::DRAG_MODE Mode() const override
bool m_dragStatus
Definition: pns_dragger.h:150
void optimizeAndUpdateDraggedLine(LINE &aDragged, const LINE &aOrig, const VECTOR2I &aP)
const ITEM_SET findViaFanoutByHandle(NODE *aNode, const VIA_HANDLE &handle)
bool startDragSegment(const VECTOR2D &aP, SEGMENT *aSeg)
VECTOR2D m_lastValidPoint
Contains the list of items that are currently modified by the dragger.
Definition: pns_dragger.h:153
virtual bool Start(const VECTOR2I &aP, ITEM_SET &aPrimitives) override
Function Start()
NODE * CurrentNode() const override
Function CurrentNode()
DRAGGER(ROUTER *aRouter)
Definition: pns_dragger.cpp:32
bool dragViaMarkObstacles(const VIA_HANDLE &aHandle, NODE *aNode, const VECTOR2I &aP)
bool Drag(const VECTOR2I &aP) override
Function Drag()
bool startDragVia(VIA *aVia)
LINE m_lastDragSolution
Definition: pns_dragger.h:147
int m_draggedSegmentIndex
Definition: pns_dragger.h:149
bool dragShove(const VECTOR2I &aP)
void SetMode(PNS::DRAG_MODE aDragMode) override
bool dragMarkObstacles(const VECTOR2I &aP)
std::unique_ptr< SHOVE > m_shove
Definition: pns_dragger.h:148
NODE * m_lastNode
Definition: pns_dragger.h:144
LINE m_draggedLine
Definition: pns_dragger.h:146
bool dragWalkaround(const VECTOR2I &aP)
bool FixRoute() override
Function FixRoute()
const std::vector< int > CurrentNets() const override
Function CurrentNets()
VVIA * checkVirtualVia(const VECTOR2D &aP, SEGMENT *aSeg)
Definition: pns_dragger.cpp:71
VIA_HANDLE m_draggedVia
Definition: pns_dragger.h:142
bool dragViaWalkaround(const VIA_HANDLE &aHandle, NODE *aNode, const VECTOR2I &aP)
bool m_freeAngleMode
Definition: pns_dragger.h:159
PNS_MODE m_currentMode
Definition: pns_dragger.h:151
const ITEM_SET Traces() override
Function Traces()
bool tryWalkaround(NODE *aNode, LINE &aOrig, LINE &aWalk)
bool startDragArc(const VECTOR2D &aP, ARC *aArc)
MOUSE_TRAIL_TRACER m_mouseTrailTracer
Definition: pns_dragger.h:160
VIA_HANDLE m_initialVia
Definition: pns_dragger.h:141
bool propagateViaForces(NODE *node, std::set< VIA * > &vias)
Definition: pns_dragger.cpp:52
DRAG_ALGO.
Definition: pns_drag_algo.h:44
bool Empty() const
Definition: pns_itemset.h:130
void Add(const LINE &aLine)
Definition: pns_itemset.cpp:32
ENTRIES & Items()
Definition: pns_itemset.h:135
Base class for PNS router board items.
Definition: pns_item.h:56
virtual void Unmark(int aMarker=-1) const
Definition: pns_item.h:213
PnsKind Kind() const
Return the type (kind) of the item.
Definition: pns_item.h:132
@ SEGMENT_T
Definition: pns_item.h:66
int Net() const
Definition: pns_item.h:154
A 2D point on a given set of layers and belonging to a certain net, that links together a number of b...
Definition: pns_joint.h:43
const LINKED_ITEMS & LinkList() const
Definition: pns_joint.h:241
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
Definition: pns_line.h:61
virtual void Unmark(int aMarker=-1) const override
Definition: pns_line.cpp:99
const SHAPE_LINE_CHAIN & CLine() const
Definition: pns_line.h:142
OPT_BOX2I ChangedArea(const LINE *aOther) const
Definition: pns_line.cpp:1152
void Reverse()
Clip the line to the nearest obstacle, traversing from the line's start vertex (0).
Definition: pns_line.cpp:1023
void DragCorner(const VECTOR2I &aP, int aIndex, bool aFreeAngle=false)
Definition: pns_line.cpp:734
void SetSnapThreshhold(int aThreshhold)
Definition: pns_line.h:224
void DragSegment(const VECTOR2I &aP, int aIndex, bool aFreeAngle=false)
Definition: pns_line.cpp:748
int PointCount() const
Definition: pns_line.h:145
int Width() const
Return true if the line is geometrically identical as line aOther.
Definition: pns_line.h:161
void AddTrailPoint(const VECTOR2I &aP)
Keep the router "world" - i.e.
Definition: pns_node.h:156
NODE * Branch()
Create a lightweight copy (called branch) of self that tracks the changes (added/removed items) wrs t...
Definition: pns_node.cpp:139
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:475
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
Definition: pns_node.cpp:667
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:1201
void Remove(ARC *aArc)
Remove an item from this branch.
Definition: pns_node.cpp:893
const LINE AssembleLine(LINKED_ITEM *aSeg, int *aOriginSegmentIndex=nullptr, bool aStopAtLockedJoints=false, bool aFollowLockedSegments=false)
Follow the joint map to assemble a line connecting two non-trivial joints starting from segment aSeg.
Definition: pns_node.cpp:1003
Perform various optimizations of the lines being routed, attempting to make the lines shorter and les...
Definition: pns_optimizer.h:95
void SetPreserveVertex(const VECTOR2I &aV)
void SetRestrictArea(const BOX2I &aArea, bool aStrict=true)
void SetEffortLevel(int aEffort)
static bool Optimize(LINE *aLine, int aEffortLevel, NODE *aWorld, const VECTOR2I &aV=VECTOR2I(0, 0))
@ LIMIT_CORNER_COUNT
Do not attempt to optimize if the resulting line's corner count is outside the predefined range.
@ MERGE_SEGMENTS
Reduce corner cost iteratively.
Definition: pns_optimizer.h:99
@ MERGE_COLINEAR
Merge co-linear segments.
void CommitRouting()
Definition: pns_router.cpp:902
int ViaForcePropIterationLimit() const
bool SmoothDraggedSegments() const
Enable/disable smoothing segments during dragging.
PNS_MODE Mode() const
Set the routing mode.
const SEG & Seg() const
Definition: pns_segment.h:84
int Width() const override
Definition: pns_segment.h:79
@ SH_HEAD_MODIFIED
Definition: pns_shove.h:54
const VIA_HANDLE MakeHandle() const
Definition: pns_via.cpp:213
void SetIterationLimit(const int aIterLimit)
void SetSolidsOnly(bool aSolidsOnly)
WALKAROUND_STATUS Route(const LINE &aInitialPath, LINE &aWalkPath, bool aOptimize=true)
VECTOR2I A
Definition: seg.h:49
VECTOR2I B
Definition: seg.h:50
bool IsPtOnArc(size_t aPtIndex) const
int PointCount() const
Return the number of points (vertices) in this line chain.
const VECTOR2I NearestPoint(const VECTOR2I &aP, bool aAllowInternalShapePoints=true) const
Find a point on the line chain that is closest to point aP.
long long int Length() const
Return length of the line chain in Euclidean metric.
int Find(const VECTOR2I &aP, int aThreshold=0) const
Search for point aP.
@ BLUE
Definition: color4d.h:54
@ CYAN
Definition: color4d.h:56
@ YELLOW
Definition: color4d.h:65
@ RED
Definition: color4d.h:57
Push and Shove diff pair dimensions (gap) settings dialog.
@ RM_MarkObstacles
Ignore collisions, mark obstacles.
@ RM_Walkaround
Only walk around.
@ RM_Shove
Only shove.
DRAG_MODE
Definition: pns_router.h:71
@ DM_CORNER
Definition: pns_router.h:72
@ DM_FREE_ANGLE
Definition: pns_router.h:75
@ DM_VIA
Definition: pns_router.h:74
@ DM_SEGMENT
Definition: pns_router.h:73
@ DM_ARC
Definition: pns_router.h:76
@ MK_LOCKED
Definition: pns_item.h:43
std::unique_ptr< typename std::remove_const< T >::type > Clone(const T &aItem)
Definition: pns_item.h:279
#define PNS_DBG(dbg, method,...)
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
VECTOR2I pos
Definition: pns_via.h:44
LAYER_RANGE layers
Definition: pns_via.h:45
WALKAROUND_STATUS statusCcw
WALKAROUND_STATUS statusCw
double EuclideanNorm(const VECTOR2I &vector)
Definition: trigo.h:129