86 if(
SOLID* solid = dyn_cast<SOLID*>( item ) )
115 PNS_DBG(
Dbg(), AddItem, &line,
WHITE, 10000, wxString::Format(
"current (policy %d, stat %d)", i, status ) );
126 PNS_DBG(
Dbg(), Message, wxString::Format(
"no-more-colls pol %d st %d", i, status ) );
132 pendingClusters[ i ] = topo.
AssembleCluster( obstacle->m_item, line.Layer(), 0.0, line.Net() );
133 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() ) );
141 PNS_DBG(
Dbg(), BeginGroup, wxString::Format(
"cluster-details [cw %d]", aCw?1:0 ), 1 );
143 for(
auto& clItem : aCluster.
m_items )
146 SHAPE_LINE_CHAIN hull = clItem->Hull( clearance + 1000, aLine.Width(), aLine.Layer() );
160 bool stat = aLine.Walkaround( hull, tmp.
Line(), aCw );
162 PNS_DBG(
Dbg(), AddShape, &hull,
YELLOW, 10000, wxString::Format(
"hull stat %d", stat?1:0 ) );
163 PNS_DBG(
Dbg(), AddItem, &tmp,
RED, 10000, wxString::Format(
"walk stat %d", stat?1:0 ) );
164 PNS_DBG(
Dbg(), AddItem, clItem,
WHITE, 10000, wxString::Format(
"item stat %d", stat?1:0 ) );
172 aLine.SetShape( tmp.
CLine() );
197 LINE path_cw( line ), path_ccw( line );
199 auto st_cw = processCluster( pendingClusters[
WP_SHORTEST], path_cw,
true );
200 auto st_ccw = processCluster( pendingClusters[
WP_SHORTEST], path_ccw,
false );
205 double lengthFactorCw = (double) path_cw.CLine().Length() / (double)
m_initialLength;
208 PNS_DBG(
Dbg(), AddItem, &path_cw,
RED, 10000, wxString::Format(
"shortest-cw stat %d lf %.1f", st_cw?1:0, lengthFactorCw ) );
209 PNS_DBG(
Dbg(), AddItem, &path_ccw,
BLUE, 10000, wxString::Format(
"shortest-ccw stat %d lf %.1f", st_ccw?1:0, lengthFactorCcw ) );
212 std::optional<LINE> shortest;
213 std::optional<LINE> shortest_alt;
216 if( st_cw && st_ccw )
218 if( !cw_coll && !ccw_coll || ( cw_coll && ccw_coll) )
220 if( path_cw.CLine().Length() > path_ccw.
CLine().
Length() )
223 shortest_alt = path_cw;
228 shortest_alt = path_ccw;
242 bool anyColliding =
false;
248 if( shortest->Collide( item,
m_world, shortest->Layer() ) )
260 shortest = shortest_alt;
301 start( aInitialPath );
303 PNS_DBG(
Dbg(), AddItem, &aInitialPath,
WHITE, 10000, wxT(
"initial-path" ) );
309 bool stillInProgress =
false;
329 PNS_DBG(
Dbg(), Message, wxString::Format(
"check-wp iter %d st %d i %d lf %.1f",
m_iteration, st, pol, lengthFactor ) );
332 stillInProgress =
true;
336 if( !stillInProgress )
352 if( ln.SegmentCount() < 1 || ln.CPoint( 0 ) != aInitialPath.
CPoint( 0 ) )
357 if( ln.PointCount() > 0 && ln.CPoint( -1 ) != aInitialPath.
CPoint( -1 ) )
362 PNS_DBG(
Dbg(), Message, wxString::Format(
"stat=%d", st ) );
375 for (
auto p : aPolicies )
constexpr coord_type GetLeft() const
constexpr coord_type GetRight() const
constexpr coord_type GetTop() const
constexpr coord_type GetBottom() const
@ ROUNDED_90
H/V with filleted corners.
@ MITERED_90
H/V only (90-degree corners)
ROUTING_SETTINGS & Settings() const
Return the logger object, allowing to dump geometry to a file.
DEBUG_DECORATOR * Dbg() const
Base class for PNS router board items.
virtual HOLE * Hole() const
virtual bool HasHole() const
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
const VECTOR2I & CPoint(int aIdx) const
const SHAPE_LINE_CHAIN & CLine() const
SHAPE_LINE_CHAIN & Line()
virtual void ClearLinks()
Return the number of segments that were assembled together to form this line.
Keep the router "world" - i.e.
int GetClearance(const ITEM *aA, const ITEM *aB, bool aUseClearanceEpsilon=true) const
Return the pre-set worst case clearance between any pair of items.
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.
std::optional< OBSTACLE > OPT_OBSTACLE
OPT_OBSTACLE NearestObstacle(const LINE *aLine, const COLLISION_SEARCH_OPTIONS &aOpts=COLLISION_SEARCH_OPTIONS())
Follow the line in search of an obstacle that is nearest to the starting to the line's starting point...
DIRECTION_45::CORNER_MODE GetCornerMode() const
const CLUSTER AssembleCluster(ITEM *aStart, int aLayer, double aAreaExpansionLimit=0.0, NET_HANDLE aExcludedNet=nullptr)
void RestrictToCluster(bool aEnabled, const TOPOLOGY::CLUSTER &aCluster)
STATUS Route(const LINE &aInitialPath, LINE &aWalkPath, bool aOptimize=true)
bool m_enabledPolicies[MaxWalkPolicies]
NODE::OPT_OBSTACLE nearestObstacle(const LINE &aPath)
std::vector< VECTOR2I > m_restrictedVertices
void SetAllowedPolicies(std::vector< WALK_POLICY > aPolicies)
void start(const LINE &aInitialPath)
static constexpr int MaxWalkPolicies
std::optional< TOPOLOGY::CLUSTER > m_lastShortestCluster
double m_lengthExpansionFactor
std::set< const ITEM * > m_restrictedSet
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void Clear()
Remove all points from the line chain.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
long long int Length() const
Return length of the line chain in Euclidean metric.
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
Push and Shove diff pair dimensions (gap) settings dialog.
static wxString policy2string(WALKAROUND::WALK_POLICY policy)
#define PNS_DBG(dbg, method,...)
#define PNS_DBGN(dbg, method)
std::function< bool(const ITEM *)> m_filter
bool m_useClearanceEpsilon
std::set< ITEM * > m_items
LINE lines[MaxWalkPolicies]
STATUS status[MaxWalkPolicies]