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
 

Returns the instance of our router

More...
 
ROUTING_SETTINGSSettings () const
 

Returns current router settings

More...
 
virtual LOGGERLogger ()
 

Returns the logger object, allowing to dump geometry to a file.

More...
 
void SetLogger (LOGGER *aLogger)
 
void SetDebugDecorator (DEBUG_DECORATOR *aDecorator)
 Function SetDebugDecorator. More...
 
DEBUG_DECORATORDbg () 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 60 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;
56  }
static const int DefaultIterationLimit
ALGO_BASE(ROUTER *aRouter)
Definition: pns_algo_base.h:42
bool m_recursiveCollision[2]

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

◆ ~WALKAROUND()

PNS::WALKAROUND::~WALKAROUND ( )
inline

Definition at line 58 of file pns_walkaround.h.

58 {};

Member Function Documentation

◆ Dbg()

◆ Logger()

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

Returns the logger object, allowing to dump geometry to a file.

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::DRAGGER::dragWalkaround(), PNS::LINE_PLACER::rhShoveOnly(), PNS::LINE_PLACER::rhWalkOnly(), and PNS::DRAGGER::Start().

◆ 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 *aItem, int aKindMask=ITEM::ANY_T, const std::set< ITEM * > *aRestrictedSet=NULL)
Function NearestObstacle()
Definition: pns_node.cpp:304
std::set< ITEM * > m_restrictedSet
#define NULL
OPT< OBSTACLE > OPT_OBSTACLE
Definition: pns_node.h:148

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 128 of file pns_walkaround.h.

129  {
130  if( aEnabled )
131  m_restrictedSet = aSet;
132  else
133  m_restrictedSet.clear();
134  }
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 303 of file pns_walkaround.cpp.

