KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pns_walkaround.h
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 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#ifndef __PNS_WALKAROUND_H
23#define __PNS_WALKAROUND_H
24
25#include <set>
26
27#include "pns_line.h"
28#include "pns_node.h"
29#include "pns_router.h"
30#include "pns_logger.h"
31#include "pns_algo_base.h"
32
33namespace PNS {
34
35class WALKAROUND : public ALGO_BASE
36{
37 static const int DefaultIterationLimit = 50;
38
39public:
40 WALKAROUND( NODE* aWorld, ROUTER* aRouter ) :
41 ALGO_BASE ( aRouter ),
42 m_world( aWorld ),
44 {
45 m_forceWinding = false;
47
48 // Initialize other members, to avoid uninitialized variables.
49 m_iteration = 0;
50 m_forceCw = false;
51 m_forceLongerPath = false;
52 m_lengthLimitOn = true;
53 }
54
56
58 {
62 STUCK
63 };
64
65 struct RESULT
66 {
67 RESULT( WALKAROUND_STATUS aStatusCw = STUCK, WALKAROUND_STATUS aStatusCcw = STUCK, const LINE& aLineCw = LINE(), const LINE& aLineCcw = LINE() )
68 {
69 statusCw = aStatusCw;
70 statusCcw = aStatusCcw;
71 lineCw = aLineCw;
72 lineCcw = aLineCcw;
73 }
74
77 };
78
79 void SetWorld( NODE* aNode )
80 {
81 m_world = aNode;
82 }
83
84 void SetIterationLimit( const int aIterLimit )
85 {
86 m_iterationLimit = aIterLimit;
87 }
88
89 void SetSolidsOnly( bool aSolidsOnly )
90 {
91 if( aSolidsOnly )
93 else
95 }
96
97 void SetItemMask( int aMask )
98 {
99 m_itemMask = aMask;
100 }
101
102 void SetForceWinding ( bool aEnabled, bool aCw )
103 {
104 m_forceCw = aCw;
105 m_forceWinding = aEnabled;
106 }
107
108 void RestrictToSet( bool aEnabled, const std::set<ITEM*>& aSet );
109
110 WALKAROUND_STATUS Route( const LINE& aInitialPath, LINE& aWalkPath,
111 bool aOptimize = true );
112
113 const RESULT Route( const LINE& aInitialPath );
114
115 void SetLengthLimit( bool aEnable )
116 {
117 m_lengthLimitOn = aEnable;
118 }
119
120private:
121 void start( const LINE& aInitialPath );
122
123 WALKAROUND_STATUS singleStep( LINE& aPath, bool aWindingDirection );
125
127
135 std::set<ITEM*> m_restrictedSet;
136 std::vector<VECTOR2I> m_restrictedVertices;
139};
140
141}
142
143#endif // __PNS_WALKAROUND_H
Base class for all P&S algorithms (shoving, walkaround, line placement, dragging, etc....
Definition: pns_algo_base.h:43
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
Definition: pns_line.h:61
Keep the router "world" - i.e.
Definition: pns_node.h:207
std::optional< OBSTACLE > OPT_OBSTACLE
Definition: pns_node.h:217
void SetIterationLimit(const int aIterLimit)
std::set< ITEM * > m_restrictedSet
void SetLengthLimit(bool aEnable)
void SetSolidsOnly(bool aSolidsOnly)
WALKAROUND_STATUS singleStep(LINE &aPath, bool aWindingDirection)
NODE::OPT_OBSTACLE m_currentObstacle[2]
void SetForceWinding(bool aEnabled, bool aCw)
void SetWorld(NODE *aNode)
NODE::OPT_OBSTACLE nearestObstacle(const LINE &aPath)
void SetItemMask(int aMask)
std::vector< VECTOR2I > m_restrictedVertices
WALKAROUND_STATUS Route(const LINE &aInitialPath, LINE &aWalkPath, bool aOptimize=true)
VECTOR2I m_cursorPos
void start(const LINE &aInitialPath)
void RestrictToSet(bool aEnabled, const std::set< ITEM * > &aSet)
static const int DefaultIterationLimit
WALKAROUND(NODE *aWorld, ROUTER *aRouter)
Push and Shove diff pair dimensions (gap) settings dialog.
WALKAROUND_STATUS statusCcw
RESULT(WALKAROUND_STATUS aStatusCw=STUCK, WALKAROUND_STATUS aStatusCcw=STUCK, const LINE &aLineCw=LINE(), const LINE &aLineCcw=LINE())
WALKAROUND_STATUS statusCw