KiCad PCB EDA Suite
PNS::WALKAROUND Class Reference

#include <pns_walkaround.h>

Inheritance diagram for PNS::WALKAROUND:
PNS::ALGO_BASE

Classes

struct  RESULT
 

Public Types

enum  WALKAROUND_STATUS { IN_PROGRESS = 0, ALMOST_DONE, DONE, STUCK }
 

Public Member Functions

 WALKAROUND (NODE *aWorld, ROUTER *aRouter)
 
 ~WALKAROUND ()
 
void SetWorld (NODE *aNode)
 
void SetIterationLimit (const int aIterLimit)
 
void SetSolidsOnly (bool aSolidsOnly)
 
void SetItemMask (int aMask)
 
void SetSingleDirection (bool aForceSingleDirection)
 
void SetSingleDirection2 (bool aForceSingleDirection)
 
void SetApproachCursor (bool aEnabled, const VECTOR2I &aPos)
 
void SetForceWinding (bool aEnabled, bool aCw)
 
void RestrictToSet (bool aEnabled, const std::set< ITEM * > &aSet)
 
WALKAROUND_STATUS Route (const LINE &aInitialPath, LINE &aWalkPath, bool aOptimize=true)
 
const RESULT Route (const LINE &aInitialPath)
 
ROUTERRouter () const
 Return current router settings. More...
 
ROUTING_SETTINGSSettings () const
 Return the logger object, allowing to dump geometry to a file. More...
 
virtual LOGGERLogger ()
 
void SetLogger (LOGGER *aLogger)
 
void SetDebugDecorator (DEBUG_DECORATOR *aDecorator)
 Assign a debug decorator allowing this algo to draw extra graphics for visual debugging. More...
 
DEBUG_DECORATORDbg () const
 
const BOX2IVisibleViewArea () const
 

Protected Attributes

DEBUG_DECORATORm_debugDecorator
 
ROUTERm_router
 
LOGGERm_logger
 

Private Member Functions

void start (const LINE &aInitialPath)
 
WALKAROUND_STATUS singleStep (LINE &aPath, bool aWindingDirection)
 
NODE::OPT_OBSTACLE nearestObstacle (const LINE &aPath)
 

Private Attributes

NODEm_world
 
int m_recursiveBlockageCount
 
int m_iteration
 
int m_iterationLimit
 
int m_itemMask
 
bool m_forceSingleDirection
 
bool m_forceLongerPath
 
bool m_cursorApproachMode
 
bool m_forceWinding
 
bool m_forceCw
 
bool m_forceUniqueWindingDirection
 
VECTOR2I m_cursorPos
 
NODE::OPT_OBSTACLE m_currentObstacle [2]
 
bool m_recursiveCollision [2]
 
std::set< ITEM * > m_restrictedSet
 

Static Private Attributes

static const int DefaultIterationLimit = 50
 

Detailed Description

Definition at line 35 of file pns_walkaround.h.

Member Enumeration Documentation

◆ WALKAROUND_STATUS

Enumerator
IN_PROGRESS 
ALMOST_DONE 
DONE 
STUCK 

Definition at line 61 of file pns_walkaround.h.

Constructor & Destructor Documentation

◆ WALKAROUND()

PNS::WALKAROUND::WALKAROUND ( NODE aWorld,
ROUTER aRouter 
)
inline

Definition at line 40 of file pns_walkaround.h.

40  :
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;
57  }
static const int DefaultIterationLimit
ALGO_BASE(ROUTER *aRouter)
Definition: pns_algo_base.h:45
bool m_recursiveCollision[2]
bool m_forceUniqueWindingDirection

References PNS::ITEM::ANY_T, m_cursorApproachMode, m_forceCw, m_forceLongerPath, m_forceSingleDirection, m_forceUniqueWindingDirection, m_forceWinding, m_itemMask, m_iteration, m_recursiveBlockageCount, and m_recursiveCollision.

◆ ~WALKAROUND()

PNS::WALKAROUND::~WALKAROUND ( )
inline

Definition at line 59 of file pns_walkaround.h.

59 {};

Member Function Documentation

