RORouteDef_OrigDest.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 <string>
00031 #include <iostream>
00032 #include <cassert>
00033 #include "ROEdge.h"
00034 #include "RORouteDef.h"
00035 #include "RORoute.h"
00036 #include "RORouteDef_OrigDest.h"
00037 #include <utils/common/SUMOAbstractRouter.h>
00038 #include "ROVehicle.h"
00039 #include "ROHelper.h"
00040 #include <utils/common/MsgHandler.h>
00041 #include <utils/iodevices/OutputDevice.h>
00042
00043 #ifdef CHECK_MEMORY_LEAKS
00044 #include <foreign/nvwa/debug_new.h>
00045 #endif // CHECK_MEMORY_LEAKS
00046
00047
00048
00049
00050
00051 RORouteDef_OrigDest::RORouteDef_OrigDest(const std::string &id,
00052 const RGBColor * const color,
00053 const ROEdge *from,
00054 const ROEdge *to,
00055 bool removeFirst) throw()
00056 : RORouteDef(id, color), myFrom(from), myTo(to), myCurrent(0),
00057 myRemoveFirst(removeFirst) {}
00058
00059
00060 RORouteDef_OrigDest::~RORouteDef_OrigDest() throw() {
00061 delete myCurrent;
00062 }
00063
00064
00065 RORoute *
00066 RORouteDef_OrigDest::buildCurrentRoute(SUMOAbstractRouter<ROEdge,ROVehicle> &router,
00067 SUMOTime begin, const ROVehicle &veh) const {
00068 std::vector<const ROEdge*> edges;
00069 router.compute(myFrom, myTo, &veh, begin, edges);
00070 if (myRemoveFirst&&edges.size()>2) {
00071 edges.erase(edges.begin());
00072 edges.erase(edges.end()-1);
00073 }
00074 return new RORoute(myID, 0, 1, edges, copyColorIfGiven());
00075 }
00076
00077
00078 void
00079 RORouteDef_OrigDest::addAlternative(SUMOAbstractRouter<ROEdge,ROVehicle> &router,
00080 const ROVehicle *const veh, RORoute *current, SUMOTime begin) {
00081 myCurrent = current;
00082 myStartTime = begin;
00083 current->setCosts(router.recomputeCosts(current->getEdgeVector(), veh, begin));
00084 }
00085
00086
00087 RORouteDef *
00088 RORouteDef_OrigDest::copy(const std::string &id) const {
00089 return new RORouteDef_OrigDest(id, copyColorIfGiven(), myFrom, myTo,
00090 myRemoveFirst);
00091 }
00092
00093
00094 OutputDevice &
00095 RORouteDef_OrigDest::writeXMLDefinition(SUMOAbstractRouter<ROEdge,ROVehicle> &router,
00096 OutputDevice &dev, const ROVehicle * const veh, bool asAlternatives, bool withExitTimes) const {
00097 return myCurrent->writeXMLDefinition(router, dev, veh, asAlternatives, withExitTimes);
00098 }
00099
00100
00101
00102