Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/microsim/MSNoLogicJunction.cpp
185785 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2002-2025 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
MSNoLogicJunction::MSNoLogicJunction(const std::string& id,
40
SumoXMLNodeType type,
41
const Position& position,
42
const PositionVector& shape,
43
const std::string& name,
44
std::vector<MSLane*> incoming, std::vector<MSLane*> internal):
45
MSJunction(id, type, position, shape, name),
46
myIncomingLanes(incoming),
47
myInternalLanes(internal) {
48
}
49
50
51
MSNoLogicJunction::~MSNoLogicJunction() {}
52
53
54
void
55
MSNoLogicJunction::postloadInit() {
56
// inform links where they have to report approaching vehicles to
57
for (const MSLane* const l : myIncomingLanes) {
58
for (MSLink* const link : l->getLinkCont()) {
59
link->setRequestInformation(-1, false, false, std::vector<MSLink*>(), std::vector<MSLane*>());
60
}
61
}
62
}
63
64
65
const std::vector<MSLane*>
66
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
for (std::vector<MSLane*>::const_iterator i = myInternalLanes.begin(); i != myInternalLanes.end(); ++i) {
71
MSLane* l = *i;
72
while (l != nullptr) {
73
allInternalLanes.push_back(l);
74
const std::vector<MSLane::IncomingLaneInfo> incoming = l->getIncomingLanes();
75
if (incoming.size() == 0) {
76
break;
77
}
78
assert(l->getIncomingLanes().size() == 1);
79
l = l->getIncomingLanes()[0].lane;
80
if (!l->isInternal()) {
81
break;
82
}
83
}
84
}
85
return allInternalLanes;
86
}
87
88
89
/****************************************************************************/
90
91