◆ Dbg()

◆ Logger()

LOGGER * PNS::ALGO_BASE::Logger ( )
virtualinherited

Reimplemented in PNS::SHOVE.

Definition at line 34 of file pns_algo_base.cpp.

35 {
36  return NULL;
37 }
#define NULL

References NULL.

Referenced by PNS::LINE_PLACER::rhShoveOnly(), PNS::LINE_PLACER::rhWalkOnly(), PNS::DRAGGER::Start(), and PNS::DRAGGER::tryWalkaround().

◆ nearestObstacle()

NODE::OPT_OBSTACLE PNS::WALKAROUND::nearestObstacle ( const LINE aPath)
private

Definition at line 41 of file pns_walkaround.cpp.

42 {
44 
45  if( m_restrictedSet.empty() )
46  return obs;
47 
48  else if( obs && m_restrictedSet.find ( obs->m_item ) != m_restrictedSet.end() )
49  return obs;
50 
51  return NODE::OPT_OBSTACLE();
52 }
OPT_OBSTACLE NearestObstacle(const LINE *aLine, int aKindMask=ITEM::ANY_T, const std::set< ITEM * > *aRestrictedSet=NULL)
Follow the line in search of an obstacle that is nearest to the starting to the line's starting point...
Definition: pns_node.cpp:285
std::set< ITEM * > m_restrictedSet
#define NULL
OPT< OBSTACLE > OPT_OBSTACLE
Definition: pns_node.h:152

References m_itemMask, m_restrictedSet, m_world, PNS::NODE::NearestObstacle(), and NULL.

Referenced by Route(), and singleStep().

◆ RestrictToSet()

void PNS::WALKAROUND::RestrictToSet ( bool  aEnabled,
const std::set< ITEM * > &  aSet 
)
inline

Definition at line 129 of file pns_walkaround.h.

130  {
131  if( aEnabled )
132  m_restrictedSet = aSet;
133  else
134  m_restrictedSet.clear();
135  }
std::set< ITEM * > m_restrictedSet

References m_restrictedSet.

Referenced by PNS::SHOVE::onCollidingSolid().

◆ Route() [1/2]

WALKAROUND::WALKAROUND_STATUS PNS::WALKAROUND::Route ( const LINE aInitialPath,
LINE aWalkPath,
bool  aOptimize = true 
)

Definition at line 286 of file pns_walkaround.cpp.