305 {
306  LINE path_cw( aInitialPath ), path_ccw( aInitialPath );
307  WALKAROUND_STATUS s_cw = IN_PROGRESS, s_ccw = IN_PROGRESS;
308  SHAPE_LINE_CHAIN best_path;
309 
310  // special case for via-in-the-middle-of-track placement
311  if( aInitialPath.PointCount() <= 1 )
312  {
313  if( aInitialPath.EndsWithVia() && m_world->CheckColliding( &aInitialPath.Via(), m_itemMask ) )
314  return STUCK;
315 
316  aWalkPath = aInitialPath;
317  return DONE;
318  }
319 
320  start( aInitialPath );
321 
322  m_currentObstacle[0] = m_currentObstacle[1] = nearestObstacle( aInitialPath );
324 
325  aWalkPath = aInitialPath;
326 
327  if( m_forceWinding )
328  {
329  s_cw = m_forceCw ? IN_PROGRESS : STUCK;
330  s_ccw = m_forceCw ? STUCK : IN_PROGRESS;
331  m_forceSingleDirection = true;
332  } else {
333  m_forceSingleDirection = false;
334  }
335 
336  while( m_iteration < m_iterationLimit )
337  {
338  if( s_cw != STUCK )
339  s_cw = singleStep( path_cw, true );
340 
341  if( s_ccw != STUCK )
342  s_ccw = singleStep( path_ccw, false );
343 
344  if( ( s_cw == DONE && s_ccw == DONE ) || ( s_cw == STUCK && s_ccw == STUCK ) )
345  {
346  int len_cw = path_cw.CLine().Length();
347  int len_ccw = path_ccw.CLine().Length();
348 
349  if( m_forceLongerPath )
350  aWalkPath = ( len_cw > len_ccw ? path_cw : path_ccw );
351  else
352  aWalkPath = ( len_cw < len_ccw ? path_cw : path_ccw );
353 
354  break;
355  }
356  else if( s_cw == DONE && !m_forceLongerPath )
357  {
358  aWalkPath = path_cw;
359  break;
360  }
361  else if( s_ccw == DONE && !m_forceLongerPath )
362  {
363  aWalkPath = path_ccw;
364  break;
365  }
366 
367  m_iteration++;
368  }
369 
371  {
372  int len_cw = path_cw.CLine().Length();
373  int len_ccw = path_ccw.CLine().Length();
374 
375  if( m_forceLongerPath )
376  aWalkPath = ( len_cw > len_ccw ? path_cw : path_ccw );
377  else
378  aWalkPath = ( len_cw < len_ccw ? path_cw : path_ccw );
379  }
380 
382  {
383  // int len_cw = path_cw.GetCLine().Length();
384  // int len_ccw = path_ccw.GetCLine().Length();
385  bool found = false;
386 
387  SHAPE_LINE_CHAIN l = aWalkPath.CLine();
388 
389  for( int i = 0; i < l.SegmentCount(); i++ )
390  {
391  const SEG s = l.Segment( i );
392 
393  VECTOR2I nearest = s.NearestPoint( m_cursorPos );
394  VECTOR2I::extended_type dist_a = ( s.A - m_cursorPos ).SquaredEuclideanNorm();
395  VECTOR2I::extended_type dist_b = ( s.B - m_cursorPos ).SquaredEuclideanNorm();
396  VECTOR2I::extended_type dist_n = ( nearest - m_cursorPos ).SquaredEuclideanNorm();
397 
398  if( dist_n <= dist_a && dist_n < dist_b )
399  {
400  l.Remove( i + 1, -1 );
401  l.Append( nearest );
402  l.Simplify();
403  found = true;
404  break;
405  }
406  }
407 
408  if( found )
409  {
410  aWalkPath = aInitialPath;
411  aWalkPath.SetShape( l );
412  }
413  }
414 
415  aWalkPath.Line().Simplify();
416 
417  if( aWalkPath.SegmentCount() < 1 )
418  return STUCK;
419  if( aWalkPath.CPoint( -1 ) != aInitialPath.CPoint( -1 ) )
420  return ALMOST_DONE;
421  if( aWalkPath.CPoint( 0 ) != aInitialPath.CPoint( 0 ) )
422  return STUCK;
423 
424  WALKAROUND_STATUS st = s_ccw == DONE || s_cw == DONE ? DONE : STUCK;
425 
426  if( st == DONE )
427  {
428  if( aOptimize )
430  }
431 
432  return st;
433 }
VECTOR2_TRAITS< int >::extended_type extended_type
Definition: vector2d.h:77
VECTOR2I m_cursorPos
WALKAROUND_STATUS singleStep(LINE &aPath, bool aWindingDirection)
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
SHAPE_LINE_CHAIN & Simplify()
Function Simplify()
NODE::OPT_OBSTACLE m_currentObstacle[2]
static bool Optimize(LINE *aLine, int aEffortLevel, NODE *aWorld, const VECTOR2I aV=VECTOR2I(0, 0))
a quick shortcut to optmize a line without creating and setting up an optimizer
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Function NearestPoint()
Definition: seg.h:392
void start(const LINE &aInitialPath)
void Remove(int aStartIndex, int aEndIndex)
Function Remove()
int SegmentCount() const
Function SegmentCount()
Definition: seg.h:39
SEG Segment(int aIndex)
Function Segment()
NODE::OPT_OBSTACLE nearestObstacle(const LINE &aPath)
SHAPE_LINE_CHAIN.
OPT_OBSTACLE CheckColliding(const ITEM *aItem, int aKindMask=ITEM::ANY_T)
Function CheckColliding()
Definition: pns_node.cpp:427
VECTOR2I A
Definition: seg.h:47
VECTOR2I B
Definition: seg.h:48

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::DRAGGER::dragWalkaround(), PNS::SHOVE::onCollidingSolid(), PNS::LINE_PLACER::rhShoveOnly(), and PNS::LINE_PLACER::rhWalkOnly().

◆ Route() [2/2]

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

Definition at line 183 of file pns_walkaround.cpp.

