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.org/sumo
3 // Copyright (C) 2001-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
16 // -------------------
17 /****************************************************************************/
18 #ifndef NIVissimConnectionCluster_h
19 #define NIVissimConnectionCluster_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 
28 #include <iostream>
29 #include <vector>
30 #include <utils/geom/Boundary.h>
31 #include <utils/geom/GeomHelper.h>
32 #include "NIVissimConnection.h"
33 
34 
35 // ===========================================================================
36 // class declarations
37 // ===========================================================================
38 class NBNode;
39 class NIVissimEdge;
40 
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
54 public:
57  NIVissimConnectionCluster(const std::vector<int>& connections, int nodeCluster,
58  int edgeid);
59 
60  NIVissimConnectionCluster(const std::vector<int>& connections,
61  const Boundary& boundary, int nodeCluster, const std::vector<int>& edges);
62 
65 
67  bool overlapsWith(NIVissimConnectionCluster* c, double offset = 0) const;
68 
69  bool hasNodeCluster() const;
70 
71  NBNode* getNBNode() const;
72 
73  bool around(const Position& p, double offset = 0) const;
74 
75  double getPositionForEdge(int edgeid) const;
76 
77  friend class NIVissimEdge; // !!! debug
78 
79  const std::vector<int>& getConnections() const {
80  return myConnections;
81  }
82 
87 
88 
89 public:
92  static void joinBySameEdges(double offset);
93 
94  static void joinByDisturbances(double offset);
95 
96  static void buildNodeClusters();
97 
98  static void _debugOut(std::ostream& into);
99 
100  static int dictSize();
101 
102 
103  static int getNextFreeNodeID();
104 
105  static void clearDict();
106 
107 private:
109  public:
111  ~NodeSubCluster();
112  void add(NIVissimConnection* c);
113  void add(const NodeSubCluster& c);
114  int size() const;
115  bool overlapsWith(const NodeSubCluster& c, double offset = 0);
116  std::vector<int> getConnectionIDs() const;
118  public:
120  typedef std::vector<NIVissimConnection*> ConnectionCont;
121  ConnectionCont myConnections;
122  };
123 
125  private:
126  double myAngle;
127 
128  public:
130  explicit same_direction_sorter(double angle)
131  : myAngle(angle) { }
132 
133  public:
136  return fabs(GeomHelper::angleDiff(c1->getGeometry().beginEndAngle(), myAngle))
137  <
138  fabs(GeomHelper::angleDiff(c2->getGeometry().beginEndAngle(), myAngle));
139  }
140  };
141 
142 
143 
144 private:
147 
148  void removeConnections(const NodeSubCluster& c);
149 
150  void recomputeBoundary();
151 
152  void recheckEdges();
153 
154  bool joinable(NIVissimConnectionCluster* c2, double offset);
155 
156 
157  std::vector<int> getDisturbanceParticipators();
158 
159  std::vector<int> extendByToTreatAsSame(const std::vector<int>& iv1,
160  const std::vector<int>& iv2) const;
161 
163 
165 
166 
167 
168 private:
170  std::vector<int> myConnections;
171 
174 
177 
178  // The edge which holds the cluster
179  std::vector<int> myEdges;
180 
181  std::vector<int> myNodes;
182 
183  std::vector<int> myTLs;
184 
185  std::vector<int> myOutgoingEdges, myIncomingEdges;
186 
187 private:
188  typedef std::vector<NIVissimConnectionCluster*> ContType;
189  static ContType myClusters;
190  static int myFirstFreeID;
191  static int myStaticBlaID;
192  int myBlaID;
193 };
194 
195 
196 #endif
197 
198 /****************************************************************************/
199 
static void joinBySameEdges(double offset)
Tries to joind clusters participating within a node This is done by joining clusters which overlap...
std::vector< NIVissimConnectionCluster * > ContType
int myNodeCluster
The node the cluster is assigned to.
std::vector< int > myConnections
List of connection-ids which participate within this cluster.
int operator()(NIVissimConnection *c1, NIVissimConnection *c2) const
comparing operation
NIVissimConnection * getIncomingContinuation(NIVissimEdge *e) const
static void joinByDisturbances(double offset)
const PositionVector & getGeometry() const
NIVissimConnection * getOutgoingContinuation(NIVissimEdge *e) const
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
std::vector< int > getDisturbanceParticipators()
double getPositionForEdge(int edgeid) const
A temporary storage for edges imported from Vissim.
Definition: NIVissimEdge.h:53
bool joinable(NIVissimConnectionCluster *c2, double offset)
PositionVector getIncomingContinuationGeometry(NIVissimEdge *e) const
double beginEndAngle() const
returns the angle in radians of the line connecting the first and the last position ...
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
static void _debugOut(std::ostream &into)
A list of positions.
bool around(const Position &p, double offset=0) const
std::vector< NIVissimConnection * > ConnectionCont
PositionVector getOutgoingContinuationGeometry(NIVissimEdge *e) const
void removeConnections(const NodeSubCluster &c)
std::vector< int > extendByToTreatAsSame(const std::vector< int > &iv1, const std::vector< int > &iv2) const
Boundary myBoundary
The boundary of the cluster.
Represents a single node (junction) during network building.
Definition: NBNode.h:68
bool overlapsWith(const NodeSubCluster &c, double offset=0)
bool overlapsWith(NIVissimConnectionCluster *c, double offset=0) const
Returns the information whether the given cluster overlaps the current.
bool liesOnSameEdgesEnd(NIVissimConnectionCluster *cc2)
bool isWeakDistrictConnRealisation(NIVissimConnectionCluster *c2)
NIVissimConnectionCluster(const std::vector< int > &connections, int nodeCluster, int edgeid)
Constructor Build the boundary; The boundary includes both incoming and outgoing nodes.
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:167
const std::vector< int > & getConnections() const