KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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-2024 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 m_forceMarkObstaclesMode = false;
45}
46
47
49{
50}
51
52
53bool DRAGGER::propagateViaForces( NODE* node, std::set<VIA*>& vias )
54{
55 VIA* via = *vias.begin();
56
57 VECTOR2I force;
59
60 const int iterLimit = Settings().ViaForcePropIterationLimit();
61
62 if( via->PushoutForce( node, lead, force, ITEM::ANY_T, iterLimit ) )
63 {
64 via->SetPos( via->Pos() + force );
65 return true;
66 }
67
68 return false;
69}
70
71
73{
74 int w2 = aSeg->Width() / 2;
75
76 auto distA = ( aP - aSeg->Seg().A ).EuclideanNorm();
77 auto distB = ( aP - aSeg->Seg().B ).EuclideanNorm();
78
79 VECTOR2I psnap;
80
81 if( distA <= w2 )
82 {
83 psnap = aSeg->Seg().A;
84 }
85 else if( distB <= w2 )
86 {
87 psnap = aSeg->Seg().B;
88 }
89 else
90 {
91 return nullptr;
92 }
93
94 const JOINT *jt = m_world->FindJoint( psnap, aSeg );
95
96 if ( !jt )
97 return nullptr;
98
99 for( ITEM* item : jt->LinkList() )
100 {
101 if( item->IsVirtual() && item->OfKind( ITEM::VIA_T ))
102 return static_cast<VVIA*>( item );
103 }
104
105 return nullptr;
106}
107
108
110{
111 int w2 = aSeg->Width() / 2;
112
115
117 {
118 // If we're already in a state that violates DRC then there's not much we can do but
119 // switch to mark obstacles mode.
121 }
122
124 m_shove->SetInitialLine( m_draggedLine );
125
126 auto distA = ( aP - aSeg->Seg().A ).EuclideanNorm();
127 auto distB = ( aP - aSeg->Seg().B ).EuclideanNorm();
128
129 if( distA < w2 || distB < w2 )
130 {
132
133 if( distB <= distA )
135 }
136 else if( m_freeAngleMode )
137 {
138 if( distB < distA &&
140 ( !m_draggedLine.CLine().IsPtOnArc( static_cast<size_t>(m_draggedSegmentIndex) + 1 ) ) )
141 {
143 }
144
146 }
147 else
148 {
150 }
151
152 return true;
153}
154
155
156bool DRAGGER::startDragArc( const VECTOR2D& aP, ARC* aArc )
157{
159 m_shove->SetInitialLine( m_draggedLine );
160 m_mode = DM_ARC;
161
163 {
164 // If we're already in a state that violates DRC then there's not much we can do but
165 // switch to mark obstacles mode.
167 }
168
169 return true;
170}
171
172
174{
175 m_initialVia = aVia->MakeHandle();
177
178 m_mode = DM_VIA;
179
180 if ( m_world->CheckColliding( aVia ) )
181 {
182 // If we're already in a state that violates DRC then there's not much we can do but
183 // switch to mark obstacles mode.
185 }
186
187 return true;
188}
189
191{
192 ITEM_SET rv;
193
194 const JOINT* jt = aNode->FindJoint( handle.pos, handle.layers.Start(), handle.net );
195
196 if( !jt )
197 return rv;
198
199 for( ITEM* item : jt->LinkList() )
200 {
201 if( item->OfKind( ITEM::SEGMENT_T | ITEM::ARC_T ) )
202 {
203 int segIndex;
204 LINKED_ITEM* seg = ( LINKED_ITEM*) item;
205 LINE l = aNode->AssembleLine( seg, &segIndex );
206
207 if( segIndex != 0 )
208 l.Reverse();
209
210 rv.Add( l );
211 }
212 else if( item->OfKind( ITEM::VIA_T ) )
213 {
214 rv.Add( item );
215 }
216 }
217
218 return rv;
219}
220
221bool DRAGGER::Start( const VECTOR2I& aP, ITEM_SET& aPrimitives )
222{
223 if( aPrimitives.Empty() )
224 return false;
225
226 ITEM* startItem = aPrimitives[0];
227
228 m_lastNode = nullptr;
233 m_lastValidPoint = aP;
234
237
239 {
240 m_shove = std::make_unique<SHOVE>( m_world, Router() );
241 m_shove->SetLogger( Logger() );
242 m_shove->SetDebugDecorator( Dbg() );
243 }
244
245 startItem->Unmark( MK_LOCKED );
246
247 PNS_DBG( Dbg(), Message, wxString::Format( "StartDragging: item %p [kind %d]",
248 startItem, (int) startItem->Kind() ) );
249
250 switch( startItem->Kind() )
251 {
252 case ITEM::SEGMENT_T:
253 {
254 SEGMENT* seg = static_cast<SEGMENT*>( startItem );
255 VVIA* vvia = checkVirtualVia( aP, seg );
256
257 if( vvia )
258 return startDragVia( vvia );
259 else
260 return startDragSegment( aP, seg );
261 }
262 case ITEM::VIA_T:
263 return startDragVia( static_cast<VIA*>( startItem ) );
264
265 case ITEM::ARC_T:
266 return startDragArc( aP, static_cast<ARC*>( startItem ) );
267
268 default:
269 return false;
270 }
271}
272
273
275{
276 m_mode = static_cast<int>( aMode );
277}
278
279
281{
282 return static_cast<PNS::DRAG_MODE>( m_mode );
283}
284
285
286const std::vector<NET_HANDLE> DRAGGER::CurrentNets() const
287{
288 if( m_mode == PNS::DM_VIA )
289 return std::vector<NET_HANDLE>( 1, m_draggedVia.net );
290 else
291 return std::vector<NET_HANDLE>( 1, m_draggedLine.Net() );
292}
293
294
296{
297 // fixme: rewrite using shared_ptr...
298 if( m_lastNode )
299 {
300 delete m_lastNode;
301 m_lastNode = nullptr;
302 }
303
305
306 switch( m_mode )
307 {
308 case DM_SEGMENT:
309 case DM_CORNER:
310 {
311 //TODO: Make threshold configurable
312 int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine.Width() / 4 : 0;
313 LINE origLine( m_draggedLine );
314 LINE dragged( m_draggedLine );
315 dragged.SetSnapThreshhold( thresh );
316 dragged.ClearLinks();
317
318 if( m_mode == DM_SEGMENT )
319 dragged.DragSegment( aP, m_draggedSegmentIndex );
320 else
322
323 m_lastNode->Remove( origLine );
324 m_lastNode->Add( dragged );
325
327 m_draggedItems.Add( dragged );
328
329 break;
330 }
331
332 case DM_VIA: // fixme...
334
335 break;
336 }
337
338 if( Settings().AllowDRCViolations() )
339 m_dragStatus = true;
340 else
342
343 return true;
344}
345
346
347bool DRAGGER::dragViaMarkObstacles( const VIA_HANDLE& aHandle, NODE* aNode, const VECTOR2I& aP )
348{
350
351 ITEM_SET fanout = findViaFanoutByHandle( aNode, aHandle );
352
353 if( fanout.Empty() )
354 return true;
355
356 for( ITEM* item : fanout.Items() )
357 {
358 if( const LINE* l = dyn_cast<const LINE*>( item ) )
359 {
360 LINE origLine( *l );
361 LINE draggedLine( *l );
362
363 draggedLine.DragCorner( aP, origLine.CLine().Find( aHandle.pos ), m_freeAngleMode );
364 draggedLine.ClearLinks();
365
366 m_draggedItems.Add( draggedLine );
367
368 m_lastNode->Remove( origLine );
369 m_lastNode->Add( draggedLine );
370 }
371 else if ( VIA *via = dyn_cast<VIA*>( item ) )
372 {
373 auto nvia = Clone( *via );
374
375 nvia->SetPos( aP );
376 m_draggedItems.Add( nvia.get() );
377
379 m_lastNode->Add( std::move( nvia ) );
380 }
381 }
382
383 return true;
384}
385
386
387bool DRAGGER::dragViaWalkaround( const VIA_HANDLE& aHandle, NODE* aNode, const VECTOR2I& aP )
388{
390
391 ITEM_SET fanout = findViaFanoutByHandle( aNode, aHandle );
392
393 if( fanout.Empty() )
394 return true;
395
396 bool viaPropOk = false;
397 VECTOR2I viaTargetPos;
398
399 for( ITEM* item : fanout.Items() )
400 {
401 if( VIA *via = dyn_cast<VIA*>( item ) )
402 {
403 std::unique_ptr<VIA> draggedVia = Clone( *via );
404
405 draggedVia->SetPos( aP );
406 m_draggedItems.Add( draggedVia.get() );
407
408 std::set<VIA*> vias;
409
410 vias.insert( draggedVia.get() );
411
413
414 bool ok = propagateViaForces( m_lastNode, vias );
415
416 if( ok )
417 {
418 viaTargetPos = draggedVia->Pos();
419 viaPropOk = true;
420 m_lastNode->Add( std::move(draggedVia) );
421 }
422 }
423 }
424
425 if( !viaPropOk ) // can't force-propagate the via? bummer...
426 return false;
427
428 for( ITEM* item : fanout.Items() )
429 {
430 if( const LINE* l = dyn_cast<const LINE*>( item ) )
431 {
432 LINE origLine( *l );
433 LINE draggedLine( *l );
434 LINE walkLine( *l );
435
436 draggedLine.DragCorner( viaTargetPos, origLine.CLine().Find( aHandle.pos ),
438 draggedLine.ClearLinks();
439
440 if ( m_world->CheckColliding( &draggedLine ) )
441 {
442 bool ok = tryWalkaround( m_lastNode, draggedLine, walkLine );
443
444 if( !ok )
445 return false;
446
447 m_lastNode->Remove( origLine );
448 optimizeAndUpdateDraggedLine( walkLine, origLine, aP );
449 }
450 else
451 {
452 m_draggedItems.Add( draggedLine );
453
454 m_lastNode->Remove( origLine );
455 m_lastNode->Add( draggedLine );
456 }
457 }
458 }
459
460 return true;
461}
462
463
464void DRAGGER::optimizeAndUpdateDraggedLine( LINE& aDragged, const LINE& aOrig, const VECTOR2I& aP )
465{
466 aDragged.ClearLinks();
467 aDragged.Unmark();
468
469 OPTIMIZER optimizer( m_lastNode );
470
472
473 if( Settings().SmoothDraggedSegments() )
475
476 optimizer.SetEffortLevel( effort );
477
478 OPT_BOX2I affectedArea = aDragged.ChangedArea( &aOrig );
479 VECTOR2I anchor( aP );
480
481 if( aDragged.CLine().Find( aP ) < 0 )
482 anchor = aDragged.CLine().NearestPoint( aP );
483
484 optimizer.SetPreserveVertex( anchor );
485
486 // People almost never want KiCad to reroute tracks in areas they can't even see, so restrict
487 // the area to what is visible even if we are optimizing the "entire" track.
488 if( Settings().GetOptimizeEntireDraggedTrack() )
489 affectedArea = VisibleViewArea();
490 else if( !affectedArea )
491 affectedArea = BOX2I( aP ); // No valid area yet? set to minimum to disable optimization
492
493 PNS_DBG( Dbg(), AddPoint, anchor, YELLOW, 100000, wxT( "drag-anchor" ) );
494 PNS_DBG( Dbg(), AddShape, *affectedArea, RED, 0, wxT( "drag-affected-area" ) );
495
496 optimizer.SetRestrictArea( *affectedArea );
497 optimizer.Optimize( &aDragged );
498
499 OPT_BOX2I optArea = aDragged.ChangedArea( &aOrig );
500
501 if( optArea )
502 PNS_DBG( Dbg(), AddShape, *optArea, BLUE, 0, wxT( "drag-opt-area" ) );
503
504 m_lastNode->Add( aDragged );
506 m_draggedItems.Add( aDragged );
507}
508
509
510bool DRAGGER::tryWalkaround( NODE* aNode, LINE& aOrig, LINE& aWalk )
511{
512 WALKAROUND walkaround( aNode, Router() );
513 bool ok = false;
514 walkaround.SetSolidsOnly( false );
515 walkaround.SetDebugDecorator( Dbg() );
516 walkaround.SetLogger( Logger() );
517 walkaround.SetIterationLimit( Settings().WalkaroundIterationLimit() );
518
519 aWalk = aOrig;
520
521 WALKAROUND::RESULT wr = walkaround.Route( aWalk );
522
524 {
525 if( wr.lineCw.CLine().PointCount() > 1
526 && wr.lineCw.CLine().Length() < wr.lineCcw.CLine().Length() )
527 {
528 aWalk = wr.lineCw;
529 ok = true;
530 }
531 else if( wr.lineCcw.CLine().PointCount() > 1 )
532 {
533 aWalk = wr.lineCcw;
534 ok = true;
535 }
536 }
537 else if( wr.statusCw == WALKAROUND::DONE && wr.lineCw.CLine().PointCount() > 1 )
538 {
539 aWalk = wr.lineCw;
540 ok = true;
541 }
542 else if( wr.statusCcw == WALKAROUND::DONE && wr.lineCcw.CLine().PointCount() > 1 )
543 {
544 aWalk = wr.lineCcw;
545 ok = true;
546 }
547
548 return ok;
549}
550
551
553{
554 bool ok = false;
555
556 // fixme: rewrite using shared_ptr...
557 if( m_lastNode )
558 {
559 delete m_lastNode;
560 m_lastNode = nullptr;
561 }
562
564
565 switch( m_mode )
566 {
567 case DM_SEGMENT:
568 case DM_CORNER:
569 {
570 int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine.Width() / 4 : 0;
571 LINE dragged( m_draggedLine );
572 LINE draggedWalk( m_draggedLine );
573 LINE origLine( m_draggedLine );
574
575 dragged.SetSnapThreshhold( thresh );
576
577 if( m_mode == DM_SEGMENT )
578 dragged.DragSegment( aP, m_draggedSegmentIndex );
579 else
580 dragged.DragCorner( aP, m_draggedSegmentIndex );
581
582 if ( m_world->CheckColliding( &dragged ) )
583 {
584 ok = tryWalkaround( m_lastNode, dragged, draggedWalk );
585 }
586 else
587 {
588 draggedWalk = dragged;
589 ok = true;
590 }
591
592 if( draggedWalk.CLine().PointCount() < 2 )
593 ok = false;
594
595 if( ok )
596 {
597 PNS_DBG( Dbg(), AddShape, &origLine.CLine(), BLUE, 50000, wxT( "drag-orig-line" ) );
598 PNS_DBG( Dbg(), AddShape, &draggedWalk.CLine(), CYAN, 75000, wxT( "drag-walk" ) );
599 m_lastNode->Remove( origLine );
600 optimizeAndUpdateDraggedLine( draggedWalk, origLine, aP );
601 }
602
603 break;
604 }
605 case DM_VIA: // fixme...
607 break;
608 }
609
610 m_dragStatus = ok;
611
612 return ok;
613}
614
615
617{
618 bool ok = false;
619
620 if( m_lastNode )
621 {
622 delete m_lastNode;
623 m_lastNode = nullptr;
624 }
625
626 switch( m_mode )
627 {
628 case DM_SEGMENT:
629 case DM_CORNER:
630 {
631 //TODO: Make threshold configurable
632 int thresh = Settings().SmoothDraggedSegments() ? m_draggedLine.Width() / 2 : 0;
633 LINE dragged( m_draggedLine );
634 dragged.SetSnapThreshhold( thresh );
635
636 if( m_mode == DM_SEGMENT )
637 dragged.DragSegment( aP, m_draggedSegmentIndex );
638 else
639 dragged.DragCorner( aP, m_draggedSegmentIndex );
640
641 PNS_DBG( Dbg(), AddShape, &dragged.CLine(), BLUE, 5000, wxT( "drag-shove-line" ) );
642
643 SHOVE::SHOVE_STATUS st = m_shove->ShoveLines( dragged );
644
645 if( st == SHOVE::SH_OK )
646 {
647 ok = true;
648 }
649 else if( st == SHOVE::SH_HEAD_MODIFIED )
650 {
651 dragged = m_shove->NewHead();
652 ok = true;
653 }
654
655 m_lastNode = m_shove->CurrentNode()->Branch();
656
657 if( ok )
658 {
659 VECTOR2D lockV;
660 dragged.ClearLinks();
661 dragged.Unmark();
663 m_lastDragSolution = dragged;
664 }
665 else
666 {
669 }
670
671 break;
672 }
673
674 case DM_VIA:
675 {
676 VIA_HANDLE newVia;
677
678 // corner count limiter intended to avoid excessive optimization produces mediocre results for via shoving.
679 // this is a hack that disables it, before I figure out a more reliable solution
680 m_shove->DisablePostShoveOptimizations( OPTIMIZER::LIMIT_CORNER_COUNT );
681 SHOVE::SHOVE_STATUS st = m_shove->ShoveDraggingVia( m_draggedVia, aP, newVia );
682
683 if( st == SHOVE::SH_OK || st == SHOVE::SH_HEAD_MODIFIED )
684 ok = true;
685
686 m_lastNode = m_shove->CurrentNode()->Branch();
687
688 if( newVia.valid )
689 m_draggedVia = newVia;
690
692
693 // If drag didn't work (i.e. dragged onto a collision) try walkaround instead
694 if( !ok )
696
697 break;
698 }
699 }
700
701 m_dragStatus = ok;
702
703 return ok;
704}
705
706
707bool DRAGGER::FixRoute( bool aForceCommit )
708{
709 NODE* node = CurrentNode();
710
711 if( node )
712 {
713 if( m_dragStatus )
714 {
715 Router()->CommitRouting( node );
716 return true;
717 }
718 else if( m_forceMarkObstaclesMode )
719 {
720 if( aForceCommit )
721 {
722 Router()->CommitRouting( node );
723 return true;
724 }
725
726 return false;
727 }
728 else
729 {
730 // If collisions exist, we can fix in shove/smart mode because all tracks to be
731 // committed will be in valid positions (even if the current routing solution to
732 // the mouse cursor is invalid).
734 node = CurrentNode();
735
736 if( node && m_dragStatus )
737 {
738 Router()->CommitRouting( node );
739 return true;
740 }
741 }
742 }
743
744 return false;
745}
746
747
748bool DRAGGER::Drag( const VECTOR2I& aP )
749{
751
752 bool ret = false;
753
755 {
756 ret = dragMarkObstacles( aP );
757 }
758 else
759 {
760 switch( m_currentMode )
761 {
762 case RM_MarkObstacles: ret = dragMarkObstacles( aP ); break;
763 case RM_Shove: ret = dragShove( aP ); break;
764 case RM_Walkaround: ret = dragWalkaround( aP ); break;
765 default: break;
766 }
767 }
768
769 if( ret )
770 {
771 m_lastValidPoint = aP;
772 }
773 else
774 {
775 if( m_lastNode )
776 {
777 delete m_lastNode;
779 m_lastNode = nullptr;
780 }
781 }
782
783 return ret;
784}
785
786
788{
789 return m_lastNode ? m_lastNode : m_world;
790}
791
792
794{
795 return m_draggedItems;
796}
797
798}
BOX2< VECTOR2I > BOX2I
Definition: box2.h:853
std::optional< BOX2I > OPT_BOX2I
Definition: box2.h:856
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:162
PNS::DRAG_MODE Mode() const override
bool m_dragStatus
Definition: pns_dragger.h:156
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:159
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:153
int m_draggedSegmentIndex
Definition: pns_dragger.h:155
const std::vector< NET_HANDLE > CurrentNets() const override
Function CurrentNets()
bool dragShove(const VECTOR2I &aP)
void SetMode(PNS::DRAG_MODE aDragMode) override
bool dragMarkObstacles(const VECTOR2I &aP)
bool FixRoute(bool aForceCommit) override
Function FixRoute()
std::unique_ptr< SHOVE > m_shove
Definition: pns_dragger.h:154
NODE * m_lastNode
Definition: pns_dragger.h:150
LINE m_draggedLine
Definition: pns_dragger.h:152
bool dragWalkaround(const VECTOR2I &aP)
VVIA * checkVirtualVia(const VECTOR2D &aP, SEGMENT *aSeg)
Definition: pns_dragger.cpp:72
VIA_HANDLE m_draggedVia
Definition: pns_dragger.h:148
bool dragViaWalkaround(const VIA_HANDLE &aHandle, NODE *aNode, const VECTOR2I &aP)
bool m_freeAngleMode
Definition: pns_dragger.h:165
bool m_forceMarkObstaclesMode
Definition: pns_dragger.h:166
PNS_MODE m_currentMode
Definition: pns_dragger.h:157
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:167
VIA_HANDLE m_initialVia
Definition: pns_dragger.h:147
bool propagateViaForces(NODE *node, std::set< VIA * > &vias)
Definition: pns_dragger.cpp:53
DRAG_ALGO.
Definition: pns_drag_algo.h:44
bool Empty() const
Definition: pns_itemset.h:82
void Add(const LINE &aLine)
Definition: pns_itemset.cpp:32
std::vector< ITEM * > & Items()
Definition: pns_itemset.h:87
Base class for PNS router board items.
Definition: pns_item.h:97
virtual void Unmark(int aMarker=-1) const
Definition: pns_item.h:230
virtual NET_HANDLE Net() const
Definition: pns_item.h:193
PnsKind Kind() const
Return the type (kind) of the item.
Definition: pns_item.h:166
@ SEGMENT_T
Definition: pns_item.h:105
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 std::vector< ITEM * > & LinkList() const
Definition: pns_joint.h:274
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:119
const SHAPE_LINE_CHAIN & CLine() const
Definition: pns_line.h:136
OPT_BOX2I ChangedArea(const LINE *aOther) const
Definition: pns_line.cpp:1172
void Reverse()
Clip the line to the nearest obstacle, traversing from the line's start vertex (0).
Definition: pns_line.cpp:1043
void DragCorner(const VECTOR2I &aP, int aIndex, bool aFreeAngle=false)
Definition: pns_line.cpp:754
void SetSnapThreshhold(int aThreshhold)
Definition: pns_line.h:219
void DragSegment(const VECTOR2I &aP, int aIndex, bool aFreeAngle=false)
Definition: pns_line.cpp:768
int PointCount() const
Definition: pns_line.h:139
int Width() const
Return true if the line is geometrically identical as line aOther.
Definition: pns_line.h:155
void AddTrailPoint(const VECTOR2I &aP)
Keep the router "world" - i.e.
Definition: pns_node.h:207
NODE * Branch()
Create a lightweight copy (called branch) of self that tracks the changes (added/removed items) wrs t...
Definition: pns_node.cpp:143
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:410
const JOINT * FindJoint(const VECTOR2I &aPos, int aLayer, NET_HANDLE aNet) const
Search for a joint at a given position, layer and belonging to given net.
Definition: pns_node.cpp:1212
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
Definition: pns_node.cpp:663
void Remove(ARC *aArc)
Remove an item from this branch.
Definition: pns_node.cpp:884
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:1014
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:896
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:193
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:56
@ CYAN
Definition: color4d.h:58
@ YELLOW
Definition: color4d.h:67
@ RED
Definition: color4d.h:59
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:44
std::unique_ptr< typename std::remove_const< T >::type > Clone(const T &aItem)
Definition: pns_item.h:308
#define PNS_DBG(dbg, method,...)
VECTOR2I pos
Definition: pns_via.h:45
NET_HANDLE net
Definition: pns_via.h:47
LAYER_RANGE layers
Definition: pns_via.h:46
WALKAROUND_STATUS statusCcw
WALKAROUND_STATUS statusCw
double EuclideanNorm(const VECTOR2I &vector)
Definition: trigo.h:128