134 PNS_DBG(
Dbg(), AddItem, &line,
WHITE, 10000, wxString::Format(
"current (policy %d, stat %d)", i, status ) );
145 PNS_DBG(
Dbg(), Message, wxString::Format(
"no-more-colls pol %d st %d", i, status ) );
151 int clusterMargin = 2 * obstacle->m_clearance + line.Width() ;
155 pendingClusters[ i ] = topo.
AssembleCluster( obstacle->m_item, line.Layer(), 0.0, line.Net(), clusterMargin );
159 pendingClusters[ i ].
m_key =
nullptr;
160 pendingClusters[ i ].
m_items = { obstacle->m_item };
163 PNS_DBG(
Dbg(), AddItem, obstacle->m_item,
BLUE, 10000, wxString::Format(
"col-item owner-depth %d cl-items=%d cl-margin=%d",
static_cast<const NODE*
>( obstacle->m_item->Owner() )->
Depth(), (
int) pendingClusters[i].
m_items.size(), clusterMargin ) );
171 using namespace std::chrono;
172 auto start_time = steady_clock::now();
176 PNS_DBG(
Dbg(), BeginGroup, wxString::Format(
"cluster-details [cw %d]", aCw?1:0 ), 1 );
178 for(
auto& clItem : aCluster.
m_items )
184 auto now = steady_clock::now();
185 auto elapsed = duration_cast<milliseconds>( now - start_time ).count();
187 if( elapsed > timeout_ms )
189 PNS_DBG(
Dbg(), Message, wxString::Format(
"processCluster timeout after %d ms", timeout_ms ) );
196 clItem,
clearance, aLine.Width(), aLine.Layer() );
216 aLine.Line().Simplify2();
218 bool stat = aLine.Walkaround( hull, tmp.
Line(), aCw );
220 PNS_DBG(
Dbg(), AddShape, &hull,
YELLOW, 10000, wxString::Format(
"hull stat %d", stat?1:0 ) );
221 PNS_DBG(
Dbg(), AddItem, &tmp,
RED, 10000, wxString::Format(
"walk stat %d", stat?1:0 ) );
222 PNS_DBG(
Dbg(), AddItem, clItem,
WHITE, 10000, wxString::Format(
"item stat %d", stat?1:0 ) );
230 aLine.SetShape( tmp.
CLine() );
255 LINE path_cw( line ), path_ccw( line );
257 auto st_cw = processCluster( pendingClusters[
WP_SHORTEST], path_cw,
true );
258 auto st_ccw = processCluster( pendingClusters[
WP_SHORTEST], path_ccw,
false );
262 bool cw_coll = st_cw ?
m_world->CheckColliding( &path_cw, opts ).has_value() :
false;
263 bool ccw_coll = st_ccw ?
m_world->CheckColliding( &path_ccw, opts ).has_value() :
false;
265 double lengthFactorCw = (double) path_cw.CLine().Length() / (double)
m_initialLength;
268 PNS_DBG(
Dbg(), AddItem, &path_cw,
RED, 10000, wxString::Format(
"shortest-cw stat %d lf %.1f", st_cw?1:0, lengthFactorCw ) );
269 PNS_DBG(
Dbg(), AddItem, &path_ccw,
BLUE, 10000, wxString::Format(
"shortest-ccw stat %d lf %.1f", st_ccw?1:0, lengthFactorCcw ) );
272 std::optional<LINE> shortest;
273 std::optional<LINE> shortest_alt;
276 if( st_cw && st_ccw )
278 if( ( !cw_coll && !ccw_coll ) || ( cw_coll && ccw_coll ) )
280 if( path_cw.CLine().Length() > path_ccw.
CLine().
Length() )
283 shortest_alt = path_cw;
288 shortest_alt = path_ccw;
302 bool anyColliding =
false;
304 if( shortest.has_value() )
306 PNS_DBG(
Dbg(), AddItem, &shortest.value(),
RED, 10000, wxString::Format(
"shortest-l" ) );
310 std::set<PNS::OBSTACLE> obstacles;
312 if( shortest->Collide( item,
m_world, shortest->Layer(), &ctx ) )
319 PNS_DBG(
Dbg(), Message, wxString::Format(
"check-back cc %d items %d coll %d", (
int) pendingClusters[
WP_SHORTEST ].m_items.size(), (
int)
m_processedItems.size(), anyColliding ? 1: 0 ) );
324 shortest = std::move( shortest_alt );
336 for(
auto item : pendingClusters[
WP_SHORTEST ].m_items )
366 start( aInitialPath );
370 PNS_DBG(
Dbg(), AddItem, &aInitialPath,
WHITE, 10000, wxT(
"initial-path" ) );
374 bool finished =
false;
377 bool stillInProgress =
false;
393 double lengthFactor = (double) ln.CLine().Length() / (double) aInitialPath.
CLine().
Length();
404 PNS_DBG(
Dbg(), Message, wxString::Format(
"check-wp iter %d st %d i %d lf %.1f",
m_iteration, st, pol, lengthFactor ) );
407 stillInProgress =
true;
410 if( !stillInProgress || finished )
426 if( ln.SegmentCount() < 1 || ln.CPoint( 0 ) != aInitialPath.
CPoint( 0 ) )
431 if( ln.PointCount() > 0 && ln.CLastPoint() != aInitialPath.
CLastPoint() )
436 PNS_DBG(
Dbg(), Message, wxString::Format(
"stat=%d", st ) );
wxString result
Test unit parsing edge cases and error handling.