1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-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    MSLogicJunction.cpp
11 /// @author  Christian Roessel
12 /// @author  Daniel Krajzewicz
13 /// @author  Michael Behrisch
14 /// @author  Jakob Erdmann
15 /// @date    Wed, 12 Dez 2001
16 /// @version $Id$
17 ///
18 // with one ore more logics.
19 /****************************************************************************/
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include "MSLinkCont.h"
27 #include "MSLogicJunction.h"
28 #include "MSLane.h"
29 
30 
31 // ===========================================================================
32 // member method definitions
33 // ===========================================================================
34 /* -------------------------------------------------------------------------
35  * methods from MSLogicJunction
36  * ----------------------------------------------------------------------- */
MSLogicJunction(const std::string & id,SumoXMLNodeType type,const Position & position,const PositionVector & shape,std::vector<MSLane * > incoming,std::vector<MSLane * > internal)37 MSLogicJunction::MSLogicJunction(const std::string& id,
38                                  SumoXMLNodeType type,
39                                  const Position& position,
40                                  const PositionVector& shape,
41                                  std::vector<MSLane*> incoming
42                                  , std::vector<MSLane*> internal
43                                 ):
44     MSJunction(id, type, position, shape),
45     myIncomingLanes(incoming),
46     myInternalLanes(internal) {
47 }
48 
49 
~MSLogicJunction()50 MSLogicJunction::~MSLogicJunction() {}
51 
52 
53 void
postloadInit()54 MSLogicJunction::postloadInit() {
55     /*
56     if(getID()=="1565") {
57         int bla = 0;
58     }
59     // inform links where they have to report approaching vehicles to
60     int requestPos = 0;
61     std::vector<MSLane*>::iterator i;
62     // going through the incoming lanes...
63     for(i=myIncomingLanes.begin(); i!=myIncomingLanes.end(); ++i) {
64         const MSLinkCont &links = (*i)->getLinkCont();
65         // ... set information for every link
66         for(MSLinkCont::const_iterator j=links.begin(); j!=links.end(); j++) {
67             (*j)->setRequestInformation(&myRequest, requestPos,
68                 &myRespond, requestPos/, clearInfo/);
69             requestPos++;
70         }
71     }
72     // set information for the internal lanes
73     requestPos = 0;
74     for(i=myInternalLanes.begin(); i!=myInternalLanes.end(); ++i) {
75         // ... set information about participation
76         static_cast<MSInternalLane*>(*i)->setParentJunctionInformation(
77             &myInnerState, requestPos++);
78     }
79     */
80 }
81 
82 const std::vector<MSLane*>
getInternalLanes() const83 MSLogicJunction::getInternalLanes() const {
84     // Besides the lanes im myInternal lanes, which are only the last parts of the connections,
85     // this collects all lanes on the junction
86     std::vector<MSLane*> allInternalLanes;
87     for (std::vector<MSLane*>::const_iterator i = myInternalLanes.begin(); i != myInternalLanes.end(); ++i) {
88         MSLane* l = *i;
89         while (l != nullptr) {
90             allInternalLanes.push_back(l);
91             const std::vector<MSLane::IncomingLaneInfo> incoming = l->getIncomingLanes();
92             if (incoming.size() == 0) {
93                 break;
94             }
95             assert(l->getIncomingLanes().size() == 1);
96             l = l->getIncomingLanes()[0].lane;
97             if (!l->isInternal()) {
98                 break;
99             }
100         }
101     }
102     return allInternalLanes;
103 }
104 
105 
106 
107 /****************************************************************************/
108 
109