118 m_fitOk = !( collP || collN ) ;
138 bool solidsOnly =
true;
162 DIFF_PAIR& aWalk,
bool aPFirst,
bool aWindCw,
bool aSolidsOnly )
179 bool currentIsP = aPFirst;
191 currentIsP = !currentIsP;
199 wf1 = walkaround.
Route( preWalk, postWalk,
false );
204 LINE postShove( preShove );
220 currentIsP = !currentIsP;
241 double bestScore = 100000000000000.0;
243 for(
int attempt = 0; attempt <= 3; attempt++ )
248 bool pfirst = ( attempt & 1 ) ?
true :
false;
249 bool wind_cw = ( attempt & 2 ) ?
true :
false;
251 if(
attemptWalk( tmp, &aPair, p, pfirst, wind_cw, aSolidsOnly ) )
255 double skew = p.
Skew();
257 double score = cl + fabs( skew ) * 3.0;
259 if( score < bestScore )
269 if( bestScore > 0.0 )
393 m_prevPair->PrimP()->Layers().Overlaps( aLayer ) ) )
408 switch( aItem->
Kind() )
412 return aItem->
Anchor( 0 );
417 SEGMENT* s = static_cast<SEGMENT*>( aItem );
442 wxLogTrace(
"PNS",
"world %p", aWorld );
450 *aErrorMsg =
_(
"Unable to find complementary differential pair " 451 "nets. Make sure the names of the nets belonging " 452 "to a differential pair end with either _N/_P or +/-." );
457 int refNet = aItem->
Net();
458 int coupledNet = ( refNet == netP ) ? netN : netP;
460 wxLogTrace(
"PNS",
"result %d", !!result );
463 ITEM* primRef = aItem;
465 wxLogTrace(
"PNS",
"refAnchor %p", aItem );
471 *aErrorMsg =
_(
"Can't find a suitable starting point. If starting " 472 "from an existing differential pair make sure you are " 478 std::set<ITEM*> coupledItems;
481 double bestDist = std::numeric_limits<double>::max();
484 for(
ITEM* item : coupledItems )
486 if( item->Kind() == aItem->
Kind() )
494 bool shapeMatches =
true;
498 shapeMatches =
false;
501 if( dist < bestDist && shapeMatches )
525 "for coupled net \"%s\"." ),
629 m_prevPair->CursorOrientation( fp, midp, dirV );
688 bool retval =
route( aP );
739 if( newP.SegmentCount() > 1 && newN.SegmentCount() > 1 )
742 newN.Remove( -1, -1 );
813 aNets.push_back(
m_netP );
814 aNets.push_back(
m_netN );
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
const SHAPE_LINE_CHAIN & CLine() const
bool rhWalkOnly(const VECTOR2I &aP)
route step, shove mode
Base class for PNS router board items.
SIZES_SETTINGS m_sizes
Are we placing a via?
ROUTER * Router() const
Return current router settings.
bool FitGateways(DP_GATEWAYS &aEntry, DP_GATEWAYS &aTarget, bool aPrefDiagonal, DIFF_PAIR &aDp)
void BuildForCursor(const VECTOR2I &aCursorPos)
bool attemptWalk(NODE *aNode, DIFF_PAIR *aCurrent, DIFF_PAIR &aWalk, bool aPFirst, bool aWindCw, bool aSolidsOnly)
Keep the router "world" - i.e.
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...
int GetLayerBottom() const
void SetShape(const SHAPE_LINE_CHAIN &aP, const SHAPE_LINE_CHAIN &aN, bool aSwapLanes=false)
SHAPE_LINE_CHAIN & Simplify(bool aRemoveColinear=true)
Function Simplify()
void GetModifiedNets(std::vector< int > &aNets) const override
Function GetModifiedNets.
void SetLayer(int aLayer)
bool route(const VECTOR2I &aP)
Re-route the current track to point aP.
void AppendVias(const VIA &aViaP, const VIA &aViaN)
bool EndsWithVias() const
bool rhShoveOnly(const VECTOR2I &aP)
route step, mark obstacles mode
const SHAPE_LINE_CHAIN & CN() const
int m_iteration
pointer to world to search colliding items
void FilterByOrientation(int aAngleMask, DIRECTION_45 aRefOrientation)
bool PushoutForce(NODE *aNode, const VECTOR2I &aDirection, VECTOR2I &aForce, bool aSolidsOnly=true, int aMaxIterations=10)
SHOVE * m_shove
Current world state.
int DiffPairWidth() const
int GetHoleToHole() const
int m_viaDiameter
current via drill
WALKAROUND_STATUS Route(const LINE &aInitialPath, LINE &aWalkPath, bool aOptimize=true)
NODE * CurrentNode(bool aLoopsRemoved=false) const override
Return the most recent world state.
double CoupledLength() const
virtual void DisplayRatline(const SHAPE_LINE_CHAIN &aRatline, int aColor=-1)=0
NODE * m_world
current routing start point (end of tail, beginning of head)
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
SHOVE_STATUS ShoveObstacleLine(const LINE &aCurLine, const LINE &aObstacleLine, LINE &aResultLine)
const VIA makeVia(const VECTOR2I &aP, int aNet)
void Add(const LINE &aLine)
bool routeHead(const VECTOR2I &aP)
NODE * Branch()
Create a lightweight copy (called branch) of self that tracks the changes (added/removed items) wrs t...
bool AbortPlacement() override
int m_viaDrill
current track width
void SetDiameter(int aDiameter)
ROUTING_SETTINGS & Settings() const
Return the logger object, allowing to dump geometry to a file.
const VECTOR2I & CPoint(int aIndex) const
Function Point()
bool HasPlacedAnything() const override
Represents a 2D point on a given set of layers and belonging to a certain net, that links together a ...
void BuildFromPrimitivePair(const DP_PRIMITIVE_PAIR &aPair, bool aPreferDiagonal)
bool propagateDpHeadForces(const VECTOR2I &aP, VECTOR2I &aNewP)
VECTOR2I LineProject(const VECTOR2I &aP) const
Compute the perpendicular projection point of aP on a line passing through ends of the segment.
void SetFitVias(bool aEnable, int aDiameter=0, int aViaGap=-1)
bool LeadingRatLine(const LINE *aTrack, SHAPE_LINE_CHAIN &aRatLine)
OPT< VECTOR2I > OPT_VECTOR2I
bool ToggleVia(bool aEnabled) override
Enable/disable a via at the end of currently routed trace.
Represent route directions & corner angles in a 45-degree metric.
void UpdateSizes(const SIZES_SETTINGS &aSizes) override
Perform on-the-fly update of the width, via diameter & drill size from a settings class.
OPT_VECTOR2I getDanglingAnchor(NODE *aNode, ITEM *aItem)
static bool Optimize(LINE *aLine, int aEffortLevel, NODE *aWorld, const VECTOR2I aV=VECTOR2I(0, 0))
bool Start(const VECTOR2I &aP, ITEM *aStartItem) override
Start routing a single track at point aP, taking item aStartItem as anchor (unless NULL).
const ITEM_SET Traces() override
Return the complete routed line, as a single-member ITEM_SET.
PNS_MODE Mode() const
Set the routing mode.
bool m_placingVia
current via diameter
DIFF_PAIR_PLACER(ROUTER *aRouter)
void SetViaDiameter(int aDiameter)
void SetSolidsOnly(bool aSolidsOnly)
void SetWidth(int aWidth)
void Remove(int aStartIndex, int aEndIndex)
Function Remove()
DP_PRIMITIVE_PAIR m_start
int SegmentCount() const
Function SegmentCount()
JOINT * FindJoint(const VECTOR2I &aPos, int aLayer, int aNet)
Search for a joint at a given position, layer and belonging to given net.
SHAPE_LINE_CHAIN & Line()
bool SimplifyLine(LINE *aLine)
RULE_RESOLVER * GetRuleResolver() const
Return the number of joints.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
virtual VECTOR2I Anchor(int n) const
void FlipPosture() override
Toggle the current posture (straight/diagonal) of the trace head.
Guess what's better, try to make least mess on the PCB.
const SHAPE_LINE_CHAIN & CP() const
NODE * m_currentNode
Postprocessed world state (including marked collisions & removed loops)
void updateLeadingRatLine()
Draw the "leading" ratsnest line, which connects the end of currently routed track and the nearest ye...
Ignore collisions, mark obstacles.
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).
void ForceClearance(bool aEnabled, int aClearance)
const SEG CSegment(int aIndex) const
Function CSegment()
std::unique_ptr< typename std::remove_const< T >::type > Clone(const T &aItem)
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.
bool CommitPlacement() override
void initPlacement()
Initialize placement of a new line with given parameters.
static bool FindDpPrimitivePair(NODE *aWorld, const VECTOR2I &aP, ITEM *aItem, DP_PRIMITIVE_PAIR &aPair, wxString *aErrorMsg=nullptr)
int DiffPairViaGap() const
bool SetLayer(int aLayer) override
Set the current routing layer.
PnsKind Kind() const
Return the type (kind) of the item.
Perform various optimizations of the lines being routed, attempting to make the lines shorter and les...
const std::vector< int > CurrentNets() const override
Return the net code of currently routed track.
virtual wxString NetName(int aNet)=0
OPT< DP_PRIMITIVE_PAIR > m_prevPair
current algorithm iteration
bool tryWalkDp(NODE *aNode, DIFF_PAIR &aPair, bool aSolidsOnly)
route step, walk around mode
void SetOrthoMode(bool aOrthoMode) override
Function SetOrthoMode()
int LinkCount(int aMask=-1) const
void setWorld(NODE *aWorld)
Set the board to route.
virtual bool DpNetPair(const ITEM *aItem, int &aNetP, int &aNetN)=0
SHOVE_STATUS ShoveMultiLines(const ITEM_SET &aHeadSet)
void SetViaDrill(int aDrill)
Push and Shove diff pair dimensions (gap) settings dialog.
bool Add(std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant=false)
Add an item to the current node.
ROUTER_IFACE * GetInterface() const
void SetIterationLimit(const int aIterLimit)
Represent a contiguous set of PCB layers.
const LAYER_RANGE & Layers() const
DP_PRIMITIVE_PAIR EndingPrimitives()
void SetAnchors(const VECTOR2I &aAnchorP, const VECTOR2I &aAnchorN)
void SetNets(int aP, int aN)
bool rhMarkObstacles(const VECTOR2I &aP)