184 {
185  LINE path_cw( aInitialPath ), path_ccw( aInitialPath );
186  WALKAROUND_STATUS s_cw = IN_PROGRESS, s_ccw = IN_PROGRESS;
187  SHAPE_LINE_CHAIN best_path;
188  RESULT result;
189 
190  // special case for via-in-the-middle-of-track placement
191  if( aInitialPath.PointCount() <= 1 )
192  {
193  if( aInitialPath.EndsWithVia() && m_world->CheckColliding( &aInitialPath.Via(), m_itemMask ) )
194  return RESULT( STUCK, STUCK );
195 
196  return RESULT( DONE, DONE, aInitialPath, aInitialPath );
197  }
198 
199  start( aInitialPath );
200 
201  m_currentObstacle[0] = m_currentObstacle[1] = nearestObstacle( aInitialPath );
203 
204  result.lineCw = aInitialPath;
205  result.lineCcw = aInitialPath;
206 
207  if( m_forceWinding )
208  {
209  s_cw = m_forceCw ? IN_PROGRESS : STUCK;
210  s_ccw = m_forceCw ? STUCK : IN_PROGRESS;
211  m_forceSingleDirection = true;
212  } else {
213  m_forceSingleDirection = false;
214  }
215 
216  while( m_iteration < m_iterationLimit )
217  {
218  if( s_cw != STUCK )
219  s_cw = singleStep( path_cw, true );
220 
221  if( s_ccw != STUCK )
222  s_ccw = singleStep( path_ccw, false );
223 
224  //Dbg()->AddLine( path_cw.CLine(), 2, 10000 );
225 
226 
227  //printf("iter %d s_cw %d s_ccw %d\n", m_iteration, s_cw, s_ccw );
228 
229  auto old = path_cw.CLine();
230 
231  if( clipToLoopStart( path_cw.Line() ))
232  {
233  //printf("ClipCW\n");
234  //Dbg()->AddLine( old, 1, 40000 );
235  s_cw = ALMOST_DONE;
236  }
237 
238  if( clipToLoopStart( path_ccw.Line() ))
239  {
240  //printf("ClipCCW\n");
241  s_ccw = ALMOST_DONE;
242  }
243 
244 
245  if( s_cw != IN_PROGRESS )
246  {
247  result.lineCw = path_cw;
248  result.statusCw = s_cw;
249  }
250 
251  if( s_ccw != IN_PROGRESS )
252  {
253  result.lineCcw = path_ccw;
254  result.statusCcw = s_ccw;
255  }
256 
257  if( s_cw != IN_PROGRESS && s_ccw != IN_PROGRESS )
258  break;
259 
260  m_iteration++;
261  }
262 
263  if( s_cw == IN_PROGRESS )
264  {
265  result.lineCw = path_cw;
266  result.statusCw = ALMOST_DONE;
267  }
268 
269  if( s_ccw == IN_PROGRESS )
270  {
271  result.lineCcw = path_ccw;
272  result.statusCcw = ALMOST_DONE;
273  }
274 
275  result.lineCw.Line().Simplify();
276  result.lineCcw.Line().Simplify();
277 
278  if( result.lineCw.SegmentCount() < 1 || result.lineCw.CPoint( 0 ) != aInitialPath.CPoint( 0 ) )
279  {
280  result.statusCw = STUCK;
281  }
282 
283  if( result.lineCw.PointCount() > 0 && result.lineCw.CPoint( -1 ) != aInitialPath.CPoint( -1 ) )
284  {
285  result.statusCw = ALMOST_DONE;
286  }
287 
288  if( result.lineCcw.SegmentCount() < 1 || result.lineCcw.CPoint( 0 ) != aInitialPath.CPoint( 0 ) )
289  {
290  result.statusCcw = STUCK;
291  }
292 
293  if( result.lineCcw.PointCount() > 0 && result.lineCcw.CPoint( -1 ) != aInitialPath.CPoint( -1 ) )
294  {
295  result.statusCcw = ALMOST_DONE;
296  }
297 
298  return result;
299 }
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)
Function CheckColliding()
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 116 of file pns_walkaround.h.

117  {
118  m_cursorPos = aPos;
119  m_cursorApproachMode = aEnabled;
120  }
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

Function SetDebugDecorator.

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

Definition at line 72 of file pns_algo_base.h.

