Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netimport/vissim/tempstructs/NIVissimConnectionCluster.h
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 NIVissimConnectionCluster.h
15
/// @author Daniel Krajzewicz
16
/// @author Michael Behrisch
17
/// @date Sept 2002
18
///
19
// -------------------
20
/****************************************************************************/
21
#pragma once
22
#include <config.h>
23
24
25
#include <iostream>
26
#include <vector>
27
#include <utils/geom/Boundary.h>
28
#include <utils/geom/GeomHelper.h>
29
#include "NIVissimConnection.h"
30
31
32
// ===========================================================================
33
// class declarations
34
// ===========================================================================
35
class NBNode;
36
class NIVissimEdge;
37
38
39
// ===========================================================================
40
// class definitions
41
// ===========================================================================
42
/**
43
* @class NIVissimConnectionCluster
44
* This class holds a list of connections either all outgoing or all
45
* incoming within an edge, which do lies close together.
46
* This shall be the connections which belong to a single node.
47
* It still are not all of the node's connections, as other edges
48
* may participate to this node, too.
49
*/
50
class NIVissimConnectionCluster {
51
public:
52
/** @brief Constructor
53
Build the boundary; The boundary includes both incoming and outgoing nodes */
54
NIVissimConnectionCluster(const std::vector<int>& connections, int nodeCluster,
55
int edgeid);
56
57
NIVissimConnectionCluster(const std::vector<int>& connections,
58
const Boundary& boundary, int nodeCluster, const std::vector<int>& edges);
59
60
/// Destructor
61
~NIVissimConnectionCluster();
62
63
/// Returns the information whether the given cluster overlaps the current
64
bool overlapsWith(NIVissimConnectionCluster* c, double offset = 0) const;
65
66
bool hasNodeCluster() const;
67
68
NBNode* getNBNode() const;
69
70
bool around(const Position& p, double offset = 0) const;
71
72
double getPositionForEdge(int edgeid) const;
73
74
friend class NIVissimEdge; // !!! debug
75
76
const std::vector<int>& getConnections() const {
77
return myConnections;
78
}
79
80
PositionVector getIncomingContinuationGeometry(NIVissimEdge* e) const;
81
PositionVector getOutgoingContinuationGeometry(NIVissimEdge* e) const;
82
NIVissimConnection* getIncomingContinuation(NIVissimEdge* e) const;
83
NIVissimConnection* getOutgoingContinuation(NIVissimEdge* e) const;
84
85
86
public:
87
/** @brief Tries to joind clusters participating within a node
88
This is done by joining clusters which overlap */
89
static void joinBySameEdges(double offset);
90
91
static void joinByDisturbances(double offset);
92
93
static void buildNodeClusters();
94
95
static void _debugOut(std::ostream& into);
96
97
static int getNextFreeNodeID();
98
99
static void clearDict();
100
101
private:
102
class NodeSubCluster {
103
public:
104
NodeSubCluster(NIVissimConnection* c);
105
~NodeSubCluster();
106
void add(NIVissimConnection* c);
107
void add(const NodeSubCluster& c);
108
int size() const;
109
bool overlapsWith(const NodeSubCluster& c, double offset = 0);
110
std::vector<int> getConnectionIDs() const;
111
friend class NIVissimConnectionCluster;
112
public:
113
Boundary myBoundary;
114
typedef std::vector<NIVissimConnection*> ConnectionCont;
115
ConnectionCont myConnections;
116
};
117
118
class same_direction_sorter {
119
private:
120
double myAngle;
121
122
public:
123
/// constructor
124
explicit same_direction_sorter(double angle)
125
: myAngle(angle) { }
126
127
public:
128
/// comparing operation
129
int operator()(NIVissimConnection* c1, NIVissimConnection* c2) const {
130
return fabs(GeomHelper::angleDiff(c1->getGeometry().beginEndAngle(), myAngle))
131
<
132
fabs(GeomHelper::angleDiff(c2->getGeometry().beginEndAngle(), myAngle));
133
}
134
};
135
136
137
138
private:
139
/// Adds the second cluster
140
void add(NIVissimConnectionCluster* c);
141
142
void removeConnections(const NodeSubCluster& c);
143
144
void recomputeBoundary();
145
146
void recheckEdges();
147
148
bool joinable(NIVissimConnectionCluster* c2, double offset);
149
150
151
std::vector<int> getDisturbanceParticipators();
152
153
std::vector<int> extendByToTreatAsSame(const std::vector<int>& iv1,
154
const std::vector<int>& iv2) const;
155
156
bool isWeakDistrictConnRealisation(NIVissimConnectionCluster* c2);
157
158
bool liesOnSameEdgesEnd(NIVissimConnectionCluster* cc2);
159
160
161
162
private:
163
/// List of connection-ids which participate within this cluster
164
std::vector<int> myConnections;
165
166
/// The boundary of the cluster
167
Boundary myBoundary;
168
169
/// The node the cluster is assigned to
170
int myNodeCluster;
171
172
// The edge which holds the cluster
173
std::vector<int> myEdges;
174
175
std::vector<int> myNodes;
176
177
std::vector<int> myTLs;
178
179
std::vector<int> myOutgoingEdges, myIncomingEdges;
180
181
private:
182
typedef std::vector<NIVissimConnectionCluster*> ContType;
183
static ContType myClusters;
184
static int myFirstFreeID;
185
static int myStaticBlaID;
186
int myBlaID;
187
};
188
189