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 The 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
19 * along with this program. If not, see <https://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_initialLength = 0.0;
51 m_forceCw = false;
52 m_forceLongerPath = false;
53 m_lengthLimitOn = true;
54 m_useShortestPath = false;
57 m_overrideClearance = nullptr;
58 m_useClustering = true;
60 }
61
63
72
74 {
75 WP_CW = 0,
76 WP_CCW = 1,
78 };
79
80 struct RESULT
81 {
83 {
84 for( int i = 0; i < MaxWalkPolicies; i++ )
85 status [i] = ST_NONE;
86 }
87
90 };
91
92 void SetWorld( NODE* aNode )
93 {
94 m_world = aNode;
95 }
96
97 void SetIterationLimit( const int aIterLimit )
98 {
99 m_iterationLimit = aIterLimit;
100 }
101
102 void SetSolidsOnly( bool aSolidsOnly )
103 {
104 if( aSolidsOnly )
106 else
108 }
109
110 void SetItemMask( int aMask )
111 {
112 m_itemMask = aMask;
113 }
114
115 void SetForceWinding ( bool aEnabled, bool aCw )
116 {
117 m_forceCw = aCw;
118 m_forceWinding = aEnabled;
119 }
120
121 void SetPickShortestPath( bool aEnabled )
122 {
123 m_useShortestPath = aEnabled;
124 }
125
126 void SetUseClustering( bool aEnabled )
127 {
128 m_useClustering = aEnabled;
129 }
130
131 void RestrictToCluster( bool aEnabled, const TOPOLOGY::CLUSTER& aCluster );
132
133 STATUS Route( const LINE& aInitialPath, LINE& aWalkPath,
134 bool aOptimize = true );
135
136 const RESULT Route( const LINE& aInitialPath );
137
138 void SetLengthLimit( bool aEnable, double aLengthExpansionFactor )
139 {
140 m_lengthLimitOn = aEnable;
141 m_lengthExpansionFactor = aLengthExpansionFactor;
142 }
143
144 void SetAllowedPolicies( std::vector<WALK_POLICY> aPolicies, bool aAnyCompletePolicyIsSuccess = false );
147
148private:
149 void start( const LINE& aInitialPath );
150 bool singleStep();
151
154
162 std::set<const ITEM*> m_restrictedSet;
163 std::vector<VECTOR2I> m_restrictedVertices;
171 std::set<ITEM*> m_processedItems;
178};
179
180}
181
182#endif // __PNS_WALKAROUND_H
ALGO_BASE(ROUTER *aRouter)
ROUTING_SETTINGS & Settings() const
Return current router settings.
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:274
std::optional< OBSTACLE > OPT_OBSTACLE
Definition pns_node.h:284
void SetIterationLimit(const int aIterLimit)
void SetLengthLimit(bool aEnable, double aLengthExpansionFactor)
void SetUseClustering(bool aEnabled)
void SetAllowedPolicies(std::vector< WALK_POLICY > aPolicies, bool aAnyCompletePolicyIsSuccess=false)
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 SetClearanceOverride(CLEARANCE_OVERRIDE_FUNC aFunc)
void SetCollisionFilter(COLLISION_FILTER_FUNC aFilter)
COLLISION_FILTER_FUNC m_collisionFilter
void SetPickShortestPath(bool aEnabled)
void start(const LINE &aInitialPath)
TOPOLOGY::CLUSTER m_currentCluster[MaxWalkPolicies]
static constexpr int MaxWalkPolicies
CLEARANCE_OVERRIDE_FUNC m_overrideClearance
bool m_anyCompletePolicyIsSuccess
std::set< ITEM * > m_processedItems
WALKAROUND(NODE *aWorld, ROUTER *aRouter)
double m_lengthExpansionFactor
std::set< const ITEM * > m_restrictedSet
Push and Shove diff pair dimensions (gap) settings dialog.
std::function< int(const ITEM *, const ITEM *, CLEARANCE_ASPECT)> CLEARANCE_OVERRIDE_FUNC
Definition pns_node.h:123
std::function< bool(const ITEM *, const ITEM *)> COLLISION_FILTER_FUNC
Definition pns_node.h:122
LINE lines[MaxWalkPolicies]
STATUS status[MaxWalkPolicies]
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708