ROJTRRouter.cpp
Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifdef _MSC_VER
00025 #include <windows_config.h>
00026 #else
00027 #include <config.h>
00028 #endif
00029
00030 #include <router/RONet.h>
00031 #include "ROJTRRouter.h"
00032 #include "ROJTREdge.h"
00033 #include <utils/common/MsgHandler.h>
00034 #include <utils/options/OptionsCont.h>
00035
00036 #ifdef CHECK_MEMORY_LEAKS
00037 #include <foreign/nvwa/debug_new.h>
00038 #endif // CHECK_MEMORY_LEAKS
00039
00040
00041
00042
00043
00044 ROJTRRouter::ROJTRRouter(RONet &net, bool unbuildIsWarningOnly,
00045 bool acceptAllDestinations)
00046 : myNet(net), myUnbuildIsWarningOnly(unbuildIsWarningOnly),
00047 myAcceptAllDestination(acceptAllDestinations) {
00048 myMaxEdges = (int)(
00049 ((SUMOReal) net.getEdgeNo()) *
00050 OptionsCont::getOptions().getFloat("max-edges-factor"));
00051 myIgnoreClasses = OptionsCont::getOptions().getBool("ignore-classes");
00052 }
00053
00054
00055 ROJTRRouter::~ROJTRRouter() {}
00056
00057
00058 void
00059 ROJTRRouter::compute(const ROEdge *from, const ROEdge * ,
00060 const ROVehicle * const vehicle,
00061 SUMOTime time, std::vector<const ROEdge*> &into) {
00062 const ROJTREdge *current = static_cast<const ROJTREdge*>(from);
00063
00064 while (current!=0
00065 &&
00066 current->getType()!=ROEdge::ET_SINK
00067 &&
00068 (int) into.size()<myMaxEdges) {
00069
00070 into.push_back(current);
00071 time += (SUMOTime) current->getTravelTime(vehicle, time);
00072 current = current->chooseNext(myIgnoreClasses ? 0 : vehicle, time);
00073 assert(myIgnoreClasses||current==0||!current->prohibits(vehicle));
00074 }
00075
00076 if ((int) into.size()>=myMaxEdges) {
00077 if (myAcceptAllDestination) {
00078 return;
00079 } else {
00080 MsgHandler *mh = 0;
00081 if (myUnbuildIsWarningOnly) {
00082 mh = MsgHandler::getWarningInstance();
00083 } else {
00084 mh = MsgHandler::getErrorInstance();
00085 }
00086 mh->inform("The route starting at edge '" + from->getID() + "' could not be closed.");
00087 }
00088 }
00089
00090 if (current!=0) {
00091 into.push_back(current);
00092 }
00093 }
00094
00095
00096 SUMOReal
00097 ROJTRRouter::recomputeCosts(const std::vector<const ROEdge*> &edges, const ROVehicle * const v, SUMOTime time) throw() {
00098 SUMOReal costs = 0;
00099 for (std::vector<const ROEdge*>::const_iterator i=edges.begin(); i!=edges.end(); i++) {
00100
00101
00102
00103
00104
00105 costs += (*i)->getTravelTime(v, time);
00106 }
00107 return costs;
00108 }
00109
00110
00111
00112
00113