73  {
74  m_debugDecorator = aDecorator;
75  }
DEBUG_DECORATOR * m_debugDecorator
Definition: pns_algo_base.h:83

References PNS::ALGO_BASE::m_debugDecorator.

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

◆ SetForceWinding()

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

Definition at line 122 of file pns_walkaround.h.

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

References m_forceCw, and m_forceWinding.

◆ SetItemMask()

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

Definition at line 100 of file pns_walkaround.h.

101  {
102  m_itemMask = aMask;
103  }

References m_itemMask.

◆ SetIterationLimit()

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

◆ SetLogger()

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

Definition at line 62 of file pns_algo_base.h.

63  {
64  m_logger = aLogger;
65  }
LOGGER * m_logger
Definition: pns_algo_base.h:85

References PNS::ALGO_BASE::m_logger.

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

◆ SetSingleDirection()

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

Definition at line 105 of file pns_walkaround.h.

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

References m_forceLongerPath, and m_forceSingleDirection.

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

◆ SetSingleDirection2()

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

Definition at line 111 of file pns_walkaround.h.

112  {
113  m_forceSingleDirection = aForceSingleDirection;
114  }

References m_forceSingleDirection.

◆ SetSolidsOnly()

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

◆ Settings()

◆ SetWorld()

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

Definition at line 82 of file pns_walkaround.h.

83  {
84  m_world = aNode;
85  }

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

References PNS::DEBUG_DECORATOR::AddLine(), SHAPE_LINE_CHAIN::Append(), PNS::NODE::CheckColliding(), PNS::LINE::CLine(), PNS::LINE::ClipToNearestObstacle(), PNS::LINE::CPoint(), PNS::ALGO_BASE::Dbg(), DONE, 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::LOGGER::NewGroup(), 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().

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 159 of file pns_walkaround.h.

Referenced by Route(), and singleStep().

◆ m_cursorApproachMode

bool PNS::WALKAROUND::m_cursorApproachMode
private

Definition at line 154 of file pns_walkaround.h.

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

◆ m_cursorPos

VECTOR2I PNS::WALKAROUND::m_cursorPos
private

Definition at line 158 of file pns_walkaround.h.

Referenced by Route(), and SetApproachCursor().

◆ m_debugDecorator

DEBUG_DECORATOR* PNS::ALGO_BASE::m_debugDecorator
protectedinherited

Definition at line 83 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 156 of file pns_walkaround.h.

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

◆ m_forceLongerPath

bool PNS::WALKAROUND::m_forceLongerPath
private

Definition at line 153 of file pns_walkaround.h.

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

◆ m_forceSingleDirection

bool PNS::WALKAROUND::m_forceSingleDirection
private

Definition at line 153 of file pns_walkaround.h.

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

◆ m_forceUniqueWindingDirection

bool PNS::WALKAROUND::m_forceUniqueWindingDirection
private

Definition at line 157 of file pns_walkaround.h.

◆ m_forceWinding

bool PNS::WALKAROUND::m_forceWinding
private

Definition at line 155 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 150 of file pns_walkaround.h.

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

◆ m_iterationLimit

int PNS::WALKAROUND::m_iterationLimit
private

Definition at line 151 of file pns_walkaround.h.

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

◆ m_logger

LOGGER* PNS::ALGO_BASE::m_logger
protectedinherited

Definition at line 85 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 149 of file pns_walkaround.h.

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

◆ m_recursiveCollision

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

Definition at line 160 of file pns_walkaround.h.

Referenced by WALKAROUND().

◆ m_restrictedSet

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

Definition at line 161 of file pns_walkaround.h.

Referenced by nearestObstacle(), and RestrictToSet().

◆ m_router

ROUTER* PNS::ALGO_BASE::m_router
protectedinherited

Definition at line 84 of file pns_algo_base.h.

Referenced by PNS::ALGO_BASE::Router(), and PNS::ALGO_BASE::Settings().

◆ m_world

NODE* PNS::WALKAROUND::m_world
private

Definition at line 147 of file pns_walkaround.h.

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


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