\doxysection{AStar.\+hpp}
\hypertarget{AStar_8hpp_source}{}\label{AStar_8hpp_source}\index{/home/chr/devel/PhD/Environment/pub/PCBEnv/pcbenv/cxx/AStar.hpp@{/home/chr/devel/PhD/Environment/pub/PCBEnv/pcbenv/cxx/AStar.hpp}}

\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ }
\DoxyCodeLine{00002\ \textcolor{preprocessor}{\#ifndef\ GYM\_PCB\_ASTAR\_H}}
\DoxyCodeLine{00003\ \textcolor{preprocessor}{\#define\ GYM\_PCB\_ASTAR\_H}}
\DoxyCodeLine{00004\ }
\DoxyCodeLine{00005\ \textcolor{preprocessor}{\#include\ "{}Log.hpp"{}}}
\DoxyCodeLine{00006\ \textcolor{preprocessor}{\#include\ "{}PCBoard.hpp"{}}}
\DoxyCodeLine{00007\ \textcolor{preprocessor}{\#include\ "{}NavGrid.hpp"{}}}
\DoxyCodeLine{00008\ \textcolor{preprocessor}{\#include\ "{}Path.hpp"{}}}
\DoxyCodeLine{00009\ \textcolor{preprocessor}{\#include\ <queue>}}
\DoxyCodeLine{00010\ }
\DoxyCodeLine{00011\ \textcolor{comment}{//\ OPTIMIZATIONS\ TODO:}}
\DoxyCodeLine{00012\ \textcolor{comment}{//\ "{}Online\ Graph\ Pruning\ for\ Pathfinding\ on\ Grid\ Maps"{},\ D.\ Harabor\ \&\ A.\ Grastien,\ AAAI\ 2011}}
\DoxyCodeLine{00013\ \textcolor{comment}{//\ 1)\ Don't\ evaluate\ nodes\ that\ are\ more\ quickly\ reached\ from\ the\ parent.}}
\DoxyCodeLine{00014\ \textcolor{comment}{//\ 2)\ Keep\ moving\ in\ the\ same\ direction\ without\ expansion\ as\ long\ as\ we\ don't}}
\DoxyCodeLine{00015\ \textcolor{comment}{//\ \ \ \ find\ another\ neighbour\ (other\ than\ straight)\ that\ isn't\ more\ quickly}}
\DoxyCodeLine{00016\ \textcolor{comment}{//\ \ \ \ reached\ from\ (dominated\ by)\ the\ parent.}}
\DoxyCodeLine{00017\ \textcolor{comment}{//\ 3)\ The\ point\ where\ we\ find\ another\ neighbour\ is\ the\ jump\ point\ that\ we\ use}}
\DoxyCodeLine{00018\ \textcolor{comment}{//\ \ \ \ as\ successor\ to\ our\ original\ node.}}
\DoxyCodeLine{00019\ \textcolor{comment}{//\ 4)\ If\ we\ reach\ an\ obstacle\ going\ straight,\ we\ do\ nothing.}}
\DoxyCodeLine{00020\ \textcolor{comment}{//\ The\ paper\ proves\ that\ this\ strategy\ does\ not\ affect\ optimality.}}
\DoxyCodeLine{00021\ }
\DoxyCodeLine{00023\ \textcolor{preprocessor}{\#define\ ASTAR\_ALLOW\_XOVER\ false}}
\DoxyCodeLine{00024\ }
\DoxyCodeLine{00029\ \textcolor{keyword}{class\ }NavPointRef}
\DoxyCodeLine{00030\ \{}
\DoxyCodeLine{00031\ \textcolor{keyword}{public}:}
\DoxyCodeLine{00032\ \ \ \ \ NavPointRef(\mbox{\hyperlink{classNavPoint}{NavPoint}}\ *nav,\ \textcolor{keywordtype}{float}\ v)\ :\ mPoint(nav),\ mKey(nav-\/>getScore()\ +\ v)\ \{\ \}}
\DoxyCodeLine{00033\ \ \ \ \ \mbox{\hyperlink{classNavPoint}{NavPoint}}\ *getPoint()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mPoint;\ \}}
\DoxyCodeLine{00034\ \ \ \ \ \mbox{\hyperlink{classNavPoint}{NavPoint}}\ *operator-\/>()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mPoint;\ \}}
\DoxyCodeLine{00035\ \ \ \ \ \textcolor{keywordtype}{bool}\ operator<(\textcolor{keyword}{const}\ NavPointRef\ \&that)\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mKey\ >=\ that.mKey;\ \}}
\DoxyCodeLine{00036\ \textcolor{keyword}{private}:}
\DoxyCodeLine{00037\ \ \ \ \ \textcolor{keywordtype}{float}\ mKey;}
\DoxyCodeLine{00038\ \ \ \ \ \mbox{\hyperlink{classNavPoint}{NavPoint}}\ *mPoint;}
\DoxyCodeLine{00039\ \};}
\DoxyCodeLine{00040\ }
\DoxyCodeLine{00041\ \textcolor{keyword}{class\ }AStar}
\DoxyCodeLine{00042\ \{}
\DoxyCodeLine{00043\ \ \ \ \ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{static}\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{float}\ mTurnCostPer45Degrees\ =\ 1.0f\ /\ 1024.0f;}
\DoxyCodeLine{00044\ \textcolor{keyword}{public}:}
\DoxyCodeLine{00045\ \ \ \ \ AStar(\mbox{\hyperlink{classNavGrid}{NavGrid}}\&,\ \textcolor{keyword}{const}\ \mbox{\hyperlink{structAStarCosts}{AStarCosts}}\&);}
\DoxyCodeLine{00046\ \ \ \ \ \string~AStar();}
\DoxyCodeLine{00047\ \ \ \ \ \textcolor{keywordtype}{bool}\ search(\mbox{\hyperlink{classConnection}{Connection}}\&);}
\DoxyCodeLine{00048\ \ \ \ \ \textcolor{keyword}{const}\ std::vector<Point\_25>\&\ violations()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ mViolationLocs;\ \}}
\DoxyCodeLine{00049\ \textcolor{keyword}{private}:}
\DoxyCodeLine{00050\ \ \ \ \ \mbox{\hyperlink{classNavGrid}{NavGrid}}\ \&mNav;}
\DoxyCodeLine{00051\ \ \ \ \ Point\_2\ mTargetXY;}
\DoxyCodeLine{00052\ \ \ \ \ \textcolor{keywordtype}{int}\ mTargetZ[2];}
\DoxyCodeLine{00053\ \ \ \ \ std::vector<float>\ mLayerCost;}
\DoxyCodeLine{00054\ \ \ \ \ uint16\_t\ mRouteMask\{NAV\_POINT\_FLAGS\_TRACKS\_BLOCKED\};}
\DoxyCodeLine{00055\ \ \ \ \ \textcolor{keywordtype}{float}\ mViaCost;}
\DoxyCodeLine{00056\ \ \ \ \ \textcolor{keywordtype}{float}\ mViolationCost;}
\DoxyCodeLine{00057\ \ \ \ \ \mbox{\hyperlink{classNavPoint}{NavPoint}}\ *mTarget\{0\};}
\DoxyCodeLine{00058\ \ \ \ \ Point\_2\ mSourceXY;}
\DoxyCodeLine{00059\ \ \ \ \ std::vector<Point\_25>\ mViolationLocs;}
\DoxyCodeLine{00060\ \ \ \ \ \mbox{\hyperlink{structAStarCosts}{AStarCosts}}\ mCostParams;}
\DoxyCodeLine{00061\ \ \ \ \ \textcolor{keywordtype}{float}\ heuristic(\textcolor{keyword}{const}\ \mbox{\hyperlink{classNavPoint}{NavPoint}}\&);}
\DoxyCodeLine{00062\ \ \ \ \ \textcolor{keywordtype}{int}\ getApproxBlockageSearchArea(\textcolor{keyword}{const}\ \mbox{\hyperlink{classPin}{Pin}}\ *)\ \textcolor{keyword}{const};}
\DoxyCodeLine{00063\ \ \ \ \ \textcolor{keywordtype}{int}\ \_search(\mbox{\hyperlink{classNavPoint}{NavPoint}}\ *source,\ \textcolor{keywordtype}{int}\ maxVisits);}
\DoxyCodeLine{00064\ \ \ \ \ \textcolor{keywordtype}{int}\ \_search(\mbox{\hyperlink{classNavPoint}{NavPoint}}\ *source,\ \mbox{\hyperlink{classNavPoint}{NavPoint}}\ *target,\ \textcolor{keywordtype}{int}\ maxVisits);}
\DoxyCodeLine{00065\ \ \ \ \ \textcolor{keywordtype}{void}\ initEndPoint(\textcolor{keyword}{const}\ Point\_2\&,\ \textcolor{keywordtype}{int}\ z[2],\ \textcolor{keywordtype}{bool}\ dst,\ \textcolor{keywordtype}{bool}\ save);}
\DoxyCodeLine{00066\ \ \ \ \ \textcolor{keywordtype}{void}\ finiEndPoint(\textcolor{keyword}{const}\ Point\_2\&,\ \textcolor{keywordtype}{int}\ z[2]);}
\DoxyCodeLine{00067\ \ \ \ \ \textcolor{keywordtype}{bool}\ reconstruct(\mbox{\hyperlink{classConnection}{Connection}}\&);}
\DoxyCodeLine{00068\ \ \ \ \ \textcolor{keywordtype}{void}\ addViolation(\textcolor{keyword}{const}\ \mbox{\hyperlink{classNavPoint}{NavPoint}}\ *,\ Real\ radius);}
\DoxyCodeLine{00069\ \ \ \ \ \textcolor{keywordtype}{void}\ initCosts(\textcolor{keyword}{const}\ \mbox{\hyperlink{classConnection}{Connection}}\&);}
\DoxyCodeLine{00070\ \ \ \ \ \textcolor{keywordtype}{float}\ computeCost(\mbox{\hyperlink{classNavPoint}{NavPoint}}\ *src,\ \mbox{\hyperlink{classNavPoint}{NavPoint}}\ *dst,\ \textcolor{keyword}{const}\ \mbox{\hyperlink{classGridDirection}{GridDirection}}\ d);}
\DoxyCodeLine{00071\ \textcolor{keyword}{private}:}
\DoxyCodeLine{00072\ \ \ \ \ \textcolor{keywordtype}{void}\ writePoint(\textcolor{keyword}{const}\ \mbox{\hyperlink{classPoint__25}{Point\_25}}\&,\ uint16\_t\ add,\ uint16\_t\ clr,\ \textcolor{keywordtype}{bool}\ save);}
\DoxyCodeLine{00073\ \ \ \ \ \mbox{\hyperlink{classNavPoint}{NavPoint}}\ *checkHEdge(\textcolor{keyword}{const}\ \mbox{\hyperlink{classNavPoint}{NavPoint}}\ *,\ \mbox{\hyperlink{classGridDirection}{GridDirection}})\ \textcolor{keyword}{const};}
\DoxyCodeLine{00074\ \ \ \ \ \mbox{\hyperlink{classNavPoint}{NavPoint}}\ *checkVEdge(\textcolor{keyword}{const}\ \mbox{\hyperlink{classNavPoint}{NavPoint}}\ *,\ \mbox{\hyperlink{classGridDirection}{GridDirection}})\ \textcolor{keyword}{const};}
\DoxyCodeLine{00075\ \};}
\DoxyCodeLine{00076\ }
\DoxyCodeLine{00077\ AStar::AStar(\mbox{\hyperlink{classNavGrid}{NavGrid}}\ \&nav,\ \textcolor{keyword}{const}\ \mbox{\hyperlink{structAStarCosts}{AStarCosts}}\ \&costs)\ :\ mNav(nav),\ mCostParams(costs)}
\DoxyCodeLine{00078\ \{}
\DoxyCodeLine{00079\ \}}
\DoxyCodeLine{00080\ AStar::\string~AStar()}
\DoxyCodeLine{00081\ \{}
\DoxyCodeLine{00082\ \}}
\DoxyCodeLine{00083\ }
\DoxyCodeLine{00084\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{void}\ AStar::writePoint(\textcolor{keyword}{const}\ \mbox{\hyperlink{classPoint__25}{Point\_25}}\ \&v,\ uint16\_t\ add,\ uint16\_t\ clr,\ \textcolor{keywordtype}{bool}\ save)}
\DoxyCodeLine{00085\ \{}
\DoxyCodeLine{00086\ \ \ \ \ NavPoint\ *x\ =\ mNav.getPoint(v);}
\DoxyCodeLine{00087\ \ \ \ \ \textcolor{keywordflow}{if}\ (save)}
\DoxyCodeLine{00088\ \ \ \ \ \ \ \ \ x-\/>saveFlags();}
\DoxyCodeLine{00089\ \ \ \ \ x-\/>setFlags(add);}
\DoxyCodeLine{00090\ \ \ \ \ x-\/>clearFlags(clr);}
\DoxyCodeLine{00091\ \}}
\DoxyCodeLine{00092\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{void}\ AStar::initEndPoint(\textcolor{keyword}{const}\ Point\_2\ \&v,\ \textcolor{keywordtype}{int}\ Z[2],\ \textcolor{keywordtype}{bool}\ dst,\ \textcolor{keywordtype}{bool}\ save)}
\DoxyCodeLine{00093\ \{}
\DoxyCodeLine{00094\ \ \ \ \ \textcolor{keyword}{const}\ uint\ w\ =\ dst\ ?\ NAV\_POINT\_FLAG\_TARGET\ :\ NAV\_POINT\_FLAG\_SOURCE;}
\DoxyCodeLine{00095\ \ \ \ \ \textcolor{keyword}{const}\ uint\ m\ =\ dst\ ?\ NAV\_POINT\_FLAG\_SOURCE\ :\ NAV\_POINT\_FLAG\_TARGET;}
\DoxyCodeLine{00096\ \ \ \ \ \textcolor{comment}{//\ If\ the\ endpoint\ goes\ across\ multiple\ layers\ it\ will\ be\ a\ pin\ where\ we\ can\ move\ freely\ vertically,\ so\ remove\ via\ clearance.\ Leaving\ the\ pin\ is\ still\ blocked\ by\ the\ canPlaceVia()\ check.}}
\DoxyCodeLine{00097\ \ \ \ \ \textcolor{keyword}{const}\ uint\ u\ =\ (Z[0]\ ==\ Z[1])\ ?\ NAV\_POINT\_FLAGS\_TRACK\_CLEARANCE\ :\ NAV\_POINT\_FLAGS\_CLEARANCE;}
\DoxyCodeLine{00098\ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ z\ =\ Z[0];\ z\ <=\ Z[1];\ ++z)}
\DoxyCodeLine{00099\ \ \ \ \ \ \ \ \ writePoint(Point\_25(v,\ z),\ w,\ NAV\_POINT\_FLAG\_BLOCKED\_TEMPORARY\ |\ u\ |\ m,\ save);}
\DoxyCodeLine{00100\ \ \ \ \ \textcolor{keywordflow}{if}\ (dst)\ \{}
\DoxyCodeLine{00101\ \ \ \ \ \ \ \ \ mTargetZ[0]\ =\ Z[0];}
\DoxyCodeLine{00102\ \ \ \ \ \ \ \ \ mTargetZ[1]\ =\ Z[1];}
\DoxyCodeLine{00103\ \ \ \ \ \}}
\DoxyCodeLine{00104\ \}}
\DoxyCodeLine{00105\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{void}\ AStar::finiEndPoint(\textcolor{keyword}{const}\ Point\_2\ \&v,\ \textcolor{keywordtype}{int}\ Z[2])}
\DoxyCodeLine{00106\ \{}
\DoxyCodeLine{00107\ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ z\ =\ Z[0];\ z\ <=\ Z[1];\ ++z)}
\DoxyCodeLine{00108\ \ \ \ \ \ \ \ \ mNav.getPoint(v,\ z)-\/>restoreFlags();}
\DoxyCodeLine{00109\ \}}
\DoxyCodeLine{00110\ }
\DoxyCodeLine{00111\ \textcolor{keywordtype}{float}\ AStar::heuristic(\textcolor{keyword}{const}\ \mbox{\hyperlink{classNavPoint}{NavPoint}}\ \&A)}
\DoxyCodeLine{00112\ \{}
\DoxyCodeLine{00113\ \ \ \ \ \textcolor{comment}{//SCORE\ d\ =\ std::sqrt(CGAL::squared\_distance(A.getRefPoint(),\ mTargetXY));}}
\DoxyCodeLine{00114\ \ \ \ \ \textcolor{keywordtype}{float}\ d\ =\ geo::distance45(A.getRefPoint(\&mNav),\ mTargetXY);}
\DoxyCodeLine{00115\ }
\DoxyCodeLine{00116\ \ \ \ \ uint\ dz\ =\ 0;}
\DoxyCodeLine{00117\ \ \ \ \ \textcolor{keywordflow}{if}\ (A.getLayer()\ <\ mTargetZ[0])}
\DoxyCodeLine{00118\ \ \ \ \ \ \ \ \ dz\ =\ mTargetZ[0]\ -\/\ A.getLayer();}
\DoxyCodeLine{00119\ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (A.getLayer()\ >\ mTargetZ[1])}
\DoxyCodeLine{00120\ \ \ \ \ \ \ \ \ dz\ =\ A.getLayer()\ -\/\ mTargetZ[1];}
\DoxyCodeLine{00121\ \ \ \ \ \textcolor{keywordflow}{if}\ (dz)\ \{}
\DoxyCodeLine{00122\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (!A.getBackDirection().isVertical())}
\DoxyCodeLine{00123\ \ \ \ \ \ \ \ \ \ \ \ \ dz\ +=\ 1;}
\DoxyCodeLine{00124\ \ \ \ \ \ \ \ \ d\ +=\ mViaCost\ *\ 0.5f\ *\ dz;}
\DoxyCodeLine{00125\ \ \ \ \ \}}
\DoxyCodeLine{00126\ \ \ \ \ \textcolor{keywordflow}{return}\ d;}
\DoxyCodeLine{00127\ \}}
\DoxyCodeLine{00128\ }
\DoxyCodeLine{00129\ \textcolor{comment}{//\ When\ we\ add\ a\ via:}}
\DoxyCodeLine{00130\ \textcolor{comment}{//\ V0\ z=0\ -\/>\ Segment(\ S,V0)}}
\DoxyCodeLine{00131\ \textcolor{comment}{//\ V1\ z=0\ -\/>\ Segment(\ S,V1)}}
\DoxyCodeLine{00132\ \textcolor{comment}{//\ V1\ z=1\ -\/>\ Segment(V1,V1)}}
\DoxyCodeLine{00133\ \textcolor{comment}{//\ V2\ z=1\ -\/>\ Segment(V1,V2)}}
\DoxyCodeLine{00134\ \textcolor{keywordtype}{bool}\ AStar::reconstruct(\mbox{\hyperlink{classConnection}{Connection}}\ \&route)}
\DoxyCodeLine{00135\ \{}
\DoxyCodeLine{00136\ \ \ \ \ std::lock\_guard\ wlock(mNav.getPCB().getLock());}
\DoxyCodeLine{00137\ }
\DoxyCodeLine{00138\ \ \ \ \ assert(!route.hasTracks()\ \&\&\ !route.isRouted());}
\DoxyCodeLine{00139\ \ \ \ \ assert(mTarget);}
\DoxyCodeLine{00140\ \ \ \ \ \textcolor{keyword}{const}\ NavPoint\ *head\ =\ mTarget;}
\DoxyCodeLine{00141\ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keyword}{auto}\ next\ =\ head-\/>getBackEdge(mNav);\ next-\/>hasFlags(NAV\_POINT\_FLAG\_TARGET);\ next\ =\ next-\/>getBackEdge(mNav))}
\DoxyCodeLine{00142\ \ \ \ \ \ \ \ \ head\ =\ next;}
\DoxyCodeLine{00143\ \ \ \ \ Track\ *T\ =\ route.newTrack(head-\/>getRefPoint25(\&mNav));}
\DoxyCodeLine{00144\ \ \ \ \ \textcolor{keyword}{const}\ NavPoint\ *node\ =\ head;}
\DoxyCodeLine{00145\ \ \ \ \ DEBUG(\textcolor{stringliteral}{"{}AStar\ "{}}\ <<\ node-\/>str(\&mNav));}
\DoxyCodeLine{00146\ \ \ \ \ GridDirection\ d\ =\ node-\/>getBackDirection();}
\DoxyCodeLine{00147\ \ \ \ \ \textcolor{keywordflow}{while}\ (!node-\/>hasFlags(NAV\_POINT\_FLAG\_SOURCE))\ \{}
\DoxyCodeLine{00148\ \ \ \ \ \ \ \ \ node\ =\ node-\/>getBackEdge(mNav);}
\DoxyCodeLine{00149\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (!node-\/>canRoute())}
\DoxyCodeLine{00150\ \ \ \ \ \ \ \ \ \ \ \ \ addViolation(node,\ T-\/>defaultWidth());}
\DoxyCodeLine{00151\ \ \ \ \ \ \ \ \ DEBUG(\textcolor{stringliteral}{"{}AStar\ "{}}\ <<\ node-\/>str(\&mNav));}
\DoxyCodeLine{00152\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (node-\/>getBackDirection()\ ==\ d\ \&\&\ node-\/>getLayer()\ ==\ head-\/>getLayer()\ \&\&\ !node-\/>hasFlags(NAV\_POINT\_FLAG\_SOURCE))}
\DoxyCodeLine{00153\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{continue};}
\DoxyCodeLine{00154\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (!d.isVertical())}
\DoxyCodeLine{00155\ \ \ \ \ \ \ \ \ \ \ \ \ T-\/>\_append(head-\/>getSegmentTo(*node,\ \&mNav));}
\DoxyCodeLine{00156\ \ \ \ \ \ \ \ \ head\ =\ node;}
\DoxyCodeLine{00157\ \ \ \ \ \ \ \ \ d\ =\ node-\/>getBackDirection();}
\DoxyCodeLine{00158\ \ \ \ \ \}}
\DoxyCodeLine{00159\ \ \ \ \ assert(head\ ==\ node);}
\DoxyCodeLine{00160\ \ \ \ \ T-\/>\_setEnd(node-\/>getRefPoint25(\&mNav));}
\DoxyCodeLine{00161\ \ \ \ \ route.\mbox{\hyperlink{classConnection_a9a9a6074a3742bee55f86b7d180028d1}{forceRouted}}();}
\DoxyCodeLine{00162\ \ \ \ \ T-\/>autocreateVias(T-\/>end()\ ==\ node-\/>getRefPoint25(\&mNav)\ ?\ T-\/>end()\ :\ route.target());}
\DoxyCodeLine{00163\ \ \ \ \ T-\/>computeLength();}
\DoxyCodeLine{00164\ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{true};}
\DoxyCodeLine{00165\ \}}
\DoxyCodeLine{00166\ }
\DoxyCodeLine{00167\ \textcolor{keywordtype}{void}\ AStar::addViolation(\textcolor{keyword}{const}\ \mbox{\hyperlink{classNavPoint}{NavPoint}}\ *node,\ Real\ radius)}
\DoxyCodeLine{00168\ \{}
\DoxyCodeLine{00169\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ v\ =\ node-\/>getRefPoint25(\&mNav);}
\DoxyCodeLine{00170\ \ \ \ \ \textcolor{keywordflow}{if}\ (mViolationLocs.empty()\ ||}
\DoxyCodeLine{00171\ \ \ \ \ \ \ \ \ mViolationLocs.back().z()\ !=\ v.z()\ ||}
\DoxyCodeLine{00172\ \ \ \ \ \ \ \ \ CGAL::squared\_distance(v.xy(),\ mViolationLocs.back().xy())\ >\ radius)}
\DoxyCodeLine{00173\ \ \ \ \ \ \ \ \ mViolationLocs.push\_back(v);}
\DoxyCodeLine{00174\ \}}
\DoxyCodeLine{00175\ }
\DoxyCodeLine{00176\ \textcolor{keywordtype}{int}\ AStar::getApproxBlockageSearchArea(\textcolor{keyword}{const}\ \mbox{\hyperlink{classPin}{Pin}}\ *T)\textcolor{keyword}{\ const}}
\DoxyCodeLine{00177\ \textcolor{keyword}{}\{}
\DoxyCodeLine{00178\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ e\ =\ mNav.EdgeLen;}
\DoxyCodeLine{00179\ \ \ \ \ \textcolor{keywordflow}{if}\ (!T)}
\DoxyCodeLine{00180\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 384;}
\DoxyCodeLine{00181\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{int}\ nx\ =\ int((T-\/>getBbox().xmax()\ -\/\ T-\/>getBbox().xmin()\ +\ e)\ /\ e);}
\DoxyCodeLine{00182\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{int}\ ny\ =\ int((T-\/>getBbox().xmax()\ -\/\ T-\/>getBbox().xmin()\ +\ e)\ /\ e);}
\DoxyCodeLine{00183\ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{int}\ nA\ =\ nx\ *\ ny;}
\DoxyCodeLine{00184\ \ \ \ \ \textcolor{keywordflow}{return}\ std::max(384,\ std::min(nA\ *\ 8,\ 1024));}
\DoxyCodeLine{00185\ \}}
\DoxyCodeLine{00186\ }
\DoxyCodeLine{00187\ \textcolor{keyword}{inline}\ \textcolor{keywordtype}{float}\ AStar::computeCost(\mbox{\hyperlink{classNavPoint}{NavPoint}}\ *src,\ \mbox{\hyperlink{classNavPoint}{NavPoint}}\ *dst,\ \textcolor{keyword}{const}\ \mbox{\hyperlink{classGridDirection}{GridDirection}}\ d)}
\DoxyCodeLine{00188\ \{}
\DoxyCodeLine{00189\ \ \ \ \ \textcolor{keyword}{auto}\ moveCost\ =\ dst-\/>getCost(0);}
\DoxyCodeLine{00190\ }
\DoxyCodeLine{00191\ \ \ \ \ \textcolor{comment}{//\ Moving\ through\ the\ source\ node\ is\ cheaper:}}
\DoxyCodeLine{00192\ \ \ \ \ \textcolor{keywordflow}{if}\ (dst-\/>hasFlags(NAV\_POINT\_FLAG\_SOURCE))}
\DoxyCodeLine{00193\ \ \ \ \ \ \ \ \ moveCost\ *=\ 0.125f;}
\DoxyCodeLine{00194\ }
\DoxyCodeLine{00195\ \ \ \ \ \textcolor{keywordflow}{if}\ (d.isVertical())\ \{}
\DoxyCodeLine{00196\ \ \ \ \ \ \ \ \ moveCost\ *=\ mViaCost;}
\DoxyCodeLine{00197\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ Using\ the\ same\ via\ costs\ less,\ but\ we\ can't\ make\ the\ cost\ 0\ or\ we'd\ always\ explore\ the\ whole\ layer\ stack\ rather:}}
\DoxyCodeLine{00198\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (src-\/>getBackDirection().isVertical())}
\DoxyCodeLine{00199\ \ \ \ \ \ \ \ \ \ \ \ \ moveCost\ *=\ 0.5f;}
\DoxyCodeLine{00200\ \ \ \ \ \}\ \textcolor{keywordflow}{else}\ \{}
\DoxyCodeLine{00201\ \ \ \ \ \ \ \ \ moveCost\ *=\ mLayerCost[dst-\/>getLayer()];}
\DoxyCodeLine{00202\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (d.\_isDiagonal())}
\DoxyCodeLine{00203\ \ \ \ \ \ \ \ \ \ \ \ \ moveCost\ *=\ std::sqrt(2.0f);}
\DoxyCodeLine{00204\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (dst-\/>hasFlags(NAV\_POINT\_FLAG\_ROUTE\_TRACK\_CLEARANCE))}
\DoxyCodeLine{00205\ \ \ \ \ \ \ \ \ \ \ \ \ moveCost\ *=\ mViolationCost;}
\DoxyCodeLine{00206\ \ \ \ \ \ \ \ \ moveCost\ +=\ mTurnCostPer45Degrees\ *\ math::squared(d.opposite().get45DegreeStepsBetween(src-\/>getBackDirection()));}
\DoxyCodeLine{00207\ \ \ \ \ \}}
\DoxyCodeLine{00208\ \ \ \ \ \textcolor{keywordflow}{return}\ moveCost;}
\DoxyCodeLine{00209\ \}}
\DoxyCodeLine{00210\ }
\DoxyCodeLine{00211\ \textcolor{keyword}{inline}\ \mbox{\hyperlink{classNavPoint}{NavPoint}}\ *AStar::checkHEdge(\textcolor{keyword}{const}\ \mbox{\hyperlink{classNavPoint}{NavPoint}}\ *ref,\ \mbox{\hyperlink{classGridDirection}{GridDirection}}\ d)\textcolor{keyword}{\ const}}
\DoxyCodeLine{00212\ \textcolor{keyword}{}\{}
\DoxyCodeLine{00213\ \ \ \ \ \textcolor{keyword}{auto}\ e\ =\ ref-\/>getEdge(mNav,\ d);}
\DoxyCodeLine{00214\ \ \ \ \ \textcolor{keywordflow}{return}\ (e\ \&\&\ !e-\/>hasFlags(mRouteMask))\ ?\ e\ :\ 0;}
\DoxyCodeLine{00215\ \}}
\DoxyCodeLine{00216\ \textcolor{keyword}{inline}\ \mbox{\hyperlink{classNavPoint}{NavPoint}}\ *AStar::checkVEdge(\textcolor{keyword}{const}\ \mbox{\hyperlink{classNavPoint}{NavPoint}}\ *ref,\ \mbox{\hyperlink{classGridDirection}{GridDirection}}\ d)\textcolor{keyword}{\ const}}
\DoxyCodeLine{00217\ \textcolor{keyword}{}\{}
\DoxyCodeLine{00218\ \ \ \ \ \textcolor{keywordflow}{if}\ (!ref-\/>canPlaceVia())}
\DoxyCodeLine{00219\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ 0;}
\DoxyCodeLine{00220\ \ \ \ \ \textcolor{keyword}{auto}\ e\ =\ ref-\/>getEdge(mNav,\ d);}
\DoxyCodeLine{00221\ \ \ \ \ \textcolor{keywordflow}{return}\ (e\ \&\&\ ref-\/>canAddVia(*e))\ ?\ e\ :\ 0;}
\DoxyCodeLine{00222\ \}}
\DoxyCodeLine{00223\ }
\DoxyCodeLine{00224\ \textcolor{preprocessor}{\#define\ PERF\_COUNTER\_T(i)\ \ \ \ auto\ \_\_t\#\#i\ =\ std::chrono::high\_resolution\_clock::now()}}
\DoxyCodeLine{00225\ \textcolor{preprocessor}{\#define\ PERF\_COUNTER\_D(a,\ b)\ std::chrono::duration\_cast<std::chrono::nanoseconds>(\_\_t\#\#b\ -\/\ \_\_t\#\#a).count()}}
\DoxyCodeLine{00226\ }
\DoxyCodeLine{00227\ \textcolor{keywordtype}{bool}\ AStar::search(\mbox{\hyperlink{classConnection}{Connection}}\ \&route)}
\DoxyCodeLine{00228\ \{}
\DoxyCodeLine{00229\ \ \ \ \ DEBUG(\textcolor{stringliteral}{"{}A*\ from\ "{}}\ <<\ route.source()\ <<\ \textcolor{stringliteral}{"{}\ to\ "{}}\ <<\ route.target());}
\DoxyCodeLine{00230\ }
\DoxyCodeLine{00231\ \ \ \ \ \textcolor{keywordflow}{if}\ (route.hasTracks()\ ||\ route.isRouted())}
\DoxyCodeLine{00232\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{throw}\ std::runtime\_error(\textcolor{stringliteral}{"{}Connection\ pass\ to\ A*\ must\ have\ an\ empty\ track."{}});}
\DoxyCodeLine{00233\ }
\DoxyCodeLine{00234\ \ \ \ \ \textcolor{comment}{//\ Search\ in\ reverse\ so\ reconstruct\ goes\ in\ the\ right\ direction.}}
\DoxyCodeLine{00235\ \ \ \ \ \textcolor{keyword}{auto}\ target\ =\ mNav.getPoint(route.source());}
\DoxyCodeLine{00236\ \ \ \ \ \textcolor{keyword}{auto}\ source\ =\ mNav.getPoint(route.target());}
\DoxyCodeLine{00237\ \ \ \ \ \textcolor{keywordflow}{if}\ (!target\ ||\ !source\ ||\ source\ ==\ target)}
\DoxyCodeLine{00238\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{false};}
\DoxyCodeLine{00239\ \ \ \ \ initCosts(route);}
\DoxyCodeLine{00240\ }
\DoxyCodeLine{00241\ \ \ \ \ \textcolor{keywordtype}{int}\ sourceZ[2];}
\DoxyCodeLine{00242\ \ \ \ \ \textcolor{keywordtype}{int}\ targetZ[2];}
\DoxyCodeLine{00243\ \ \ \ \ sourceZ[0]\ =\ route.targetPin()\ ?\ route.targetPin()-\/>minLayer()\ :\ source-\/>getLayer();}
\DoxyCodeLine{00244\ \ \ \ \ targetZ[0]\ =\ route.sourcePin()\ ?\ route.sourcePin()-\/>minLayer()\ :\ target-\/>getLayer();}
\DoxyCodeLine{00245\ \ \ \ \ sourceZ[1]\ =\ route.targetPin()\ ?\ route.targetPin()-\/>maxLayer()\ :\ source-\/>getLayer();}
\DoxyCodeLine{00246\ \ \ \ \ targetZ[1]\ =\ route.sourcePin()\ ?\ route.sourcePin()-\/>maxLayer()\ :\ target-\/>getLayer();}
\DoxyCodeLine{00247\ }
\DoxyCodeLine{00248\ \ \ \ \ \textcolor{comment}{//\ First\ test\ if\ we're\ blocked\ off\ (rv\ <\ 0).}}
\DoxyCodeLine{00249\ \ \ \ \ initEndPoint(target-\/>getRefPoint(\&mNav),\ targetZ,\ 0,\ \textcolor{keyword}{true});}
\DoxyCodeLine{00250\ \ \ \ \ initEndPoint(source-\/>getRefPoint(\&mNav),\ sourceZ,\ 1,\ \textcolor{keyword}{true});}
\DoxyCodeLine{00251\ \ \ \ \ \textcolor{keyword}{auto}\ rv\ =\ \_search(target,\ source,\ getApproxBlockageSearchArea(route.sourcePin()));}
\DoxyCodeLine{00252\ \ \ \ \ \textcolor{keywordflow}{if}\ (rv\ >=\ 0)\ \{}
\DoxyCodeLine{00253\ \ \ \ \ \ \ \ \ initEndPoint(source-\/>getRefPoint(\&mNav),\ sourceZ,\ 0,\ \textcolor{keyword}{false});}
\DoxyCodeLine{00254\ \ \ \ \ \ \ \ \ initEndPoint(target-\/>getRefPoint(\&mNav),\ targetZ,\ 1,\ \textcolor{keyword}{false});}
\DoxyCodeLine{00255\ \ \ \ \ \ \ \ \ rv\ =\ \_search(source,\ target,\ std::numeric\_limits<int>::max());}
\DoxyCodeLine{00256\ \ \ \ \ \}}
\DoxyCodeLine{00257\ \ \ \ \ DEBUG(\textcolor{stringliteral}{"{}A*\ "{}}\ <<\ ((rv\ >\ 0)\ ?\ \textcolor{stringliteral}{"{}finished"{}}\ :\ \textcolor{stringliteral}{"{}failed"{}})\ <<\ \textcolor{stringliteral}{"{}\ after\ "{}}\ <<\ ((rv\ >\ 0)\ ?\ (std::numeric\_limits<int>::max()\ -\/\ rv)\ :\ -\/rv)\ <<\ \textcolor{stringliteral}{"{}\ nodes."{}});}
\DoxyCodeLine{00258\ }
\DoxyCodeLine{00259\ \ \ \ \ \textcolor{keyword}{auto}\ ret\ =\ (rv\ >\ 0)\ \&\&\ reconstruct(route);}
\DoxyCodeLine{00260\ \ \ \ \ \textcolor{keywordflow}{if}\ (rv\ <=\ 0)\ \{}
\DoxyCodeLine{00261\ \ \ \ \ \ \ \ \ std::lock\_guard\ wlock(mNav.getPCB().getLock());}
\DoxyCodeLine{00262\ \ \ \ \ \ \ \ \ route.clearTracks();}
\DoxyCodeLine{00263\ \ \ \ \ \}}
\DoxyCodeLine{00264\ \ \ \ \ finiEndPoint(source-\/>getRefPoint(\&mNav),\ sourceZ);}
\DoxyCodeLine{00265\ \ \ \ \ finiEndPoint(target-\/>getRefPoint(\&mNav),\ targetZ);}
\DoxyCodeLine{00266\ \ \ \ \ \textcolor{keywordflow}{return}\ ret;}
\DoxyCodeLine{00267\ \}}
\DoxyCodeLine{00268\ \textcolor{keywordtype}{int}\ AStar::\_search(\mbox{\hyperlink{classNavPoint}{NavPoint}}\ *source,\ \mbox{\hyperlink{classNavPoint}{NavPoint}}\ *target,\ \textcolor{keywordtype}{int}\ maxVisits)}
\DoxyCodeLine{00269\ \{}
\DoxyCodeLine{00270\ \ \ \ \ assert(source\ \&\&\ target\ \&\&\ source\ !=\ target);}
\DoxyCodeLine{00271\ \ \ \ \ mTargetXY\ =\ target-\/>getRefPoint(\&mNav);}
\DoxyCodeLine{00272\ \ \ \ \ mSourceXY\ =\ source-\/>getRefPoint(\&mNav);}
\DoxyCodeLine{00273\ \ \ \ \ \textcolor{keywordflow}{return}\ \_search(source,\ maxVisits);}
\DoxyCodeLine{00274\ \}}
\DoxyCodeLine{00275\ \textcolor{keywordtype}{int}\ AStar::\_search(\mbox{\hyperlink{classNavPoint}{NavPoint}}\ *source,\ \textcolor{keywordtype}{int}\ maxVisits)}
\DoxyCodeLine{00276\ \{}
\DoxyCodeLine{00277\ \ \ \ \ \textcolor{keyword}{const}\ uint\ seq\ =\ mNav.nextSearchSeq();}
\DoxyCodeLine{00278\ }
\DoxyCodeLine{00279\ \ \ \ \ source-\/>setScore(0);}
\DoxyCodeLine{00280\ \ \ \ \ source-\/>setBackDirection(GridDirection::Z().n());}
\DoxyCodeLine{00281\ \ \ \ \ source-\/>getVisits().setOpen(seq);}
\DoxyCodeLine{00282\ }
\DoxyCodeLine{00283\ \ \ \ \ std::priority\_queue<NavPointRef>\ openList;}
\DoxyCodeLine{00284\ \ \ \ \ openList.push(NavPointRef(source,\ heuristic(*source)));}
\DoxyCodeLine{00285\ \ \ \ \ \textcolor{keywordflow}{while}\ (!openList.empty())\ \{}
\DoxyCodeLine{00286\ \ \ \ \ \ \ \ \ \textcolor{keyword}{auto}\ current\ =\ openList.top().getPoint();}
\DoxyCodeLine{00287\ \ \ \ \ \ \ \ \ openList.pop();}
\DoxyCodeLine{00288\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (!current-\/>getVisits().isOpen(seq))\ \textcolor{comment}{//\ duplicate\ entry\ already\ encountered\ sooner}}
\DoxyCodeLine{00289\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{continue};}
\DoxyCodeLine{00290\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (current-\/>hasFlags(NAV\_POINT\_FLAG\_TARGET))\ \{}
\DoxyCodeLine{00291\ \ \ \ \ \ \ \ \ \ \ \ \ mTarget\ =\ current;}
\DoxyCodeLine{00292\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ maxVisits;}
\DoxyCodeLine{00293\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00294\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (!-\/-\/maxVisits)}
\DoxyCodeLine{00295\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{00296\ \ \ \ \ \ \ \ \ current-\/>getVisits().setDone(seq);}
\DoxyCodeLine{00297\ }
\DoxyCodeLine{00298\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ FIXME:\ The\ no-\/cross\ check\ is\ still\ no\ sufficient\ for\ correctness.}}
\DoxyCodeLine{00299\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ We\ can\ have\ conditions\ where\ unroute-\/reroute\ does\ not\ work:}}
\DoxyCodeLine{00300\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ \ \ A\ B}}
\DoxyCodeLine{00301\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ \ A\ B}}
\DoxyCodeLine{00302\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ A\ BCCC\ <-\/-\/\ C\ can\ be\ routed\ or\ be\ a\ via,\ but\ then\ B\ becomes\ illegal}}
\DoxyCodeLine{00303\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ \ \ \ CCC}}
\DoxyCodeLine{00304\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ \ \ \ CCC}}
\DoxyCodeLine{00305\ \ \ \ \ \ \ \ \ NavPoint\ *edges[GridDirection::Count];}
\DoxyCodeLine{00306\ \ \ \ \ \ \ \ \ edges[GridDirection::U().n()]\ =\ checkHEdge(current,\ GridDirection::U());}
\DoxyCodeLine{00307\ \ \ \ \ \ \ \ \ edges[GridDirection::D().n()]\ =\ checkHEdge(current,\ GridDirection::D());}
\DoxyCodeLine{00308\ \ \ \ \ \ \ \ \ edges[GridDirection::L().n()]\ =\ checkHEdge(current,\ GridDirection::L());}
\DoxyCodeLine{00309\ \ \ \ \ \ \ \ \ edges[GridDirection::R().n()]\ =\ checkHEdge(current,\ GridDirection::R());}
\DoxyCodeLine{00310\ \ \ \ \ \ \ \ \ edges[GridDirection::UR().n()]\ =\ ((edges[GridDirection::U().n()]\ \&\&\ edges[GridDirection::R().n()])\ ||\ ASTAR\_ALLOW\_XOVER)\ ?\ checkHEdge(current,\ GridDirection::UR())\ :\ 0;}
\DoxyCodeLine{00311\ \ \ \ \ \ \ \ \ edges[GridDirection::DR().n()]\ =\ ((edges[GridDirection::D().n()]\ \&\&\ edges[GridDirection::R().n()])\ ||\ ASTAR\_ALLOW\_XOVER)\ ?\ checkHEdge(current,\ GridDirection::DR())\ :\ 0;}
\DoxyCodeLine{00312\ \ \ \ \ \ \ \ \ edges[GridDirection::DL().n()]\ =\ ((edges[GridDirection::D().n()]\ \&\&\ edges[GridDirection::L().n()])\ ||\ ASTAR\_ALLOW\_XOVER)\ ?\ checkHEdge(current,\ GridDirection::DL())\ :\ 0;}
\DoxyCodeLine{00313\ \ \ \ \ \ \ \ \ edges[GridDirection::UL().n()]\ =\ ((edges[GridDirection::U().n()]\ \&\&\ edges[GridDirection::L().n()])\ ||\ ASTAR\_ALLOW\_XOVER)\ ?\ checkHEdge(current,\ GridDirection::UL())\ :\ 0;}
\DoxyCodeLine{00314\ \ \ \ \ \ \ \ \ edges[GridDirection::A().n()]\ =\ checkVEdge(current,\ GridDirection::A());}
\DoxyCodeLine{00315\ \ \ \ \ \ \ \ \ edges[GridDirection::V().n()]\ =\ checkVEdge(current,\ GridDirection::V());}
\DoxyCodeLine{00316\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ backd\ =\ current-\/>getBackDirection();}
\DoxyCodeLine{00317\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (!backd.isZero())}
\DoxyCodeLine{00318\ \ \ \ \ \ \ \ \ \ \ \ \ edges[backd.n()]\ =\ 0;\ \textcolor{comment}{//\ no\ need\ to\ check\ going\ right\ back}}
\DoxyCodeLine{00319\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (backd.is2D())\ \{}
\DoxyCodeLine{00320\ \ \ \ \ \ \ \ \ \ \ \ \ edges[backd.rotatedCcw45().n()]\ =\ 0;\ \textcolor{comment}{//\ these\ will\ never\ be\ better\ as\ edge\ costs\ are\ node\ costs\ and\ never\ negative}}
\DoxyCodeLine{00321\ \ \ \ \ \ \ \ \ \ \ \ \ edges[backd.rotatedCw45().n()]\ =\ 0;}
\DoxyCodeLine{00322\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00323\ }
\DoxyCodeLine{00324\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keyword}{auto}\ d\ =\ GridDirection::begin();\ d\ !=\ (current-\/>canPlaceVia()\ ?\ GridDirection::vend()\ :\ GridDirection::hend());\ ++d)\ \{}
\DoxyCodeLine{00325\ \ \ \ \ \ \ \ \ \ \ \ \ NavPoint\ *node\ =\ edges[d.n()];}
\DoxyCodeLine{00326\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (!node)}
\DoxyCodeLine{00327\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{continue};}
\DoxyCodeLine{00328\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ score\ =\ current-\/>getScore()\ +\ computeCost(current,\ node,\ d);}
\DoxyCodeLine{00329\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (node-\/>getVisits().isSeen(seq)\ \&\&\ score\ >=\ node-\/>getScore())}
\DoxyCodeLine{00330\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{continue};}
\DoxyCodeLine{00331\ \ \ \ \ \ \ \ \ \ \ \ \ node-\/>setBackDirection(d.opposite());}
\DoxyCodeLine{00332\ \ \ \ \ \ \ \ \ \ \ \ \ node-\/>setScore(score);}
\DoxyCodeLine{00333\ \ \ \ \ \ \ \ \ \ \ \ \ node-\/>getVisits().setOpen(seq);}
\DoxyCodeLine{00334\ \ \ \ \ \ \ \ \ \ \ \ \ openList.push(NavPointRef(node,\ heuristic(*node)));}
\DoxyCodeLine{00335\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00336\ \textcolor{preprocessor}{\#if\ GYM\_PCB\_ENABLE\_UI}}
\DoxyCodeLine{00337\ \ \ \ \ \ \ \ \ mNav.getPCB().setChanged(PCB\_CHANGED\_NAV\_GRID);}
\DoxyCodeLine{00338\ \ \ \ \ \ \ \ \ UserSettings::get().sleepForActionDelay();}
\DoxyCodeLine{00339\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00340\ \ \ \ \ \}}
\DoxyCodeLine{00341\ \ \ \ \ \textcolor{keywordflow}{return}\ -\/maxVisits;}
\DoxyCodeLine{00342\ \}}
\DoxyCodeLine{00343\ }
\DoxyCodeLine{00344\ \textcolor{keywordtype}{void}\ AStar::initCosts(\textcolor{keyword}{const}\ \mbox{\hyperlink{classConnection}{Connection}}\ \&X)}
\DoxyCodeLine{00345\ \{}
\DoxyCodeLine{00346\ \ \ \ \ assert(mCostParams.valid());}
\DoxyCodeLine{00347\ \ \ \ \ \textcolor{keyword}{const}\ uint\ dirMask\ =\ (!X.hasNet()\ ||\ !X.net()-\/>isGroundOrPower())\ ?\ 0x1\ :\ 0x0;}
\DoxyCodeLine{00348\ }
\DoxyCodeLine{00349\ \ \ \ \ mLayerCost.resize(mNav.getSize(2),\ 0.0f);}
\DoxyCodeLine{00350\ \ \ \ \ \textcolor{keywordflow}{for}\ (uint\ z\ =\ 0;\ z\ <\ mLayerCost.size();\ ++z)\ \{}
\DoxyCodeLine{00351\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (!X.canRouteOnLayer(z))}
\DoxyCodeLine{00352\ \ \ \ \ \ \ \ \ \ \ \ \ mLayerCost[z]\ =\ mCostParams.MaskedLayer;}
\DoxyCodeLine{00353\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}\ \textcolor{keywordflow}{if}\ (z\ \&\ dirMask)}
\DoxyCodeLine{00354\ \ \ \ \ \ \ \ \ \ \ \ \ mLayerCost[z]\ =\ mCostParams.WrongDirection;}
\DoxyCodeLine{00355\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{00356\ \ \ \ \ \ \ \ \ \ \ \ \ mLayerCost[z]\ =\ 1.0f;}
\DoxyCodeLine{00357\ \ \ \ \ \}}
\DoxyCodeLine{00358\ \ \ \ \ mViaCost\ =\ mCostParams.Via\ *\ X.defaultViaDiameter();}
\DoxyCodeLine{00359\ \ \ \ \ mViolationCost\ =\ mCostParams.Violation;}
\DoxyCodeLine{00360\ }
\DoxyCodeLine{00361\ \ \ \ \ \textcolor{keywordflow}{if}\ (std::isinf(mCostParams.Violation))}
\DoxyCodeLine{00362\ \ \ \ \ \ \ \ \ mRouteMask\ |=\ NAV\_POINT\_FLAG\_ROUTE\_TRACK\_CLEARANCE;}
\DoxyCodeLine{00363\ \ \ \ \ \textcolor{keywordflow}{else}}
\DoxyCodeLine{00364\ \ \ \ \ \ \ \ \ mRouteMask\ \&=\ \string~NAV\_POINT\_FLAG\_ROUTE\_TRACK\_CLEARANCE;}
\DoxyCodeLine{00365\ \}}
\DoxyCodeLine{00366\ }
\DoxyCodeLine{00367\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ GYM\_PCB\_ASTAR\_H}}

\end{DoxyCode}
