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#include "pns_topology.h"
33
34namespace PNS {
35
36class WALKAROUND : public ALGO_BASE
37{
38 static constexpr int MaxWalkPolicies = 3;
39
40public:
41 WALKAROUND( NODE* aWorld, ROUTER* aRouter ) :
42 ALGO_BASE ( aRouter ),
43 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 m_useShortestPath = false;
56 }
57
59
60 enum STATUS
61 {
67 };
68
70 {
71 WP_CW = 0,
72 WP_CCW = 1,
73 WP_SHORTEST = 2
74 };
75
76 struct RESULT
77 {
79 {
80 for( int i = 0; i < MaxWalkPolicies; i++ )
81 status [i] = ST_NONE;
82 }
83
86 };
87
88 void SetWorld( NODE* aNode )
89 {
90 m_world = aNode;
91 }
92
93 void SetIterationLimit( const int aIterLimit )
94 {
95 m_iterationLimit = aIterLimit;
96 }
97
98 void SetSolidsOnly( bool aSolidsOnly )
99 {
100 if( aSolidsOnly )
102 else
104 }
105
106 void SetItemMask( int aMask )
107 {
108 m_itemMask = aMask;
109 }
110
111 void SetForceWinding ( bool aEnabled, bool aCw )
112 {
113 m_forceCw = aCw;
114 m_forceWinding = aEnabled;
115 }
116
117 void SetPickShortestPath( bool aEnabled )
118 {
119 m_useShortestPath = aEnabled;
120 }
121
122 void RestrictToCluster( bool aEnabled, const TOPOLOGY::CLUSTER& aCluster );
123
124 STATUS Route( const LINE& aInitialPath, LINE& aWalkPath,
125 bool aOptimize = true );
126
127 const RESULT Route( const LINE& aInitialPath );
128
129 void SetLengthLimit( bool aEnable, double aLengthExpansionFactor )
130 {
131 m_lengthLimitOn = aEnable;
132 m_lengthExpansionFactor = aLengthExpansionFactor;
133 }
134
135 void SetAllowedPolicies( std::vector<WALK_POLICY> aPolicies);
136
137private:
138 void start( const LINE& aInitialPath );
139 bool singleStep();
140
143
151 std::set<const ITEM*> m_restrictedSet;
152 std::vector<VECTOR2I> m_restrictedVertices;
160 std::optional<TOPOLOGY::CLUSTER> m_lastShortestCluster;
163};
164
165}
166
167#endif // __PNS_WALKAROUND_H
Base class for all P&S algorithms (shoving, walkaround, line placement, dragging, etc....
Definition: pns_algo_base.h:43
ROUTING_SETTINGS & Settings() const
Return the logger object, allowing to dump geometry to a file.
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
Definition: pns_line.h:62
Keep the router "world" - i.e.
Definition: pns_node.h:231
std::optional< OBSTACLE > OPT_OBSTACLE
Definition: pns_node.h:241
void SetIterationLimit(const int aIterLimit)
void SetLengthLimit(bool aEnable, double aLengthExpansionFactor)
void RestrictToCluster(bool aEnabled, const TOPOLOGY::CLUSTER &aCluster)
void SetSolidsOnly(bool aSolidsOnly)
STATUS Route(const LINE &aInitialPath, LINE &aWalkPath, bool aOptimize=true)
void SetForceWinding(bool aEnabled, bool aCw)
void SetWorld(NODE *aNode)
bool m_enabledPolicies[MaxWalkPolicies]
NODE::OPT_OBSTACLE nearestObstacle(const LINE &aPath)
void SetItemMask(int aMask)
std::vector< VECTOR2I > m_restrictedVertices
NODE::OPT_OBSTACLE m_currentObstacle[MaxWalkPolicies]
void SetAllowedPolicies(std::vector< WALK_POLICY > aPolicies)
void SetPickShortestPath(bool aEnabled)
VECTOR2I m_cursorPos
void start(const LINE &aInitialPath)
TOPOLOGY::CLUSTER m_currentCluster[MaxWalkPolicies]
static constexpr int MaxWalkPolicies
std::optional< TOPOLOGY::CLUSTER > m_lastShortestCluster
WALKAROUND(NODE *aWorld, ROUTER *aRouter)
double m_lengthExpansionFactor
std::set< const ITEM * > m_restrictedSet
Push and Shove diff pair dimensions (gap) settings dialog.
LINE lines[MaxWalkPolicies]
STATUS status[MaxWalkPolicies]