SUMO - Simulation of Urban MObility

MSInternalJunction.cpp

Go to the documentation of this file.
00001 /****************************************************************************/
00009 // junction.
00010 /****************************************************************************/
00011 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00012 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00013 /****************************************************************************/
00014 //
00015 //   This file is part of SUMO.
00016 //   SUMO is free software: you can redistribute it and/or modify
00017 //   it under the terms of the GNU General Public License as published by
00018 //   the Free Software Foundation, either version 3 of the License, or
00019 //   (at your option) any later version.
00020 //
00021 /****************************************************************************/
00022 
00023 
00024 // ===========================================================================
00025 // included modules
00026 // ===========================================================================
00027 #ifdef _MSC_VER
00028 #include <windows_config.h>
00029 #else
00030 #include <config.h>
00031 #endif
00032 
00033 #include "MSInternalJunction.h"
00034 #include "MSLane.h"
00035 #include "MSJunctionLogic.h"
00036 #include "MSBitSetLogic.h"
00037 #include <algorithm>
00038 #include <cassert>
00039 #include <cmath>
00040 
00041 #ifdef CHECK_MEMORY_LEAKS
00042 #include <foreign/nvwa/debug_new.h>
00043 #endif // CHECK_MEMORY_LEAKS
00044 
00045 
00046 // ===========================================================================
00047 // method definitions
00048 // ===========================================================================
00049 #ifdef HAVE_INTERNAL_LANES
00050 MSInternalJunction::MSInternalJunction(const std::string& id,
00051                                        const Position& position,
00052                                        const PositionVector& shape,
00053                                        std::vector<MSLane*> incoming,
00054                                        std::vector<MSLane*> internal)
00055     : MSLogicJunction(id, position, shape, incoming, internal) {}
00056 
00057 
00058 
00059 MSInternalJunction::~MSInternalJunction() {}
00060 
00061 
00062 void
00063 MSInternalJunction::postloadInit() {
00064     // inform links where they have to report approaching vehicles to
00065     unsigned int requestPos = 0;
00066     myInternalLaneFoes = myInternalLanes;
00067     for (std::vector<MSLane*>::const_iterator i = myIncomingLanes.begin() + 1; i != myIncomingLanes.end(); ++i) {
00068         MSLane* l = *i;
00069         const MSLinkCont& lc = l->getLinkCont();
00070         for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); ++j) {
00071             MSLane* via = (*j)->getViaLane();
00072             if (std::find(myInternalLanes.begin(), myInternalLanes.end(), via) == myInternalLanes.end()) {
00073                 continue;
00074             }
00075             myInternalLinkFoes.push_back(*j);
00076         }
00077     }
00078     if (myIncomingLanes.size() != 0) {
00079         // for the first incoming lane
00080         const MSLinkCont& links = myIncomingLanes[0]->getLinkCont();
00081         // ... set information for every link
00082         for (MSLinkCont::const_iterator j = links.begin(); j != links.end(); j++) {
00083             (*j)->setRequestInformation(requestPos, requestPos, true, false, myInternalLinkFoes, myInternalLaneFoes);
00084             requestPos++;
00085             for (std::vector<MSLink*>::const_iterator k = myInternalLinkFoes.begin(); k != myInternalLinkFoes.end(); ++k) {
00086                 (*j)->addBlockedLink(*k);
00087                 (*k)->addBlockedLink(*j);
00088             }
00089         }
00090     }
00091 }
00092 
00093 
00094 #endif
00095 
00096 
00097 /****************************************************************************/
00098 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines