Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2002-2024 German Aerospace Center (DLR) and others.
4 : // This program and the accompanying materials are made available under the
5 : // terms of the Eclipse Public License 2.0 which is available at
6 : // https://www.eclipse.org/legal/epl-2.0/
7 : // This Source Code may also be made available under the following Secondary
8 : // Licenses when the conditions for such availability set forth in the Eclipse
9 : // Public License 2.0 are satisfied: GNU General Public License, version 2
10 : // or later which is available at
11 : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 : /****************************************************************************/
14 : /// @file MSNoLogicJunction.cpp
15 : /// @author Daniel Krajzewicz
16 : /// @author Michael Behrisch
17 : /// @author Jakob Erdmann
18 : /// @date Thu, 06 Jun 2002
19 : ///
20 : // -------------------
21 : /****************************************************************************/
22 : #include <config.h>
23 :
24 : #include <algorithm>
25 : #include <cassert>
26 : #include <cmath>
27 : #include "MSLane.h"
28 : #include "MSLink.h"
29 : #include "MSNoLogicJunction.h"
30 :
31 :
32 : // ===========================================================================
33 : // static member definitions
34 : // ===========================================================================
35 :
36 : // ===========================================================================
37 : // method definitions
38 : // ===========================================================================
39 58365 : MSNoLogicJunction::MSNoLogicJunction(const std::string& id,
40 : SumoXMLNodeType type,
41 : const Position& position,
42 : const PositionVector& shape,
43 : const std::string& name,
44 58365 : std::vector<MSLane*> incoming, std::vector<MSLane*> internal):
45 : MSJunction(id, type, position, shape, name),
46 58365 : myIncomingLanes(incoming),
47 58365 : myInternalLanes(internal) {
48 58365 : }
49 :
50 :
51 114660 : MSNoLogicJunction::~MSNoLogicJunction() {}
52 :
53 :
54 : void
55 58029 : MSNoLogicJunction::postloadInit() {
56 : // inform links where they have to report approaching vehicles to
57 115268 : for (const MSLane* const l : myIncomingLanes) {
58 69148 : for (MSLink* const link : l->getLinkCont()) {
59 11909 : link->setRequestInformation(-1, false, false, std::vector<MSLink*>(), std::vector<MSLane*>());
60 : }
61 : }
62 58029 : }
63 :
64 :
65 : const std::vector<MSLane*>
66 54219 : MSNoLogicJunction::getInternalLanes() const {
67 : // Besides the lanes im myInternal lanes, which are only the last parts of the connections,
68 : // this collects all lanes on the junction
69 : std::vector<MSLane*> allInternalLanes;
70 61711 : for (std::vector<MSLane*>::const_iterator i = myInternalLanes.begin(); i != myInternalLanes.end(); ++i) {
71 7492 : MSLane* l = *i;
72 7492 : while (l != nullptr) {
73 7492 : allInternalLanes.push_back(l);
74 7492 : const std::vector<MSLane::IncomingLaneInfo> incoming = l->getIncomingLanes();
75 7492 : if (incoming.size() == 0) {
76 : break;
77 : }
78 : assert(l->getIncomingLanes().size() == 1);
79 7492 : l = l->getIncomingLanes()[0].lane;
80 7492 : if (!l->isInternal()) {
81 : break;
82 : }
83 7492 : }
84 : }
85 54219 : return allInternalLanes;
86 0 : }
87 :
88 :
89 : /****************************************************************************/
|