112    m_fitOk = !( collP || collN ) ;
 
 
  132    bool solidsOnly = 
true;
 
  152    bool                  collided = 
false;
 
  154    std::set<const ITEM*> handled;
 
  156    while( iter < maxIter )
 
  161        if( !obs || handled.count( obs->m_item ) )
 
  170            collided |= obs->m_item->Shape( viaLayer )->Collide( virtHead.
Shape( viaLayer ),
 
  180            virtHead.
SetPos( virtHead.
Pos() + force );
 
  183        handled.insert( obs->m_item );
 
  188    bool succeeded = ( !collided || iter != maxIter );
 
 
  201                                    bool aPFirst, 
bool aWindCw, 
bool aSolidsOnly )
 
  219    bool currentIsP = aPFirst;
 
  231            currentIsP = !currentIsP;
 
  239        auto wf1 = walkaround.
Route( preWalk );
 
  246        LINE postShove( preShove );
 
  262        currentIsP = !currentIsP;
 
 
  283    double bestScore = 100000000000000.0;
 
  285    for( 
int attempt = 0; attempt <= 3; attempt++ )
 
  290        bool pfirst = ( attempt & 1 ) ? 
true : 
false;
 
  291        bool wind_cw = ( attempt & 2 ) ? 
true : 
false;
 
  293        if( 
attemptWalk( tmp, &aPair, p, pfirst, wind_cw, aSolidsOnly ) )
 
  296            double skew = p.
Skew();
 
  298            double score = cl + fabs( skew ) * 3.0;
 
  300            if( score < bestScore )
 
  303                best = std::move( p );
 
  310    if( bestScore > 0.0 )
 
 
  383        if( 
m_shove->HeadsModified( 0 ))
 
  384            pLine = 
m_shove->GetModifiedHead(0);
 
  386        if( 
m_shove->HeadsModified( 1 ))
 
  387            nLine = 
m_shove->GetModifiedHead(1);
 
 
  447                m_prevPair->PrimP()->Layers().Overlaps( aLayer ) ) )
 
 
  462    switch( aItem->
Kind() )
 
  466        LINE* l = 
static_cast<LINE*
>( aItem );
 
  475        return aItem->
Anchor( 0 );
 
  479        ARC* a = 
static_cast<ARC*
>( aItem );
 
 
  524            *aErrorMsg = 
_( 
"Unable to find complementary differential pair " 
  525                            "nets. Make sure the names of the nets belonging " 
  526                            "to a differential pair end with either N/P or +/-." );
 
  532    NET_HANDLE coupledNet = ( refNet == netP ) ? netN : netP;
 
  535    ITEM* primRef = aItem;
 
  541            *aErrorMsg = 
