KiCad PCB EDA Suite
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 <tomasz.wlostowski@cern.ch>
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 
33 namespace PNS {
34 
35 class WALKAROUND : public ALGO_BASE
36 {
37  static const int DefaultIterationLimit = 50;
38 
39 public:
40  WALKAROUND( NODE* aWorld, ROUTER* aRouter ) :
41  ALGO_BASE ( aRouter ),
42  m_world( aWorld ),
44  {
45  m_forceSingleDirection = false;
46  m_forceLongerPath = false;
47  m_forceWinding = false;
48  m_cursorApproachMode = false;
50 
51  // Initialize other members, to avoid uninitialized variables.
54  m_iteration = 0;
55  m_forceCw = false;
56  }
57 
59 
61  {
66  };
67 
68  struct RESULT
69  {
70  RESULT( WALKAROUND_STATUS aStatusCw = STUCK, WALKAROUND_STATUS aStatusCcw = STUCK, const LINE& aLineCw = LINE(), const LINE& aLineCcw = LINE() )
71  {
72  statusCw = aStatusCw;
73  statusCcw = aStatusCcw;
74  lineCw = aLineCw;
75  lineCcw = aLineCcw;
76  }
77 
80  };
81 
82  void SetWorld( NODE* aNode )
83  {
84  m_world = aNode;
85  }
86 
87  void SetIterationLimit( const int aIterLimit )
88  {
89  m_iterationLimit = aIterLimit;
90  }
91 
92  void SetSolidsOnly( bool aSolidsOnly )
93  {
94  if( aSolidsOnly )
96  else
98  }
99 
100  void SetItemMask( int aMask )
101  {
102  m_itemMask = aMask;
103  }
104 
105  void SetSingleDirection( bool aForceSingleDirection )
106  {
107  m_forceSingleDirection = aForceSingleDirection;
108  m_forceLongerPath = aForceSingleDirection;
109  }
110 
111  void SetSingleDirection2( bool aForceSingleDirection )
112  {
113  m_forceSingleDirection = aForceSingleDirection;
114  }
115 
116  void SetApproachCursor( bool aEnabled, const VECTOR2I& aPos )
117  {
118  m_cursorPos = aPos;
119  m_cursorApproachMode = aEnabled;
120  }
121 
122  void SetForceWinding ( bool aEnabled, bool aCw )
123  {
124  m_forceCw = aCw;
125  m_forceWinding = aEnabled;
126  }
127 
128  void RestrictToSet( bool aEnabled, const std::set<ITEM*>& aSet )
129  {
130  if( aEnabled )
131  m_restrictedSet = aSet;
132  else
133  m_restrictedSet.clear();
134  }
135 
136  WALKAROUND_STATUS Route( const LINE& aInitialPath, LINE& aWalkPath,
137  bool aOptimize = true );
138 
139  const RESULT Route( const LINE& aInitialPath );
140 
141 private:
142  void start( const LINE& aInitialPath );
143 
144  WALKAROUND_STATUS singleStep( LINE& aPath, bool aWindingDirection );
145  NODE::OPT_OBSTACLE nearestObstacle( const LINE& aPath );
146 
148 
156  bool m_forceCw;
161  std::set<ITEM*> m_restrictedSet;
162 };
163 
164 }
165 
166 #endif // __PNS_WALKAROUND_H
NODE.
Definition: pns_node.h:145
void SetForceWinding(bool aEnabled, bool aCw)
ALGO_BASE.
Definition: pns_algo_base.h:39
WALKAROUND_STATUS statusCw
void SetSingleDirection(bool aForceSingleDirection)
void SetSingleDirection2(bool aForceSingleDirection)
VECTOR2I m_cursorPos
WALKAROUND_STATUS Route(const LINE &aInitialPath, LINE &aWalkPath, bool aOptimize=true)
WALKAROUND_STATUS singleStep(LINE &aPath, bool aWindingDirection)
std::set< ITEM * > m_restrictedSet
static const int DefaultIterationLimit
NODE::OPT_OBSTACLE m_currentObstacle[2]
void SetApproachCursor(bool aEnabled, const VECTOR2I &aPos)
void RestrictToSet(bool aEnabled, const std::set< ITEM * > &aSet)
void SetItemMask(int aMask)
void SetSolidsOnly(bool aSolidsOnly)
void start(const LINE &aInitialPath)
RESULT(WALKAROUND_STATUS aStatusCw=STUCK, WALKAROUND_STATUS aStatusCcw=STUCK, const LINE &aLineCw=LINE(), const LINE &aLineCcw=LINE())
WALKAROUND(NODE *aWorld, ROUTER *aRouter)
bool m_recursiveCollision[2]
NODE::OPT_OBSTACLE nearestObstacle(const LINE &aPath)
WALKAROUND_STATUS statusCcw
OPT< OBSTACLE > OPT_OBSTACLE
Definition: pns_node.h:148
void SetWorld(NODE *aNode)
bool m_forceUniqueWindingDirection
Push and Shove diff pair dimensions (gap) settings dialog.
void SetIterationLimit(const int aIterLimit)