1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2002-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
10 /// @file    MSNoLogicJunction.cpp
11 /// @author  Daniel Krajzewicz
12 /// @author  Michael Behrisch
13 /// @author  Jakob Erdmann
14 /// @date    Thu, 06 Jun 2002
15 /// @version $Id$
16 ///
17 // -------------------
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include "MSNoLogicJunction.h"
27 #include "MSLane.h"
28 #include <algorithm>
29 #include <cassert>
30 #include <cmath>
31 
32 
33 // ===========================================================================
34 // static member definitions
35 // ===========================================================================
36 
37 // ===========================================================================
38 // method definitions
39 // ===========================================================================
MSNoLogicJunction(const std::string & id,SumoXMLNodeType type,const Position & position,const PositionVector & shape,std::vector<MSLane * > incoming,std::vector<MSLane * > internal)40 MSNoLogicJunction::MSNoLogicJunction(const std::string& id,
41                                      SumoXMLNodeType type,
42                                      const Position& position,
43                                      const PositionVector& shape,
44                                      std::vector<MSLane*> incoming, std::vector<MSLane*> internal):
45     MSJunction(id, type, position, shape),
46     myIncomingLanes(incoming),
47     myInternalLanes(internal) {
48 }
49 
50 
~MSNoLogicJunction()51 MSNoLogicJunction::~MSNoLogicJunction() {}
52 
53 
54 void
postloadInit()55 MSNoLogicJunction::postloadInit() {
56     std::vector<MSLane*>::iterator i;
57     // inform links where they have to report approaching vehicles to
58     for (i = myIncomingLanes.begin(); i != myIncomingLanes.end(); ++i) {
59         const MSLinkCont& links = (*i)->getLinkCont();
60         for (MSLinkCont::const_iterator j = links.begin(); j != links.end(); j++) {
61             (*j)->setRequestInformation(-1, false, false, std::vector<MSLink*>(), std::vector<MSLane*>());
62         }
63     }
64 }
65 
66 
67 const std::vector<MSLane*>
getInternalLanes() const68 MSNoLogicJunction::getInternalLanes() const {
69     // Besides the lanes im myInternal lanes, which are only the last parts of the connections,
70     // this collects all lanes on the junction
71     std::vector<MSLane*> allInternalLanes;
72     for (std::vector<MSLane*>::const_iterator i = myInternalLanes.begin(); i != myInternalLanes.end(); ++i) {
73         MSLane* l = *i;
74         while (l != nullptr) {
75             allInternalLanes.push_back(l);
76             const std::vector<MSLane::IncomingLaneInfo> incoming = l->getIncomingLanes();
77             if (incoming.size() == 0) {
78                 break;
79             }
80             assert(l->getIncomingLanes().size() == 1);
81             l = l->getIncomingLanes()[0].lane;
82             if (!l->isInternal()) {
83                 break;
84             }
85         }
86     }
87     return allInternalLanes;
88 }
89 
90 
91 
92 /****************************************************************************/
93 
94