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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
18 // -------------------
19 /****************************************************************************/
20 #ifndef NIVissimConnectionCluster_h
21 #define NIVissimConnectionCluster_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 
34 #include <iostream>
35 #include <vector>
36 #include <utils/geom/Boundary.h>
37 #include <utils/geom/GeomHelper.h>
38 #include "NIVissimConnection.h"
39 
40 
41 // ===========================================================================
42 // class declarations
43 // ===========================================================================
44 class NBNode;
45 class NIVissimEdge;
46 
47 
48 // ===========================================================================
49 // class definitions
50 // ===========================================================================
60 public:
63  NIVissimConnectionCluster(const std::vector<int>& connections, int nodeCluster,
64  int edgeid);
65 
66  NIVissimConnectionCluster(const std::vector<int>& connections,
67  const Boundary& boundary, int nodeCluster, const std::vector<int>& edges);
68 
71 
73  bool overlapsWith(NIVissimConnectionCluster* c, double offset = 0) const;
74 
75  bool hasNodeCluster() const;
76 
77  NBNode* getNBNode() const;
78 
79  bool around(const Position& p, double offset = 0) const;
80 
81  double getPositionForEdge(int edgeid) const;
82 
83  friend class NIVissimEdge; // !!! debug
84 
85  const std::vector<int>& getConnections() const {
86  return myConnections;
87  }
88 
93 
94 
95 public:
98  static void joinBySameEdges(double offset);
99 
100  static void joinByDisturbances(double offset);
101 
102  static void buildNodeClusters();
103 
104  static void _debugOut(std::ostream& into);
105 
106  static int dictSize();
107 
108 
109  static int getNextFreeNodeID();
110 
111  static void clearDict();
112 
113 private:
115  public:
117  ~NodeSubCluster();
118  void add(NIVissimConnection* c);
119  void add(const NodeSubCluster& c);
120  int size() const;
121  bool overlapsWith(const NodeSubCluster& c, double offset = 0);
122  std::vector<int> getConnectionIDs() const;
124  public:
126  typedef std::vector<NIVissimConnection*> ConnectionCont;
127  ConnectionCont myConnections;
128  };
129 
131  private:
132  double myAngle;
133 
134  public:
136  explicit same_direction_sorter(double angle)
137  : myAngle(angle) { }
138 
139  public:
142  return fabs(GeomHelper::angleDiff(c1->getGeometry().beginEndAngle(), myAngle))
143  <
144  fabs(GeomHelper::angleDiff(c2->getGeometry().beginEndAngle(), myAngle));
145  }
146  };
147 
148 
149 
150 private:
153 
154  void removeConnections(const NodeSubCluster& c);
155 
156  void recomputeBoundary();
157 
158  void recheckEdges();
159 
160  bool joinable(NIVissimConnectionCluster* c2, double offset);
161 
162 
163  std::vector<int> getDisturbanceParticipators();
164 
165  std::vector<int> extendByToTreatAsSame(const std::vector<int>& iv1,
166  const std::vector<int>& iv2) const;
167 
169 
171 
172 
173 
174 private:
176  std::vector<int> myConnections;
177 
180 
183 
184  // The edge which holds the cluster
185  std::vector<int> myEdges;
186 
187  std::vector<int> myNodes;
188 
189  std::vector<int> myTLs;
190 
191  std::vector<int> myOutgoingEdges, myIncomingEdges;
192 
193 private:
194  typedef std::vector<NIVissimConnectionCluster*> ContType;
195  static ContType myClusters;
196  static int myFirstFreeID;
197  static int myStaticBlaID;
198  int myBlaID;
199 };
200 
201 
202 #endif
203 
204 /****************************************************************************/
205 
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:47
std::vector< int > getDisturbanceParticipators()
double getPositionForEdge(int edgeid) const
A temporary storage for edges imported from Vissim.
Definition: NIVissimEdge.h:59
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:45
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:74
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:173
const std::vector< int > & getConnections() const