288 {
289  LINE path_cw( aInitialPath ), path_ccw( aInitialPath );
290  WALKAROUND_STATUS s_cw = IN_PROGRESS, s_ccw = IN_PROGRESS;
291  SHAPE_LINE_CHAIN best_path;
292 
293  // special case for via-in-the-middle-of-track placement
294  if( aInitialPath.PointCount() <= 1 )
295  {
296  if( aInitialPath.EndsWithVia() && m_world->CheckColliding( &aInitialPath.Via(), m_itemMask ) )
297  return STUCK;
298 
299  aWalkPath = aInitialPath;
300  return DONE;
301  }
302 
303  start( aInitialPath );
304 
305  m_currentObstacle[0] = m_currentObstacle[1] = nearestObstacle( aInitialPath );
307 
308  aWalkPath = aInitialPath;
309 
310  if( m_forceWinding )
311  {
312  s_cw = m_forceCw ? IN_PROGRESS : STUCK;
313  s_ccw = m_forceCw ? STUCK : IN_PROGRESS;
314  m_forceSingleDirection = true;
315  } else {
316  m_forceSingleDirection = false;
317  }
318 
319  while( m_iteration < m_iterationLimit )
320  {
321  if( s_cw != STUCK )
322  s_cw = singleStep( path_cw, true );
323 
324  if( s_ccw != STUCK )
325  s_ccw = singleStep( path_ccw, false );
326 
327  if( ( s_cw == DONE && s_ccw == DONE ) || ( s_cw == STUCK && s_ccw == STUCK ) )
328  {
329  int len_cw = path_cw.CLine().Length();
330  int len_ccw = path_ccw.CLine().Length();
331 
332  if( m_forceLongerPath )
333  aWalkPath = ( len_cw > len_ccw ? path_cw : path_ccw );
334  else
335  aWalkPath = ( len_cw < len_ccw ? path_cw : path_ccw );
336 
337  break;
338  }
339  else if( s_cw == DONE && !m_forceLongerPath )
340  {
341  aWalkPath = path_cw;
342  break;
343  }
344  else if( s_ccw == DONE && !m_forceLongerPath )
345  {
346  aWalkPath = path_ccw;
347  break;
348  }
349 
350  m_iteration++;
351  }
352 
354  {
355  int len_cw = path_cw.CLine().Length();
356  int len_ccw = path_ccw.CLine().Length();
357 
358  if( m_forceLongerPath )
359  aWalkPath = ( len_cw > len_ccw ? path_cw : path_ccw );
360  else
361  aWalkPath = ( len_cw < len_ccw ? path_cw : path_ccw );
362  }
363 
365  {
366  // int len_cw = path_cw.GetCLine().Length();
367  // int len_ccw = path_ccw.GetCLine().Length();
368  bool found = false;
369 
370  SHAPE_LINE_CHAIN l = aWalkPath.CLine();
371 
372  for( int i = 0; i < l.SegmentCount(); i++ )
373  {
374  const SEG s = l.Segment( i );
375 
376  VECTOR2I nearest = s.NearestPoint( m_cursorPos );
377  VECTOR2I::extended_type dist_a = ( s.A - m_cursorPos ).SquaredEuclideanNorm();
378  VECTOR2I::extended_type dist_b = ( s.B - m_cursorPos ).SquaredEuclideanNorm();
379  VECTOR2I::extended_type dist_n = ( nearest - m_cursorPos ).SquaredEuclideanNorm();
380 
381  if( dist_n <= dist_a && dist_n < dist_b )
382  {
383  l.Remove( i + 1, -1 );
384  l.Append( nearest );
385  l.Simplify();
386  found = true;
387  break;
388  }
389  }
390 
391  if( found )
392  {
393  aWalkPath = aInitialPath;
394  aWalkPath.SetShape( l );
395  }
396  }
397 
398  aWalkPath.Line().Simplify();
399 
400  if( aWalkPath.SegmentCount() < 1 )
401  return STUCK;
402  if( aWalkPath.CPoint( -1 ) != aInitialPath.CPoint( -1 ) )
403  return ALMOST_DONE;
404  if( aWalkPath.CPoint( 0 ) != aInitialPath.CPoint( 0 ) )
405  return STUCK;
406 
407  WALKAROUND_STATUS st = s_ccw == DONE || s_cw == DONE ? DONE : STUCK;
408 
409  if( st == DONE )
410  {
411  if( aOptimize )
413  }
414 
415  return st;
416 }
VECTOR2_TRAITS< int >::extended_type extended_type
Definition: vector2d.h:76
SHAPE_LINE_CHAIN & Simplify(bool aRemoveColinear=true)
Function Simplify()
VECTOR2I m_cursorPos
WALKAROUND_STATUS singleStep(LINE &aPath, bool aWindingDirection)
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
NODE::OPT_OBSTACLE m_currentObstacle[2]
static bool Optimize(LINE *aLine, int aEffortLevel, NODE *aWorld, const VECTOR2I aV=VECTOR2I(0, 0))
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute a point on the segment (this) that is closest to point aP.
Definition: seg.h:422
void start(const LINE &aInitialPath)
void Remove(int aStartIndex, int aEndIndex)
Function Remove()
int SegmentCount() const
Function SegmentCount()
Definition: seg.h:41
SEG Segment(int aIndex)
Function Segment()
NODE::OPT_OBSTACLE nearestObstacle(const LINE &aPath)
Reduce corner cost by merging obtuse segments.
SHAPE_LINE_CHAIN.
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:427
VECTOR2I A
Definition: seg.h:49
VECTOR2I B
Definition: seg.h:50

