SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00008 // A route where only the origin and the destination edges are known 00009 /****************************************************************************/ 00010 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00011 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00012 /****************************************************************************/ 00013 // 00014 // This file is part of SUMO. 00015 // SUMO is free software: you can redistribute it and/or modify 00016 // it under the terms of the GNU General Public License as published by 00017 // the Free Software Foundation, either version 3 of the License, or 00018 // (at your option) any later version. 00019 // 00020 /****************************************************************************/ 00021 00022 00023 // =========================================================================== 00024 // included modules 00025 // =========================================================================== 00026 #ifdef _MSC_VER 00027 #include <windows_config.h> 00028 #else 00029 #include <config.h> 00030 #endif 00031 00032 #include <string> 00033 #include <iostream> 00034 #include <cassert> 00035 #include "ROEdge.h" 00036 #include "RORouteDef.h" 00037 #include "RORoute.h" 00038 #include "RORouteDef_OrigDest.h" 00039 #include <utils/common/SUMOAbstractRouter.h> 00040 #include "ROVehicle.h" 00041 #include "ROHelper.h" 00042 #include <utils/common/MsgHandler.h> 00043 #include <utils/iodevices/OutputDevice.h> 00044 00045 #ifdef CHECK_MEMORY_LEAKS 00046 #include <foreign/nvwa/debug_new.h> 00047 #endif // CHECK_MEMORY_LEAKS 00048 00049 00050 // =========================================================================== 00051 // member method definitions 00052 // =========================================================================== 00053 RORouteDef_OrigDest::RORouteDef_OrigDest(const std::string& id, 00054 const RGBColor* const color, 00055 const ROEdge* from, 00056 const ROEdge* to, 00057 bool removeFirst) 00058 : RORouteDef(id, color), myFrom(from), myTo(to), myCurrent(0), 00059 myRemoveFirst(removeFirst) {} 00060 00061 00062 RORouteDef_OrigDest::~RORouteDef_OrigDest() { 00063 delete myCurrent; 00064 } 00065 00066 00067 void 00068 RORouteDef_OrigDest::preComputeCurrentRoute(SUMOAbstractRouter<ROEdge, ROVehicle> &router, 00069 SUMOTime begin, const ROVehicle& veh) const { 00070 std::vector<const ROEdge*> edges; 00071 router.compute(myFrom, myTo, &veh, begin, edges); 00072 if (myRemoveFirst && edges.size() > 2) { 00073 edges.erase(edges.begin()); 00074 edges.erase(edges.end() - 1); 00075 } 00076 myPrecomputed = new RORoute(myID, 0, 1, edges, copyColorIfGiven()); 00077 } 00078 00079 00080 void 00081 RORouteDef_OrigDest::addAlternative(SUMOAbstractRouter<ROEdge, ROVehicle> &router, 00082 const ROVehicle* const veh, RORoute* current, SUMOTime begin) { 00083 myCurrent = current; 00084 myStartTime = begin; 00085 current->setCosts(router.recomputeCosts(current->getEdgeVector(), veh, begin)); 00086 } 00087 00088 00089 RORouteDef* 00090 RORouteDef_OrigDest::copy(const std::string& id) const { 00091 return new RORouteDef_OrigDest(id, copyColorIfGiven(), myFrom, myTo, 00092 myRemoveFirst); 00093 } 00094 00095 00096 OutputDevice& 00097 RORouteDef_OrigDest::writeXMLDefinition(SUMOAbstractRouter<ROEdge, ROVehicle> &router, 00098 OutputDevice& dev, const ROVehicle* const veh, bool asAlternatives, bool withExitTimes) const { 00099 return myCurrent->writeXMLDefinition(router, dev, veh, asAlternatives, withExitTimes); 00100 } 00101 00102 00103 const ROEdge* 00104 RORouteDef_OrigDest::getDestination() const { 00105 return myTo; 00106 } 00107 00108 00109 /****************************************************************************/ 00110