]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/trainroutemetric.cpp
Sprinkle some comments on the routing system
[r2c2.git] / source / libr2c2 / trainroutemetric.cpp
index 7e4d4856fe91a484f794470ce8a2e66a03151b96..469fc9494715dfea68be9517b7a71f1b783d8b89 100644 (file)
@@ -9,6 +9,9 @@ namespace R2C2 {
 
 TrainRouteMetric::TrainRouteMetric(const TrackChain &tc, TrackChain::Direction dir)
 {
+       /* Initialize goals for tracks in the target chain.  We travel outwards from
+       the target in the search phase so the iters appear to point the wrong way. */
+       TrackChain::Direction reverse_dir = (dir==TrackChain::DOWN ? TrackChain::UP : TrackChain::DOWN);
        const TrackChain::TrackSet &ctracks = tc.get_tracks();
        for(TrackChain::TrackSet::const_iterator i=ctracks.begin(); i!=ctracks.end(); ++i)
        {
@@ -31,6 +34,9 @@ TrainRouteMetric::TrainRouteMetric(const TrackChain &tc, TrackChain::Direction d
                queue.push_back(i->track);
        }
 
+       /* Use Dijkstra's algorithm to find the shortest distance from the goal to
+       every reachable track in the layout.  Entry points here become exit points
+       when looking up distances to the goal. */
        while(!queue.empty())
        {
                TrackIter track = queue.front();