109 m_fitOk = !( collP || collN ) ;
129 bool solidsOnly =
true;
149 bool collided =
false;
151 std::set<const ITEM*> handled;
153 while( iter < maxIter )
158 if( !obs || handled.count( obs->m_item ) )
163 if( obs->m_item->Shape()->Collide( virtHead.
Shape(), clearance, &force ) )
167 virtHead.
SetPos( virtHead.
Pos() + force );
170 handled.insert( obs->m_item );
175 bool succeeded = ( !collided || iter != maxIter );
188 bool aPFirst,
bool aWindCw,
bool aSolidsOnly )
205 bool currentIsP = aPFirst;
217 currentIsP = !currentIsP;
225 wf1 = walkaround.
Route( preWalk, postWalk,
false );
230 LINE postShove( preShove );
246 currentIsP = !currentIsP;
267 double bestScore = 100000000000000.0;
269 for(
int attempt = 0; attempt <= 3; attempt++ )
274 bool pfirst = ( attempt & 1 ) ?
true :
false;
275 bool wind_cw = ( attempt & 2 ) ?
true :
false;
277 if(
attemptWalk( tmp, &aPair, p, pfirst, wind_cw, aSolidsOnly ) )
281 double skew = p.
Skew();
283 double score = cl + fabs( skew ) * 3.0;
285 if( score < bestScore )
295 if( bestScore > 0.0 )
419 m_prevPair->PrimP()->Layers().Overlaps( aLayer ) ) )
434 switch( aItem->
Kind() )
438 LINE* l =
static_cast<LINE*
>( aItem );
447 return aItem->
Anchor( 0 );
451 ARC* a =
static_cast<ARC*
>( aItem );
496 *aErrorMsg =
_(
"Unable to find complementary differential pair "
497 "nets. Make sure the names of the nets belonging "
498 "to a differential pair end with either N/P or +/-." );
504 NET_HANDLE coupledNet = ( refNet == netP ) ? netN : netP;
507 ITEM* primRef = aItem;
513 *aErrorMsg =
_(
"Can't find a suitable starting point. If starting "
514 "from an existing differential pair make sure you are "
521 std::set<ITEM*> coupledItems;
524 double bestDist = std::numeric_limits<double>::max();
527 for(
ITEM* item : coupledItems )
529 if( item->Kind() == aItem->
Kind() )
536 double dist = ( *
anchor - *refAnchor ).EuclideanNorm();
538 bool shapeMatches =
true;
542 shapeMatches =
false;
545 if( dist < bestDist && shapeMatches )
568 *aErrorMsg = wxString::Format(
_(
"Can't find a suitable starting point "
569 "for coupled net \"%s\"." ),
673 m_prevPair->CursorOrientation( fp, midp, dirV );
679 int lead_dist = ( fpProj - fp ).EuclideanNorm();
737 bool retval =
route( aP );
861 aNets.push_back(
m_netP );
862 aNets.push_back(
m_netN );
881 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.
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
void SetNets(NET_HANDLE aP, NET_HANDLE aN)
const SHAPE_LINE_CHAIN & CP() const
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.
const PNS_LAYER_RANGE & Layers() const
virtual NET_HANDLE Net() const
PnsKind Kind() const
Return the type (kind) of the item.
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...
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.
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.
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
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))
virtual void DisplayRatline(const SHAPE_LINE_CHAIN &aRatline, NET_HANDLE aNetCode)=0
ROUTER_IFACE * GetInterface() const
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.
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)
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 aMaxError=0)
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)
std::optional< VECTOR2I > OPT_VECTOR2I