Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netimport/vissim/tempstructs/NIVissimNodeDef_Edges.cpp
169684 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-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 NIVissimNodeDef_Edges.cpp
15
/// @author Daniel Krajzewicz
16
/// @author Michael Behrisch
17
/// @date Sept 2002
18
///
19
// -------------------
20
/****************************************************************************/
21
#include <config.h>
22
23
24
25
#include <string>
26
#include <map>
27
#include <algorithm>
28
#include <cassert>
29
#include <utils/geom/Boundary.h>
30
#include "NIVissimNodeParticipatingEdgeVector.h"
31
#include "NIVissimNodeDef.h"
32
#include "NIVissimEdge.h"
33
#include "NIVissimNodeDef_Edges.h"
34
#include "NIVissimDisturbance.h"
35
#include "NIVissimConnection.h"
36
37
38
// ===========================================================================
39
// method definitions
40
// ===========================================================================
41
NIVissimNodeDef_Edges::NIVissimNodeDef_Edges(int id,
42
const std::string& name, const NIVissimNodeParticipatingEdgeVector& edges)
43
: NIVissimNodeDef(id, name), myEdges(edges) {}
44
45
46
NIVissimNodeDef_Edges::~NIVissimNodeDef_Edges() {
47
for (NIVissimNodeParticipatingEdgeVector::iterator i = myEdges.begin(); i != myEdges.end(); i++) {
48
delete (*i);
49
}
50
myEdges.clear();
51
}
52
53
54
bool
55
NIVissimNodeDef_Edges::dictionary(int id, const std::string& name,
56
const NIVissimNodeParticipatingEdgeVector& edges) {
57
NIVissimNodeDef_Edges* o = new NIVissimNodeDef_Edges(id, name, edges);
58
if (!NIVissimNodeDef::dictionary(id, o)) {
59
delete o;
60
return false;
61
}
62
return true;
63
}
64
65
66
/*
67
void
68
NIVissimNodeDef_Edges::searchAndSetConnections() {
69
std::vector<int> connections;
70
std::vector<int> edges;
71
Boundary boundary;
72
for (NIVissimNodeParticipatingEdgeVector::const_iterator i = myEdges.begin(); i != myEdges.end(); i++) {
73
NIVissimNodeParticipatingEdge* edge = *i;
74
NIVissimConnection* c =
75
NIVissimConnection::dictionary(edge->getID());
76
NIVissimEdge* e =
77
NIVissimEdge::dictionary(edge->getID());
78
if (c != 0) {
79
connections.push_back(edge->getID());
80
boundary.add(c->getFromGeomPosition());
81
boundary.add(c->getToGeomPosition());
82
c->setNodeCluster(myID);
83
}
84
if (e != 0) {
85
edges.push_back(edge->getID());
86
boundary.add(e->getGeomPosition(edge->getFromPos()));
87
boundary.add(e->getGeomPosition(edge->getToPos()));
88
}
89
}
90
NIVissimConnectionCluster* c =
91
new NIVissimConnectionCluster(connections, boundary, myID, edges);
92
for (std::vector<int>::iterator j = edges.begin(); j != edges.end(); j++) {
93
NIVissimEdge* edge = NIVissimEdge::dictionary(*j);
94
edge->myConnectionClusters.push_back(c);
95
}
96
}
97
*/
98
99
100
double
101
NIVissimNodeDef_Edges::getEdgePosition(int edgeid) const {
102
for (NIVissimNodeParticipatingEdgeVector::const_iterator i = myEdges.begin(); i != myEdges.end(); i++) {
103
NIVissimNodeParticipatingEdge* edge = *i;
104
if (edge->getID() == edgeid) {
105
return (edge->getFromPos() + edge->getToPos()) / (double) 2.0;
106
}
107
}
108
return -1;
109
}
110
111
112
/****************************************************************************/
113
114