References SEG::A, ALMOST_DONE, SHAPE_LINE_CHAIN::Append(), SEG::B, PNS::NODE::CheckColliding(), PNS::LINE::CLine(), PNS::LINE::CPoint(), DONE, PNS::LINE::EndsWithVia(), IN_PROGRESS, SHAPE_LINE_CHAIN::Length(), PNS::LINE::Line(), m_currentObstacle, m_cursorApproachMode, m_cursorPos, m_forceCw, m_forceLongerPath, m_forceSingleDirection, m_forceWinding, m_itemMask, m_iteration, m_iterationLimit, m_recursiveBlockageCount, m_world, PNS::OPTIMIZER::MERGE_OBTUSE, nearestObstacle(), SEG::NearestPoint(), PNS::OPTIMIZER::Optimize(), PNS::LINE::PointCount(), SHAPE_LINE_CHAIN::Remove(), SHAPE_LINE_CHAIN::Segment(), PNS::LINE::SegmentCount(), SHAPE_LINE_CHAIN::SegmentCount(), PNS::LINE::SetShape(), SHAPE_LINE_CHAIN::Simplify(), singleStep(), start(), STUCK, and PNS::LINE::Via().

Referenced by PNS::DIFF_PAIR_PLACER::attemptWalk(), PNS::SHOVE::onCollidingSolid(), PNS::LINE_PLACER::rhShoveOnly(), PNS::LINE_PLACER::rhWalkOnly(), and PNS::DRAGGER::tryWalkaround().

◆ Route() [2/2]

const WALKAROUND::RESULT PNS::WALKAROUND::Route ( const LINE aInitialPath)

Definition at line 178 of file pns_walkaround.cpp.

179 {
180  LINE path_cw( aInitialPath ), path_ccw( aInitialPath );
181  WALKAROUND_STATUS s_cw = IN_PROGRESS, s_ccw = IN_PROGRESS;
182  SHAPE_LINE_CHAIN best_path;
183  RESULT result;
184 
185  // special case for via-in-the-middle-of-track placement
186  if( aInitialPath.PointCount() <= 1 )
187  {
188  if( aInitialPath.EndsWithVia() && m_world->CheckColliding( &aInitialPath.Via(), m_itemMask ) )
189  return RESULT( STUCK, STUCK );
190 
191  return RESULT( DONE, DONE, aInitialPath, aInitialPath );
192  }
193 
194  start( aInitialPath );
195 
196  m_currentObstacle[0] = m_currentObstacle[1] = nearestObstacle( aInitialPath );
198 
199  result.lineCw = aInitialPath;
200  result.lineCcw = aInitialPath;
201 
202  if( m_forceWinding )
203  {
204  s_cw = m_forceCw ? IN_PROGRESS : STUCK;
205  s_ccw = m_forceCw ? STUCK : IN_PROGRESS;
206  m_forceSingleDirection = true;
207  } else {
208  m_forceSingleDirection = false;
209  }
210 
211  while( m_iteration < m_iterationLimit )
212  {
213  if( s_cw != STUCK )
214  s_cw = singleStep( path_cw, true );
215 
216  if( s_ccw != STUCK )
217  s_ccw = singleStep( path_ccw, false );
218 
219  auto old = path_cw.CLine();
220 
221  if( clipToLoopStart( path_cw.Line() ) )
222  s_cw = ALMOST_DONE;
223 
224  if( clipToLoopStart( path_ccw.Line() ) )
225  s_ccw = ALMOST_DONE;
226 
227 
228  if( s_cw != IN_PROGRESS )
229  {
230  result.lineCw = path_cw;
231  result.statusCw = s_cw;
232  }
233 
234  if( s_ccw != IN_PROGRESS )
235  {
236  result.lineCcw = path_ccw;
237  result.statusCcw = s_ccw;
238  }
239 
240  if( s_cw != IN_PROGRESS && s_ccw != IN_PROGRESS )
241  break;
242 
243  m_iteration++;
244  }
245 
246  if( s_cw == IN_PROGRESS )
247  {
248  result.lineCw = path_cw;
249  result.statusCw = ALMOST_DONE;
250  }
251 
252  if( s_ccw == IN_PROGRESS )
253  {
254  result.lineCcw = path_ccw;
255  result.statusCcw = ALMOST_DONE;
256  }
257 
258  result.lineCw.Line().Simplify();
259  result.lineCcw.Line().Simplify();
260 
261  if( result.lineCw.SegmentCount() < 1 || result.lineCw.CPoint( 0 ) != aInitialPath.CPoint( 0 ) )
262  {
263  result.statusCw = STUCK;
264  }
265 
266  if( result.lineCw.PointCount() > 0 && result.lineCw.CPoint( -1 ) != aInitialPath.CPoint( -1 ) )
267  {
268  result.statusCw = ALMOST_DONE;
269  }
270 
271  if( result.lineCcw.SegmentCount() < 1 || result.lineCcw.CPoint( 0 ) != aInitialPath.CPoint( 0 ) )
272  {
273  result.statusCcw = STUCK;
274  }
275 
276  if( result.lineCcw.PointCount() > 0 && result.lineCcw.CPoint( -1 ) != aInitialPath.CPoint( -1 ) )
277  {
278  result.statusCcw = ALMOST_DONE;
279  }
280 
281  return result;
282 }
bool clipToLoopStart(SHAPE_LINE_CHAIN &l)
WALKAROUND_STATUS singleStep(LINE &aPath, bool aWindingDirection)
NODE::OPT_OBSTACLE m_currentObstacle[2]
void start(const LINE &aInitialPath)
NODE::OPT_OBSTACLE nearestObstacle(const LINE &aPath)
SHAPE_LINE_CHAIN.
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:427

References ALMOST_DONE, PNS::NODE::CheckColliding(), PNS::clipToLoopStart(), PNS::LINE::CPoint(), DONE, PNS::LINE::EndsWithVia(), IN_PROGRESS, PNS::LINE::Line(), PNS::WALKAROUND::RESULT::lineCcw, PNS::WALKAROUND::RESULT::lineCw, m_currentObstacle, m_forceCw, m_forceSingleDirection, m_forceWinding, m_itemMask, m_iteration, m_iterationLimit, m_recursiveBlockageCount, m_world, nearestObstacle(), PNS::LINE::PointCount(), PNS::LINE::SegmentCount(), SHAPE_LINE_CHAIN::Simplify(), singleStep(), start(), PNS::WALKAROUND::RESULT::statusCcw, PNS::WALKAROUND::RESULT::statusCw, STUCK, and PNS::LINE::Via().

◆ Router()

◆ SetApproachCursor()

void PNS::WALKAROUND::SetApproachCursor ( bool  aEnabled,
const VECTOR2I aPos 
)
inline

Definition at line 117 of file pns_walkaround.h.

118  {
119  m_cursorPos = aPos;
120  m_cursorApproachMode = aEnabled;
121  }
VECTOR2I m_cursorPos

References m_cursorApproachMode, and m_cursorPos.

Referenced by PNS::LINE_PLACER::rhShoveOnly().

◆ SetDebugDecorator()

void PNS::ALGO_BASE::SetDebugDecorator ( DEBUG_DECORATOR aDecorator)
inlineinherited

Assign a debug decorator allowing this algo to draw extra graphics for visual debugging.

Definition at line 73 of file pns_algo_base.h.

74  {
75  m_debugDecorator = aDecorator;
76  }
DEBUG_DECORATOR * m_debugDecorator
Definition: pns_algo_base.h:86

References PNS::ALGO_BASE::m_debugDecorator.

Referenced by PNS::LINE_PLACER::rhShoveOnly(), PNS::LINE_PLACER::rhWalkOnly(), PNS::SHOVE::SHOVE(), and PNS::DRAGGER::tryWalkaround().

◆ SetForceWinding()

void PNS::WALKAROUND::SetForceWinding ( bool  aEnabled,
bool  aCw 
)
inline

Definition at line 123 of file pns_walkaround.h.

124  {
125  m_forceCw = aCw;
126  m_forceWinding = aEnabled;
127  }

References m_forceCw, and m_forceWinding.

◆ SetItemMask()

void PNS::WALKAROUND::SetItemMask ( int  aMask)
inline

Definition at line 101 of file pns_walkaround.h.

