107 PNS_DBG(
Dbg(), AddItem, &line,
WHITE, 10000, wxString::Format(
"current (policy %d, stat %d)", i, status ) );
118 PNS_DBG(
Dbg(), Message, wxString::Format(
"no-more-colls pol %d st %d", i, status ) );
124 pendingClusters[ i ] = topo.
AssembleCluster( obstacle->m_item, line.Layer(), 0.0, line.Net() );
125 PNS_DBG(
Dbg(), AddItem, obstacle->m_item,
BLUE, 10000, wxString::Format(
"col-item owner-depth %d cl-items=%d",
static_cast<const NODE*
>( obstacle->m_item->Owner() )->
Depth(), (
int) pendingClusters[i].
m_items.size() ) );
133 using namespace std::chrono;
134 auto start_time = steady_clock::now();
138 PNS_DBG(
Dbg(), BeginGroup, wxString::Format(
"cluster-details [cw %d]", aCw?1:0 ), 1 );
140 for(
auto& clItem : aCluster.
m_items )
146 auto now = steady_clock::now();
147 auto elapsed = duration_cast<milliseconds>( now - start_time ).count();
149 if( elapsed > timeout_ms )
151 PNS_DBG(
Dbg(), Message, wxString::Format(
"processCluster timeout after %d ms", timeout_ms ) );
158 clItem,
clearance, aLine.Width(), aLine.Layer() );
177 aLine.Line().Simplify2();
179 bool stat = aLine.Walkaround( hull, tmp.
Line(), aCw );
181 PNS_DBG(
Dbg(), AddShape, &hull,
YELLOW, 10000, wxString::Format(
"hull stat %d", stat?1:0 ) );
182 PNS_DBG(
Dbg(), AddItem, &tmp,
RED, 10000, wxString::Format(
"walk stat %d", stat?1:0 ) );
183 PNS_DBG(
Dbg(), AddItem, clItem,
WHITE, 10000, wxString::Format(
"item stat %d", stat?1:0 ) );
191 aLine.SetShape( tmp.
CLine() );
216 LINE path_cw( line ), path_ccw( line );
218 auto st_cw = processCluster( pendingClusters[
WP_SHORTEST], path_cw,
true );
219 auto st_ccw = processCluster( pendingClusters[
WP_SHORTEST], path_ccw,
false );
221 bool cw_coll = st_cw ?
m_world->CheckColliding( &path_cw ).has_value() :
false;
222 bool ccw_coll = st_ccw ?
m_world->CheckColliding( &path_ccw ).has_value() :
false;
224 double lengthFactorCw = (double) path_cw.CLine().Length() / (double)
m_initialLength;
227 PNS_DBG(
Dbg(), AddItem, &path_cw,
RED, 10000, wxString::Format(
"shortest-cw stat %d lf %.1f", st_cw?1:0, lengthFactorCw ) );
228 PNS_DBG(
Dbg(), AddItem, &path_ccw,
BLUE, 10000, wxString::Format(
"shortest-ccw stat %d lf %.1f", st_ccw?1:0, lengthFactorCcw ) );
231 std::optional<LINE> shortest;
232 std::optional<LINE> shortest_alt;
235 if( st_cw && st_ccw )
237 if( ( !cw_coll && !ccw_coll ) || ( cw_coll && ccw_coll ) )
239 if( path_cw.CLine().Length() > path_ccw.
CLine().
Length() )
242 shortest_alt = path_cw;
247 shortest_alt = path_ccw;
261 bool anyColliding =
false;
263 if( shortest.has_value() )
265 PNS_DBG(
Dbg(), AddItem, &shortest.value(),
RED, 10000, wxString::Format(
"shortest-l" ) );
269 std::set<PNS::OBSTACLE> obstacles;
271 if( shortest->Collide( item,
m_world, shortest->Layer(), &ctx ) )
278 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 ) );
283 shortest = std::move( shortest_alt );
295 for(
auto item : pendingClusters[
WP_SHORTEST ].m_items )
325 start( aInitialPath );
329 PNS_DBG(
Dbg(), AddItem, &aInitialPath,
WHITE, 10000, wxT(
"initial-path" ) );
335 bool stillInProgress =
false;
344 double lengthFactor = (double) ln.CLine().Length() / (double) aInitialPath.
CLine().
Length();
355 PNS_DBG(
Dbg(), Message, wxString::Format(
"check-wp iter %d st %d i %d lf %.1f",
m_iteration, st, pol, lengthFactor ) );
358 stillInProgress =
true;
362 if( !stillInProgress )
378 if( ln.SegmentCount() < 1 || ln.CPoint( 0 ) != aInitialPath.
CPoint( 0 ) )
383 if( ln.PointCount() > 0 && ln.CLastPoint() != aInitialPath.
CLastPoint() )
388 PNS_DBG(
Dbg(), Message, wxString::Format(
"stat=%d", st ) );
wxString result
Test unit parsing edge cases and error handling.