SUMO - Simulation of Urban MObility

MSInternalJunction.cpp

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // junction.
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 
00020 
00021 // ===========================================================================
00022 // included modules
00023 // ===========================================================================
00024 #ifdef _MSC_VER
00025 #include <windows_config.h>
00026 #else
00027 #include <config.h>
00028 #endif
00029 
00030 #include "MSInternalJunction.h"
00031 #include "MSLane.h"
00032 #include "MSJunctionLogic.h"
00033 #include "MSBitSetLogic.h"
00034 #include <algorithm>
00035 #include <cassert>
00036 #include <cmath>
00037 
00038 #ifdef CHECK_MEMORY_LEAKS
00039 #include <foreign/nvwa/debug_new.h>
00040 #endif // CHECK_MEMORY_LEAKS
00041 
00042 
00043 // ===========================================================================
00044 // method definitions
00045 // ===========================================================================
00046 #ifdef HAVE_INTERNAL_LANES
00047 MSInternalJunction::MSInternalJunction(const std::string& id,
00048                                        const Position& position,
00049                                        const PositionVector& shape,
00050                                        std::vector<MSLane*> incoming,
00051                                        std::vector<MSLane*> internal) throw()
00052     : MSLogicJunction(id, position, shape, incoming, internal) {}
00053 
00054 
00055 
00056 MSInternalJunction::~MSInternalJunction() {}
00057 
00058 
00059 void
00060 MSInternalJunction::postloadInit() throw(ProcessError) {
00061     // inform links where they have to report approaching vehicles to
00062     unsigned int requestPos = 0;
00063     myInternalLaneFoes = myInternalLanes;
00064     for (std::vector<MSLane*>::const_iterator i=myIncomingLanes.begin()+1; i!=myIncomingLanes.end(); ++i) {
00065         MSLane* l = *i;
00066         const MSLinkCont& lc = l->getLinkCont();
00067         for (MSLinkCont::const_iterator j=lc.begin(); j!=lc.end(); ++j) {
00068             MSLane* via = (*j)->getViaLane();
00069             if (std::find(myInternalLanes.begin(), myInternalLanes.end(), via)==myInternalLanes.end()) {
00070                 continue;
00071             }
00072             myInternalLinkFoes.push_back(*j);
00073         }
00074     }
00075     if (myIncomingLanes.size()!=0) {
00076         // for the first incoming lane
00077         const MSLinkCont& links = myIncomingLanes[0]->getLinkCont();
00078         // ... set information for every link
00079         for (MSLinkCont::const_iterator j=links.begin(); j!=links.end(); j++) {
00080             (*j)->setRequestInformation(requestPos, requestPos, true, false, myInternalLinkFoes, myInternalLaneFoes);
00081             requestPos++;
00082             for (std::vector<MSLink*>::const_iterator k=myInternalLinkFoes.begin(); k!=myInternalLinkFoes.end(); ++k) {
00083                 (*j)->addBlockedLink(*k);
00084                 (*k)->addBlockedLink(*j);
00085             }
00086         }
00087     }
00088 }
00089 
00090 
00091 #endif
00092 
00093 
00094 /****************************************************************************/
00095 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines