110 m_fitOk = !( collP || collN ) ;
130 bool solidsOnly =
true;
150 bool collided =
false;
152 std::set<ITEM*> handled;
154 while( iter < maxIter )
159 if( !obs || handled.count( obs->m_item ) )
164 if( obs->m_item->Shape()->Collide( virtHead.
Shape(), clearance, &force ) )
168 virtHead.
SetPos( virtHead.
Pos() + force );
171 handled.insert( obs->m_item );
176 bool succeeded = ( !collided || iter != maxIter );
189 bool aPFirst,
bool aWindCw,
bool aSolidsOnly )
206 bool currentIsP = aPFirst;
218 currentIsP = !currentIsP;
226 wf1 = walkaround.
Route( preWalk, postWalk,
false );
231 LINE postShove( preShove );
247 currentIsP = !currentIsP;
268 double bestScore = 100000000000000.0;
270 for(
int attempt = 0; attempt <= 3; attempt++ )
275 bool pfirst = ( attempt & 1 ) ?
true :
false;
276 bool wind_cw = ( attempt & 2 ) ?
true :
false;
278 if(
attemptWalk( tmp, &aPair, p, pfirst, wind_cw, aSolidsOnly ) )
282 double skew = p.
Skew();
284 double score = cl + fabs( skew ) * 3.0;
286 if( score < bestScore )
296 if( bestScore > 0.0 )
420 m_prevPair->PrimP()->Layers().Overlaps( aLayer ) ) )
435 switch( aItem->
Kind() )
439 return aItem->
Anchor( 0 );
475 *aErrorMsg =
_(
"Unable to find complementary differential pair "
476 "nets. Make sure the names of the nets belonging "
477 "to a differential pair end with either N/P or +/-." );
482 int refNet = aItem->
Net();
483 int coupledNet = ( refNet == netP ) ? netN : netP;
486 ITEM* primRef = aItem;
492 *aErrorMsg =
_(
"Can't find a suitable starting point. If starting "
493 "from an existing differential pair make sure you are "
500 std::set<ITEM*> coupledItems;
503 double bestDist = std::numeric_limits<double>::max();
506 for(
ITEM* item : coupledItems )
508 if( item->Kind() == aItem->
Kind() )
517 bool shapeMatches =
true;
521 shapeMatches =
false;
524 if( dist < bestDist && shapeMatches )
548 "for coupled net \"%s\"." ),
652 m_prevPair->CursorOrientation( fp, midp, dirV );
716 bool retval =
route( aP );
840 aNets.push_back(
m_netP );
841 aNets.push_back(
m_netN );
Represent route directions & corner angles in a 45-degree metric.
bool IsDiagonal() const
Returns true if the direction is diagonal (e.g.
Represent a contiguous set of PCB layers.
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)
void GetModifiedNets(std::vector< int > &aNets) const override
Function GetModifiedNets.
bool rhMarkObstacles(const VECTOR2I &aP)
int m_viaDiameter
current via drill
const VIA makeVia(const VECTOR2I &aP, int aNet)
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
const std::vector< int > CurrentNets() const override
Return the net code of currently routed track.
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.
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.
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...
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.
void AppendVias(const VIA &aViaP, const VIA &aViaN)
const SHAPE_LINE_CHAIN & CN() const
DP_PRIMITIVE_PAIR EndingPrimitives()
double CoupledLength() const
void SetViaDiameter(int aDiameter)
void SetViaDrill(int aDrill)
void SetShape(const SHAPE_LINE_CHAIN &aP, const SHAPE_LINE_CHAIN &aN, bool aSwapLanes=false)
bool EndsWithVias() const
const SHAPE_LINE_CHAIN & CP() const
void SetNets(int aP, int aN)
void SetWidth(int aWidth)
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.
PnsKind Kind() const
Return the type (kind) of the item.
void SetLayer(int aLayer)
const LAYER_RANGE & Layers() const
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 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...
int GetClearance(const ITEM *aA, const ITEM *aB, bool aUseClearanceEpsilon=true) const
void AllItemsInNet(int aNet, std::set< ITEM * > &aItems, int aKindMask=-1)
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
RULE_RESOLVER * GetRuleResolver() const
Return the number of joints.
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
JOINT * FindJoint(const VECTOR2I &aPos, int aLayer, int aNet)
Search for a joint at a given position, layer and belonging to given net.
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))
virtual void DisplayRatline(const SHAPE_LINE_CHAIN &aRatline, int aNetCode)=0
ROUTER_IFACE * GetInterface() const
void SetFailureReason(const wxString &aReason)
virtual wxString NetName(int aNet)=0
virtual bool DpNetPair(const ITEM *aItem, int &aNetP, int &aNetN)=0
The actual Push and Shove algorithm.
SHOVE_STATUS ShoveObstacleLine(const LINE &aCurLine, const LINE &aObstacleLine, LINE &aResultLine)
void ForceClearance(bool aEnabled, int aClearance)
int DiffPairWidth() const
int GetLayerBottom() const
int GetDiffPairHoleToHole() const
int DiffPairViaGap() const
bool LeadingRatLine(const LINE *aTrack, SHAPE_LINE_CHAIN &aRatLine)
bool SimplifyLine(LINE *aLine)
const VECTOR2I & Pos() const
const SHAPE * Shape() const override
Return the geometrical shape of the item.
void SetDiameter(int aDiameter)
void SetPos(const VECTOR2I &aPos)
void SetIterationLimit(const int aIterLimit)
void SetSolidsOnly(bool aSolidsOnly)
WALKAROUND_STATUS Route(const LINE &aInitialPath, LINE &aWalkPath, bool aOptimize=true)
VECTOR2I LineProject(const VECTOR2I &aP) const
Compute the perpendicular projection point of aP on a line passing through ends of the segment.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
SHAPE_LINE_CHAIN & Simplify(bool aRemoveColinear=true)
Simplify the line chain by removing colinear adjacent segments and duplicate vertices.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
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.
const SEG CSegment(int aIndex) const
Return a constant copy of the aIndex segment in the line chain.
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)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
std::optional< VECTOR2I > OPT_VECTOR2I
double EuclideanNorm(const VECTOR2I &vector)