SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSInternalJunction.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // junction.
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
12 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include "MSInternalJunction.h"
34 #include "MSLane.h"
35 #include "MSJunctionLogic.h"
36 #include "MSBitSetLogic.h"
37 #include <algorithm>
38 #include <cassert>
39 #include <cmath>
40 
41 #ifdef CHECK_MEMORY_LEAKS
42 #include <foreign/nvwa/debug_new.h>
43 #endif // CHECK_MEMORY_LEAKS
44 
45 
46 // ===========================================================================
47 // method definitions
48 // ===========================================================================
49 #ifdef HAVE_INTERNAL_LANES
50 MSInternalJunction::MSInternalJunction(const std::string& id,
51  const Position& position,
52  const PositionVector& shape,
53  std::vector<MSLane*> incoming,
54  std::vector<MSLane*> internal)
55  : MSLogicJunction(id, position, shape, incoming, internal) {}
56 
57 
58 
59 MSInternalJunction::~MSInternalJunction() {}
60 
61 
62 void
63 MSInternalJunction::postloadInit() {
64  // inform links where they have to report approaching vehicles to
65  unsigned int requestPos = 0;
66  for (std::vector<MSLane*>::iterator i = myInternalLanes.begin(); i != myInternalLanes.end(); ++i) {
67  const MSLinkCont& lc = (*i)->getLinkCont();
68  for (MSLinkCont::const_iterator q = lc.begin(); q != lc.end(); ++q) {
69  if ((*q)->getViaLane() != 0) {
70  myInternalLaneFoes.push_back((*q)->getViaLane());
71  } else {
72  myInternalLaneFoes.push_back(*i);
73  }
74  }
75 
76  }
77  for (std::vector<MSLane*>::const_iterator i = myIncomingLanes.begin() + 1; i != myIncomingLanes.end(); ++i) {
78  MSLane* l = *i;
79  const MSLinkCont& lc = l->getLinkCont();
80  for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); ++j) {
81  MSLane* via = (*j)->getViaLane();
82  if (std::find(myInternalLanes.begin(), myInternalLanes.end(), via) == myInternalLanes.end()) {
83  continue;
84  }
85  myInternalLinkFoes.push_back(*j);
86  }
87  }
88  if (myIncomingLanes.size() != 0) {
89  // for the first incoming lane
90  const MSLinkCont& links = myIncomingLanes[0]->getLinkCont();
91  // ... set information for every link
92  for (MSLinkCont::const_iterator j = links.begin(); j != links.end(); j++) {
93  (*j)->setRequestInformation(requestPos, requestPos, true, false, myInternalLinkFoes, myInternalLaneFoes);
94  requestPos++;
95  for (std::vector<MSLink*>::const_iterator k = myInternalLinkFoes.begin(); k != myInternalLinkFoes.end(); ++k) {
96  (*j)->addBlockedLink(*k);
97  (*k)->addBlockedLink(*j);
98  }
99  }
100  }
101 }
102 
103 
104 #endif
105 
106 
107 /****************************************************************************/
108