SUMO - Simulation of Urban MObility
NIVissimConnectionCluster.h
Go to the documentation of this file.
1 /****************************************************************************/
8 // -------------------
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
11 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 #ifndef NIVissimConnectionCluster_h
22 #define NIVissimConnectionCluster_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 
35 #include <iostream>
36 #include <vector>
37 #include <utils/geom/Boundary.h>
38 #include <utils/geom/GeomHelper.h>
39 #include "NIVissimConnection.h"
40 
41 
42 // ===========================================================================
43 // class declarations
44 // ===========================================================================
45 class NBNode;
46 class NIVissimEdge;
47 
48 
49 // ===========================================================================
50 // class definitions
51 // ===========================================================================
61 public:
64  NIVissimConnectionCluster(const std::vector<int>& connections, int nodeCluster,
65  int edgeid);
66 
67  NIVissimConnectionCluster(const std::vector<int>& connections,
68  const Boundary& boundary, int nodeCluster, const std::vector<int>& edges);
69 
72 
74  bool overlapsWith(NIVissimConnectionCluster* c, double offset = 0) const;
75 
76  bool hasNodeCluster() const;
77 
78  NBNode* getNBNode() const;
79 
80  bool around(const Position& p, double offset = 0) const;
81 
82  double getPositionForEdge(int edgeid) const;
83 
84  friend class NIVissimEdge; // !!! debug
85 
86  const std::vector<int>& getConnections() const {
87  return myConnections;
88  }
89 
94 
95 
96 public:
99  static void joinBySameEdges(double offset);
100 
101  static void joinByDisturbances(double offset);
102 
103  static void buildNodeClusters();
104 
105  static void _debugOut(std::ostream& into);
106 
107  static int dictSize();
108 
109 
110  static int getNextFreeNodeID();
111 
112  static void clearDict();
113 
114 private:
116  public:
118  ~NodeSubCluster();
119  void add(NIVissimConnection* c);
120  void add(const NodeSubCluster& c);
121  int size() const;
122  bool overlapsWith(const NodeSubCluster& c, double offset = 0);
123  std::vector<int> getConnectionIDs() const;
125  public:
127  typedef std::vector<NIVissimConnection*> ConnectionCont;
128  ConnectionCont myConnections;
129  };
130 
132  private:
133  double myAngle;
134 
135  public:
137  explicit same_direction_sorter(double angle)
138  : myAngle(angle) { }
139 
140  public:
143  return fabs(GeomHelper::angleDiff(c1->getGeometry().beginEndAngle(), myAngle))
144  <
145  fabs(GeomHelper::angleDiff(c2->getGeometry().beginEndAngle(), myAngle));
146  }
147  };
148 
149 
150 
151 private:
154 
155  void removeConnections(const NodeSubCluster& c);
156 
157  void recomputeBoundary();
158 
159  void recheckEdges();
160 
161  bool joinable(NIVissimConnectionCluster* c2, double offset);
162 
163 
164  std::vector<int> getDisturbanceParticipators();
165 
166  std::vector<int> extendByToTreatAsSame(const std::vector<int>& iv1,
167  const std::vector<int>& iv2) const;
168 
170 
172 
173 
174 
175 private:
177  std::vector<int> myConnections;
178 
181 
184 
185  // The edge which holds the cluster
186  std::vector<int> myEdges;
187 
188  std::vector<int> myNodes;
189 
190  std::vector<int> myTLs;
191 
192  std::vector<int> myOutgoingEdges, myIncomingEdges;
193 
194 private:
195  typedef std::vector<NIVissimConnectionCluster*> ContType;
196  static ContType myClusters;
197  static int myFirstFreeID;
198  static int myStaticBlaID;
199  int myBlaID;
200 };
201 
202 
203 #endif
204 
205 /****************************************************************************/
206 
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:48
std::vector< int > getDisturbanceParticipators()
double getPositionForEdge(int edgeid) const
A temporary storage for edges imported from Vissim.
Definition: NIVissimEdge.h:60
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:46
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:75
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:174
const std::vector< int > & getConnections() const