_( 
"Can't find a suitable starting point.  If starting " 
  542                            "from an existing differential pair make sure you are " 
  549    std::set<ITEM*> coupledItems;
 
  552    double bestDist = std::numeric_limits<double>::max();
 
  555    for( 
ITEM* item : coupledItems )
 
  557        if( item->Kind() == aItem->
Kind() )
 
  564            double dist = ( *
anchor - *refAnchor ).EuclideanNorm();
 
  566            bool shapeMatches = 
true;
 
  570                shapeMatches = 
false;
 
  573            if( dist < bestDist && shapeMatches )
 
  596            *aErrorMsg = wxString::Format( 
_( 
"Can't find a suitable starting point " 
  597                                              "for coupled net \"%s\"." ),
 
 
  610    return std::max( 
m_sizes.DiffPairViaGap(),
 
 
  702        m_prevPair->CursorOrientation( fp, midp, dirV );
 
  708        int lead_dist = ( fpProj - fp ).EuclideanNorm();
 
  713        if( lead_dist > ( 
m_sizes.DiffPairGap() + 
m_sizes.DiffPairWidth() ) / 2 )
 
 
  766    bool retval = 
route( aP );
 
 
  898    aNets.push_back( 
m_netP );
 
  899    aNets.push_back( 
m_netN );
 
 
  918    std::vector<NET_HANDLE> rv;
 
 
Represent route directions & corner angles in a 45-degree metric.
 
bool IsDiagonal() const
Returns true if the direction is diagonal (e.g.
 
ROUTER * Router() const
Return current router settings.
 
ROUTING_SETTINGS & Settings() const
Return the logger object, allowing to dump geometry to a file.
 
NODE * CurrentNode(bool aLoopsRemoved=false) const override
Return the most recent world state.
 
void SetOrthoMode(bool aOrthoMode) override
Function SetOrthoMode()
 
bool HasPlacedAnything() const override
 
NODE * m_world
current routing start point (end of tail, beginning of head)
 
bool tryWalkDp(NODE *aNode, DIFF_PAIR &aPair, bool aSolidsOnly)
route step, walk around mode
 
bool propagateDpHeadForces(const VECTOR2I &aP, VECTOR2I &aNewP)
 
bool rhMarkObstacles(const VECTOR2I &aP)
 
int m_viaDiameter
current via drill
 
std::optional< DP_PRIMITIVE_PAIR > m_prevPair
current algorithm iteration
 
bool ToggleVia(bool aEnabled) override
Enable/disable a via at the end of currently routed trace.
 
bool route(const VECTOR2I &aP)
Re-route the current track to point aP.
 
bool AbortPlacement() override
 
int m_iteration
pointer to world to search colliding items
 
bool rhShoveOnly(const VECTOR2I &aP)
route step, mark obstacles mode
 
bool Start(const VECTOR2I &aP, ITEM *aStartItem) override
Start routing a single track at point aP, taking item aStartItem as anchor (unless NULL).
 
bool CommitPlacement() override
 
const ITEM_SET Traces() override
Return the complete routed line, as a single-member ITEM_SET.
 
void GetModifiedNets(std::vector< NET_HANDLE > &aNets) const override
Function GetModifiedNets.
 
int m_viaDrill
current track width
 
void FlipPosture() override
Toggle the current posture (straight/diagonal) of the trace head.
 
DIFF_PAIR_PLACER(ROUTER *aRouter)
 
bool attemptWalk(NODE *aNode, DIFF_PAIR *aCurrent, DIFF_PAIR &aWalk, bool aPFirst, bool aWindCw, bool aSolidsOnly)
 
void setWorld(NODE *aWorld)
Set the board to route.
 
NODE * m_currentNode
Postprocessed world state (including marked collisions & removed loops)
 
void initPlacement()
Initialize placement of a new line with given parameters.
 
const std::vector< NET_HANDLE > CurrentNets() const override
Return the net of currently routed track.
 
bool routeHead(const VECTOR2I &aP)
 
void UpdateSizes(const SIZES_SETTINGS &aSizes) override
Perform on-the-fly update of the width, via diameter & drill size from a settings class.
 
static bool FindDpPrimitivePair(NODE *aWorld, const VECTOR2I &aP, ITEM *aItem, DP_PRIMITIVE_PAIR &aPair, wxString *aErrorMsg=nullptr)
 
bool rhWalkOnly(const VECTOR2I &aP)
route step, shove mode
 
bool Move(const VECTOR2I &aP, ITEM *aEndItem) override
Move the end of the currently routed trace to the point aP, taking aEndItem as anchor (if not NULL).
 
DP_PRIMITIVE_PAIR m_start
 
bool FixRoute(const VECTOR2I &aP, ITEM *aEndItem, bool aForceFinish) override
Commit the currently routed track to the parent node, taking aP as the final end point and aEndItem a...
 
bool m_placingVia
current via diameter
 
void updateLeadingRatLine()
Draw the "leading" ratsnest line, which connects the end of currently routed track and the nearest ye...
 
const VIA makeVia(const VECTOR2I &aP, NET_HANDLE aNet)
 
SIZES_SETTINGS m_sizes
Are we placing a via?
 
bool SetLayer(int aLayer) override
Set the current routing layer.
 
std::unique_ptr< SHOVE > m_shove
Current world state.
 
Basic class for a differential pair.
 
const SHAPE_LINE_CHAIN & CN() const
 
double CoupledLength() const
 
void SetShape(const SHAPE_LINE_CHAIN &aP, const SHAPE_LINE_CHAIN &aN, bool aSwapLanes=false)
 
const SHAPE_LINE_CHAIN & CP() const
 
A set of gateways calculated for the cursor or starting/ending primitive pair.
 
void SetFitVias(bool aEnable, int aDiameter=0, int aViaGap=-1)
 
void BuildFromPrimitivePair(const DP_PRIMITIVE_PAIR &aPair, bool aPreferDiagonal)
 
bool FitGateways(DP_GATEWAYS &aEntry, DP_GATEWAYS &aTarget, bool aPrefDiagonal, DIFF_PAIR &aDp)
 
void FilterByOrientation(int aAngleMask, DIRECTION_45 aRefOrientation)
 
void BuildForCursor(const VECTOR2I &aCursorPos)
 
Store starting/ending primitives (pads, vias or segments) for a differential pair.
 
void SetAnchors(const VECTOR2I &aAnchorP, const VECTOR2I &aAnchorN)
 
void Add(const LINE &aLine)
 
Base class for PNS router board items.
 
const PNS_LAYER_RANGE & Layers() const
 
virtual NET_HANDLE Net() const
 
PnsKind Kind() const
Return the type (kind) of the item.
 
std::set< int > RelevantShapeLayers(const ITEM *aOther) const
Returns the set of layers on which either this or the other item can have a unique shape.
 
void SetLayer(int aLayer)
 
virtual VECTOR2I Anchor(int n) const
 
A 2D point on a given set of layers and belonging to a certain net, that links together a number of b...
 
int LinkCount(int aMask=-1) 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()
 
Keep the router "world" - i.e.
 
NODE * Branch()
Create a lightweight copy (called branch) of self that tracks the changes (added/removed items) wrs t...
 
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.
 
const JOINT * FindJoint(const VECTOR2I &aPos, int aLayer, NET_HANDLE aNet) const
Search for a joint at a given position, layer and belonging to given net.
 
std::optional< OBSTACLE > OPT_OBSTACLE
 
RULE_RESOLVER * GetRuleResolver() const
Return the number of joints.
 
void AllItemsInNet(NET_HANDLE aNet, std::set< ITEM * > &aItems, int aKindMask=-1)
 
Perform various optimizations of the lines being routed, attempting to make the lines shorter and les...
 
static bool Optimize(LINE *aLine, int aEffortLevel, NODE *aWorld, const VECTOR2I &aV=VECTOR2I(0, 0))
 
PLACEMENT_ALGO(ROUTER *aRouter)
 
void SetFailureReason(const wxString &aReason)
 
virtual bool DpNetPair(const ITEM *aItem, NET_HANDLE &aNetP, NET_HANDLE &aNetN)=0
 
virtual wxString NetName(NET_HANDLE aNet)=0
 
The actual Push and Shove algorithm.
 
void ForceClearance(bool aEnabled, int aClearance)
 
bool ShoveObstacleLine(const LINE &aCurLine, const LINE &aObstacleLine, LINE &aResultLine)
 
bool LeadingRatLine(const LINE *aTrack, SHAPE_LINE_CHAIN &aRatLine)
 
bool SimplifyLine(LINE *aLine)
 
int Diameter(int aLayer) const
 
void SetDiameter(int aLayer, int aDiameter)
 
const VECTOR2I & Pos() const
 
const SHAPE * Shape(int aLayer) const override
Return the geometrical shape of the item.
 
void SetPos(const VECTOR2I &aPos)
 
void SetIterationLimit(const int aIterLimit)
 
void SetSolidsOnly(bool aSolidsOnly)
 
STATUS Route(const LINE &aInitialPath, LINE &aWalkPath, bool aOptimize=true)
 
void SetAllowedPolicies(std::vector< WALK_POLICY > aPolicies)
 
Represent a contiguous set of PCB layers.
 
VECTOR2I LineProject(const VECTOR2I &aP) const
Compute the perpendicular projection point of aP on a line passing through ends of the segment.
 
const VECTOR2I & GetP1() const
 
const VECTOR2I & GetP0() const
 
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
 
void Simplify(int aTolerance=0)
Simplify the line chain by removing colinear adjacent segments and duplicate vertices.
 
int SegmentCount() const
Return the number of segments in this line chain.
 
void Remove(int aStartIndex, int aEndIndex)
Remove the range of points [start_index, end_index] from the line chain.
 
constexpr extended_type SquaredEuclideanNorm() const
Compute the squared euclidean norm of the vector, which is defined as (x ** 2 + y ** 2).
 
Push and Shove diff pair dimensions (gap) settings dialog.
 
OPT_VECTOR2I getDanglingAnchor(NODE *aNode, ITEM *aItem)
 
@ RM_MarkObstacles
Ignore collisions, mark obstacles.
 
@ RM_Walkaround
Only walk around.
 
std::unique_ptr< typename std::remove_const< T >::type > Clone(const T &aItem)
 
std::optional< VECTOR2I > OPT_VECTOR2I
 
wxString result
Test unit parsing edge cases and error handling.
 
VECTOR2< int32_t > VECTOR2I