|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // Storage for edges, including some functionality operating on multiple edges 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors 00011 /****************************************************************************/ 00012 // 00013 // This program is free software; you can redistribute it and/or modify 00014 // it under the terms of the GNU General Public License as published by 00015 // the Free Software Foundation; either version 2 of the License, or 00016 // (at your option) any later version. 00017 // 00018 /****************************************************************************/ 00019 #ifndef NBEdgeCont_h 00020 #define NBEdgeCont_h 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 <map> 00033 #include <iostream> 00034 #include <string> 00035 #include <vector> 00036 #include <set> 00037 #include "NBCont.h" 00038 #include <utils/common/SUMOVehicleClass.h> 00039 #include <utils/common/UtilExceptions.h> 00040 #include <utils/geom/PositionVector.h> 00041 00042 00043 // =========================================================================== 00044 // class declarations 00045 // =========================================================================== 00046 class NBNodeCont; 00047 class NBTypeCont; 00048 class NBEdge; 00049 class NBNode; 00050 class OptionsCont; 00051 class NBDistrictCont; 00052 class NBTrafficLightLogicCont; 00053 class OutputDevice; 00054 00055 00056 // =========================================================================== 00057 // class definitions 00058 // =========================================================================== 00063 class NBEdgeCont { 00064 public: 00068 NBEdgeCont(NBTypeCont& tc) throw(); 00069 00070 00072 ~NBEdgeCont() throw(); 00073 00074 00083 void applyOptions(OptionsCont& oc); 00084 00085 00087 void clear() throw(); 00088 00089 00090 00091 00094 00108 bool insert(NBEdge* edge, bool ignorePrunning=false) throw(); 00109 00110 00119 NBEdge* retrieve(const std::string& id, bool retrieveExtracted=false) const throw(); 00120 00121 00134 NBEdge* retrievePossiblySplitted(const std::string& id, 00135 const std::string& hint, bool incoming) const throw(); 00136 00137 00148 NBEdge* retrievePossiblySplitted(const std::string& id, SUMOReal pos) const throw(); 00149 00150 00157 void erase(NBDistrictCont& dc, NBEdge* edge) throw(); 00158 00159 00168 void extract(NBDistrictCont& dc, NBEdge* edge, bool remember=false); 00169 00170 00174 std::map<std::string, NBEdge*>::const_iterator begin() const { 00175 return myEdges.begin(); 00176 } 00177 00178 00182 std::map<std::string, NBEdge*>::const_iterator end() const { 00183 return myEdges.end(); 00184 } 00186 00187 00188 00191 00205 bool splitAt(NBDistrictCont& dc, NBEdge* edge, NBNode* node) throw(ProcessError); 00206 00207 00228 bool splitAt(NBDistrictCont& dc, NBEdge* edge, NBNode* node, 00229 const std::string& firstEdgeName, const std::string& secondEdgeName, 00230 unsigned int noLanesFirstEdge, unsigned int noLanesSecondEdge) throw(ProcessError); 00231 00232 00245 bool splitAt(NBDistrictCont& dc, NBEdge* edge, SUMOReal edgepos, NBNode* node, 00246 const std::string& firstEdgeName, const std::string& secondEdgeName, 00247 unsigned int noLanesFirstEdge, unsigned int noLanesSecondEdge) throw(ProcessError); 00249 00250 00251 00254 00258 unsigned int size() const throw() { 00259 return (unsigned int) myEdges.size(); 00260 } 00261 00262 00267 std::vector<std::string> getAllNames() const throw(); 00268 00269 00273 unsigned int getNoEdgeSplits() const throw() { 00274 return myEdgesSplit; 00275 } 00277 00278 00279 00282 00287 void removeUnwishedEdges(NBDistrictCont& dc); 00288 00289 00298 void splitGeometry(NBNodeCont& nc); 00300 00301 00302 00305 00313 void computeTurningDirections() throw(); 00314 00315 00323 void sortOutgoingLanesConnections() throw(); 00324 00325 00334 void computeEdge2Edges(bool noLeftMovers) throw(); 00335 00336 00344 void computeLanes2Edges() throw(); 00345 00346 00354 void recheckLanes() throw(); 00355 00356 00365 void appendTurnarounds(bool noTLSControlled) throw(); 00366 00367 00374 void appendTurnarounds(const std::set<std::string> &ids, bool noTLSControlled); 00375 00376 00385 void computeEdgeShapes() throw(); 00386 00387 00396 void recomputeLaneShapes() throw(); 00397 00398 00401 void clearControllingTLInformation() const; 00402 00403 00411 void joinSameNodeConnectingEdges(NBDistrictCont& dc, 00412 NBTrafficLightLogicCont& tlc, EdgeVector edges) throw(); 00413 00414 00419 void recheckLaneSpread() throw(); 00421 00422 00423 00427 void guessRoundabouts(std::vector<std::set<NBEdge*> > &marked) throw(); 00428 00429 00433 bool isLeftHanded() const throw() { 00434 return myAmLeftHanded; 00435 } 00436 00437 00441 bool wasIgnored(std::string id) const throw() { 00442 return myIgnoredEdges.count(id) != 0; 00443 } 00444 00445 00448 bool wasRemoved(std::string id) const throw() { 00449 return myExtractedEdges.count(id) != 0; 00450 } 00451 00452 00453 private: 00460 EdgeVector getGeneratedFrom(const std::string& id) const throw(); 00461 00462 00463 private: 00465 typedef std::map<std::string, NBEdge*> EdgeCont; 00466 00468 EdgeCont myEdges; 00469 00471 EdgeCont myExtractedEdges; 00472 00474 std::set<std::string> myIgnoredEdges; 00475 00477 unsigned int myEdgesSplit; 00478 00480 bool myAmLeftHanded; 00481 00482 00485 00487 SUMOReal myEdgesMinSpeed; 00488 00490 bool myRemoveEdgesAfterJoining; 00491 00493 std::set<std::string> myEdges2Keep; 00494 00496 std::set<std::string> myEdges2Remove; 00497 00499 SUMOVehicleClasses myVehicleClasses2Keep; 00500 00502 SUMOVehicleClasses myVehicleClasses2Remove; 00503 00505 PositionVector myPrunningBoundary; 00506 00508 00509 00511 NBTypeCont& myTypeCont; 00512 00513 00514 private: 00516 NBEdgeCont(const NBEdgeCont& s); 00517 00519 NBEdgeCont& operator=(const NBEdgeCont& s); 00520 00521 00522 }; 00523 00524 00525 #endif 00526 00527 /****************************************************************************/ 00528