Eclipse SUMO - Simulation of Urban MObility
NIVissimConnectionCluster.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-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 /****************************************************************************/
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 // ===========================================================================
51 public:
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 
62 
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 
84 
85 
86 public:
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:
103  public:
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;
112  public:
114  typedef std::vector<NIVissimConnection*> ConnectionCont;
116  };
117 
119  private:
120  double myAngle;
121 
122  public:
124  explicit same_direction_sorter(double angle)
125  : myAngle(angle) { }
126 
127  public:
131  <
133  }
134  };
135 
136 
137 
138 private:
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 
157 
159 
160 
161 
162 private:
164  std::vector<int> myConnections;
165 
168 
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;
184  static int myFirstFreeID;
185  static int myStaticBlaID;
186  int myBlaID;
187 };
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
static double angleDiff(const double angle1, const double angle2)
Returns the difference of the second angle to the first angle in radiants.
Definition: GeomHelper.cpp:178
Represents a single node (junction) during network building.
Definition: NBNode.h:66
const PositionVector & getGeometry() const
bool overlapsWith(const NodeSubCluster &c, double offset=0)
std::vector< NIVissimConnection * > ConnectionCont
int operator()(NIVissimConnection *c1, NIVissimConnection *c2) const
comparing operation
bool around(const Position &p, double offset=0) const
NIVissimConnection * getIncomingContinuation(NIVissimEdge *e) const
bool liesOnSameEdgesEnd(NIVissimConnectionCluster *cc2)
Boundary myBoundary
The boundary of the cluster.
PositionVector getOutgoingContinuationGeometry(NIVissimEdge *e) const
std::vector< int > myConnections
List of connection-ids which participate within this cluster.
void removeConnections(const NodeSubCluster &c)
std::vector< int > extendByToTreatAsSame(const std::vector< int > &iv1, const std::vector< int > &iv2) const
bool isWeakDistrictConnRealisation(NIVissimConnectionCluster *c2)
const std::vector< int > & getConnections() const
static void joinBySameEdges(double offset)
Tries to joind clusters participating within a node This is done by joining clusters which overlap.
std::vector< int > getDisturbanceParticipators()
bool joinable(NIVissimConnectionCluster *c2, double offset)
static void _debugOut(std::ostream &into)
bool overlapsWith(NIVissimConnectionCluster *c, double offset=0) const
Returns the information whether the given cluster overlaps the current.
std::vector< NIVissimConnectionCluster * > ContType
NIVissimConnection * getOutgoingContinuation(NIVissimEdge *e) const
PositionVector getIncomingContinuationGeometry(NIVissimEdge *e) const
int myNodeCluster
The node the cluster is assigned to.
NIVissimConnectionCluster(const std::vector< int > &connections, int nodeCluster, int edgeid)
Constructor Build the boundary; The boundary includes both incoming and outgoing nodes.
double getPositionForEdge(int edgeid) const
static void joinByDisturbances(double offset)
void add(NIVissimConnectionCluster *c)
Adds the second cluster.
A temporary storage for edges imported from Vissim.
Definition: NIVissimEdge.h:51
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
A list of positions.
double beginEndAngle() const
returns the angle in radians of the line connecting the first and the last position