SUMO - Simulation of Urban MObility
MSNoLogicJunction.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // -------------------
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2002-2017 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 "MSNoLogicJunction.h"
34 #include "MSLane.h"
35 #include <algorithm>
36 #include <cassert>
37 #include <cmath>
38 
39 
40 // ===========================================================================
41 // static member definitions
42 // ===========================================================================
43 
44 // ===========================================================================
45 // method definitions
46 // ===========================================================================
48  SumoXMLNodeType type,
49  const Position& position,
50  const PositionVector& shape,
51  std::vector<MSLane*> incoming, std::vector<MSLane*> internal):
52  MSJunction(id, type, position, shape),
53  myIncomingLanes(incoming),
54  myInternalLanes(internal) {
55 }
56 
57 
59 
60 
61 void
63  std::vector<MSLane*>::iterator i;
64  // inform links where they have to report approaching vehicles to
65  for (i = myIncomingLanes.begin(); i != myIncomingLanes.end(); ++i) {
66  const MSLinkCont& links = (*i)->getLinkCont();
67  for (MSLinkCont::const_iterator j = links.begin(); j != links.end(); j++) {
68  (*j)->setRequestInformation(-1, false, false, std::vector<MSLink*>(), std::vector<MSLane*>());
69  }
70  }
71 }
72 
73 
74 const std::vector<MSLane*>
76  // Besides the lanes im myInternal lanes, which are only the last parts of the connections,
77  // this collects all lanes on the junction
78  std::vector<MSLane*> allInternalLanes;
79  for (std::vector<MSLane*>::const_iterator i = myInternalLanes.begin(); i != myInternalLanes.end(); ++i) {
80  MSLane* l = *i;
81  while (l != 0) {
82  allInternalLanes.push_back(l);
83  const std::vector<MSLane::IncomingLaneInfo> incoming = l->getIncomingLanes();
84  if (incoming.size() == 0) {
85  break;
86  }
87  assert(l->getIncomingLanes().size() == 1);
88  l = l->getIncomingLanes()[0].lane;
89  if (!l->isInternal()) {
90  break;
91  }
92  }
93  }
94  return allInternalLanes;
95 }
96 
97 
98 
99 /****************************************************************************/
100 
MSNoLogicJunction(const std::string &id, SumoXMLNodeType type, const Position &position, const PositionVector &shape, std::vector< MSLane * > incoming, std::vector< MSLane * > internal)
Constructor.
std::vector< MSLane * > myIncomingLanes
The base class for an intersection.
Definition: MSJunction.h:64
virtual ~MSNoLogicJunction()
Destructor.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A list of positions.
virtual const std::vector< MSLane * > getInternalLanes() const
Returns all internal lanes on the junction.
std::vector< MSLane * > myInternalLanes
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
Definition: MSLane.h:727
Representation of a lane in the micro simulation.
Definition: MSLane.h:79