102  {
103  m_itemMask = aMask;
104  }

References m_itemMask.

◆ SetIterationLimit()

void PNS::WALKAROUND::SetIterationLimit ( const int  aIterLimit)
inline

◆ SetLogger()

void PNS::ALGO_BASE::SetLogger ( LOGGER aLogger)
inlineinherited

Definition at line 65 of file pns_algo_base.h.

66  {
67  m_logger = aLogger;
68  }
LOGGER * m_logger
Definition: pns_algo_base.h:88

References PNS::ALGO_BASE::m_logger.

Referenced by PNS::LINE_PLACER::rhShoveOnly(), PNS::LINE_PLACER::rhWalkOnly(), and PNS::DRAGGER::tryWalkaround().

◆ SetSingleDirection()

void PNS::WALKAROUND::SetSingleDirection ( bool  aForceSingleDirection)
inline

Definition at line 106 of file pns_walkaround.h.

107  {
108  m_forceSingleDirection = aForceSingleDirection;
109  m_forceLongerPath = aForceSingleDirection;
110  }

References m_forceLongerPath, and m_forceSingleDirection.

Referenced by PNS::SHOVE::onCollidingSolid().

◆ SetSingleDirection2()

void PNS::WALKAROUND::SetSingleDirection2 ( bool  aForceSingleDirection)
inline

Definition at line 112 of file pns_walkaround.h.

113  {
114  m_forceSingleDirection = aForceSingleDirection;
115  }

References m_forceSingleDirection.

◆ SetSolidsOnly()

void PNS::WALKAROUND::SetSolidsOnly ( bool  aSolidsOnly)
inline

◆ Settings()

◆ SetWorld()

void PNS::WALKAROUND::SetWorld ( NODE aNode)
inline

Definition at line 83 of file pns_walkaround.h.

84  {
85  m_world = aNode;
86  }

References m_world.

Referenced by PNS::LINE_PLACER::rhShoveOnly().

◆ singleStep()

WALKAROUND::WALKAROUND_STATUS PNS::WALKAROUND::singleStep ( LINE aPath,
bool  aWindingDirection 
)
private

Definition at line 55 of file pns_walkaround.cpp.

57 {
58  OPT<OBSTACLE>& current_obs =
59  aWindingDirection ? m_currentObstacle[0] : m_currentObstacle[1];
60 
61  if( !current_obs )
62  return DONE;
63 
64  SHAPE_LINE_CHAIN path_walk[2];
65 
66  if( aPath.PointCount() > 1 )
67  {
68  VECTOR2I last = aPath.CPoint( -1 );
69 
70  if( ( current_obs->m_hull ).PointInside( last ) || ( current_obs->m_hull ).PointOnEdge( last ) )
71  {
73 
74  if( m_recursiveBlockageCount < 3 )
75  aPath.Line().Append( current_obs->m_hull.NearestPoint( last ) );
76  else
77  {
78  aPath = aPath.ClipToNearestObstacle( m_world );
79  return DONE;
80  }
81  }
82  }
83 
84  aPath.Walkaround( current_obs->m_hull, path_walk[0],
85  aWindingDirection );
86  aPath.Walkaround( current_obs->m_hull, path_walk[1],
87  !aWindingDirection );
88 
89  if( !aPath.Walkaround( current_obs->m_hull, path_walk[1], !aWindingDirection ) )
90  return STUCK;
91 
92  auto l =aPath.CLine();
93 
94 #if 0
95  if( m_logger )
96  {
97  m_logger->NewGroup( aWindingDirection ? "walk-cw" : "walk-ccw", m_iteration );
98  m_logger->Log( &path_walk[0], 0, "path_walk" );
99  m_logger->Log( &path_pre[0], 1, "path_pre" );
100  m_logger->Log( &path_post[0], 4, "path_post" );
101  m_logger->Log( &current_obs->m_hull, 2, "hull" );
102  m_logger->Log( current_obs->m_item, 3, "item" );
103  }
104 #endif
105 
106  if ( Dbg() )
107  {
108  Dbg()->BeginGroup("hull/walk");
109  char name[128];
110  snprintf(name, sizeof(name), "hull-%s-%d", aWindingDirection ? "cw" : "ccw", m_iteration );
111  Dbg()->AddLine( current_obs->m_hull, 1, 1, name);
112  snprintf(name, sizeof(name), "path-%s-%d", aWindingDirection ? "cw" : "ccw", m_iteration );
113  Dbg()->AddLine( aPath.CLine(), 2, 1, name );
114  Dbg()->EndGroup();
115  }
116 
117  int len_pre = path_walk[0].Length();
118  int len_alt = path_walk[1].Length();
119 
120  LINE walk_path( aPath, path_walk[1] );
121 
122  bool alt_collides = static_cast<bool>( m_world->CheckColliding( &walk_path, m_itemMask ) );
123 
124  SHAPE_LINE_CHAIN pnew;
125 
126  /*if( !m_forceLongerPath && len_alt < len_pre && !alt_collides && !prev_recursive )
127  {
128  pnew = path_pre[1];
129  pnew.Append( path_walk[1] );
130  pnew.Append( path_post[1] );
131 
132  if( !path_post[1].PointCount() || !path_walk[1].PointCount() )
133  current_obs = nearestObstacle( LINE( aPath, path_pre[1] ) );
134  else
135  current_obs = nearestObstacle( LINE( aPath, path_post[1] ) );
136  }
137  else*/
138  {
139  pnew = path_walk[0];
140  current_obs = nearestObstacle( LINE( aPath, path_walk[0] ) );
141  }
142 
143  pnew.Simplify();
144  aPath.SetShape( pnew );
145 
146  return IN_PROGRESS;
147 }
long long int Length() const
Function Length()
virtual void AddLine(const SHAPE_LINE_CHAIN &aLine, int aType=0, int aWidth=0, const std::string aName="")
LOGGER * m_logger
Definition: pns_algo_base.h:88
NODE::OPT_OBSTACLE m_currentObstacle[2]
DEBUG_DECORATOR * Dbg() const
Definition: pns_algo_base.h:78
virtual void BeginGroup(const std::string name)
NODE::OPT_OBSTACLE nearestObstacle(const LINE &aPath)
const char * name
Definition: DXF_plotter.cpp:59
SHAPE_LINE_CHAIN.
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:427
boost::optional< T > OPT
Definition: optional.h:7
void Log(EVENT_TYPE evt, VECTOR2I pos, const ITEM *item=nullptr)
Definition: pns_logger.cpp:73

References PNS::DEBUG_DECORATOR::AddLine(), SHAPE_LINE_CHAIN::Append(), PNS::DEBUG_DECORATOR::BeginGroup(), PNS::NODE::CheckColliding(), PNS::LINE::CLine(), PNS::LINE::ClipToNearestObstacle(), PNS::LINE::CPoint(), PNS::ALGO_BASE::Dbg(), DONE, PNS::DEBUG_DECORATOR::EndGroup(), IN_PROGRESS, SHAPE_LINE_CHAIN::Length(), PNS::LINE::Line(), PNS::LOGGER::Log(), m_currentObstacle, m_itemMask, m_iteration, PNS::ALGO_BASE::m_logger, m_recursiveBlockageCount, m_world, name, nearestObstacle(), PNS::LINE::PointCount(), PNS::LINE::SetShape(), STUCK, and PNS::LINE::Walkaround().

Referenced by Route().

◆ start()

void PNS::WALKAROUND::start ( const LINE aInitialPath)
private

Definition at line 34 of file pns_walkaround.cpp.

35 {
36  m_iteration = 0;
37  m_iterationLimit = 50;
38 }

References m_iteration, and m_iterationLimit.

Referenced by Route().

◆ VisibleViewArea()

const BOX2I & PNS::ALGO_BASE::VisibleViewArea ( ) const
inherited

Definition at line 39 of file pns_algo_base.cpp.

40 {
41  auto bb = m_router->VisibleViewArea();
42  return m_router->VisibleViewArea();
43 }
ROUTER * m_router
Definition: pns_algo_base.h:87
const BOX2I & VisibleViewArea() const
Definition: pns_router.h:225

References PNS::ALGO_BASE::m_router, and PNS::ROUTER::VisibleViewArea().

Referenced by PNS::SHOVE::runOptimizer().

Member Data Documentation

◆ DefaultIterationLimit

const int PNS::WALKAROUND::DefaultIterationLimit = 50
staticprivate

Definition at line 37 of file pns_walkaround.h.

◆ m_currentObstacle

NODE::OPT_OBSTACLE PNS::WALKAROUND::m_currentObstacle[2]
private

Definition at line 160 of file pns_walkaround.h.

Referenced by Route(), and singleStep().

◆ m_cursorApproachMode

bool PNS::WALKAROUND::m_cursorApproachMode
private

Definition at line 155 of file pns_walkaround.h.

Referenced by Route(), SetApproachCursor(), and WALKAROUND().

◆ m_cursorPos

VECTOR2I PNS::WALKAROUND::m_cursorPos
private

Definition at line 159 of file pns_walkaround.h.

Referenced by Route(), and SetApproachCursor().

◆ m_debugDecorator

DEBUG_DECORATOR* PNS::ALGO_BASE::m_debugDecorator
protectedinherited

Definition at line 86 of file pns_algo_base.h.

Referenced by PNS::ALGO_BASE::Dbg(), and PNS::ALGO_BASE::SetDebugDecorator().

◆ m_forceCw

bool PNS::WALKAROUND::m_forceCw
private

Definition at line 157 of file pns_walkaround.h.

Referenced by Route(), SetForceWinding(), and WALKAROUND().

◆ m_forceLongerPath

bool PNS::WALKAROUND::m_forceLongerPath
private

Definition at line 154 of file pns_walkaround.h.

Referenced by Route(), SetSingleDirection(), and WALKAROUND().

◆ m_forceSingleDirection

bool PNS::WALKAROUND::m_forceSingleDirection
private

Definition at line 154 of file pns_walkaround.h.

Referenced by Route(), SetSingleDirection(), SetSingleDirection2(), and WALKAROUND().

◆ m_forceUniqueWindingDirection

bool PNS::WALKAROUND::m_forceUniqueWindingDirection
private

Definition at line 158 of file pns_walkaround.h.

Referenced by WALKAROUND().

◆ m_forceWinding

bool PNS::WALKAROUND::m_forceWinding
private

Definition at line 156 of file pns_walkaround.h.

Referenced by Route(), SetForceWinding(), and WALKAROUND().

◆ m_itemMask

int PNS::WALKAROUND::m_itemMask
private

◆ m_iteration

int PNS::WALKAROUND::m_iteration
private

Definition at line 151 of file pns_walkaround.h.

Referenced by Route(), singleStep(), start(), and WALKAROUND().

◆ m_iterationLimit

int PNS::WALKAROUND::m_iterationLimit
private

Definition at line 152 of file pns_walkaround.h.

Referenced by Route(), SetIterationLimit(), and start().

◆ m_logger

LOGGER* PNS::ALGO_BASE::m_logger
protectedinherited

Definition at line 88 of file pns_algo_base.h.

Referenced by PNS::ALGO_BASE::SetLogger(), and singleStep().

◆ m_recursiveBlockageCount

int PNS::WALKAROUND::m_recursiveBlockageCount
private

Definition at line 150 of file pns_walkaround.h.

Referenced by Route(), singleStep(), and WALKAROUND().

◆ m_recursiveCollision

bool PNS::WALKAROUND::m_recursiveCollision[2]
private

Definition at line 161 of file pns_walkaround.h.

Referenced by WALKAROUND().

◆ m_restrictedSet

std::set<ITEM*> PNS::WALKAROUND::m_restrictedSet
private

Definition at line 162 of file pns_walkaround.h.

Referenced by nearestObstacle(), and RestrictToSet().

◆ m_router

◆ m_world

NODE* PNS::WALKAROUND::m_world
private

Definition at line 148 of file pns_walkaround.h.

Referenced by nearestObstacle(), Route(), SetWorld(), and singleStep().


The documentation for this class was generated from the following files: