SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NIVissimConnectionCluster.h
Go to the documentation of this file.
1 /****************************************************************************/
8 // -------------------
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
11 // Copyright (C) 2001-2012 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/Position.h>
38 #include <utils/geom/Boundary.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, SUMOReal offset = 0) const;
75 
76  bool hasNodeCluster() const;
77 
78  NBNode* getNBNode() const;
79 
80  bool around(const Position& p, SUMOReal offset = 0) const;
81 
82  SUMOReal 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(SUMOReal offset);
100 
101  static void joinByDisturbances(SUMOReal offset);
102 
103  static void buildNodeClusters();
104 
105  static void _debugOut(std::ostream& into);
106 
107  static size_t 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  size_t size() const;
122  bool overlapsWith(const NodeSubCluster& c, SUMOReal offset = 0);
123  std::vector<int> getConnectionIDs() const;
125  public:
127  typedef std::vector<NIVissimConnection*> ConnectionCont;
129  };
130 
132  private:
134 
135  public:
138  : myAngle(angle) { }
139 
140  public:
143  return
144  fabs(c1->getGeometry().beginEndAngle() - myAngle)
145  <
146  fabs(c2->getGeometry().beginEndAngle() - myAngle);
147  }
148  };
149 
150 
151 
152 private:
155 
156  void removeConnections(const NodeSubCluster& c);
157 
158  void recomputeBoundary();
159 
160  void recheckEdges();
161 
162  bool joinable(NIVissimConnectionCluster* c2, SUMOReal offset);
163 
164 
165  std::vector<int> getDisturbanceParticipators();
166 
167  std::vector<int> extendByToTreatAsSame(const std::vector<int>& iv1,
168  const std::vector<int>& iv2) const;
169 
171 
173 
174 
175 
176 private:
178  std::vector<int> myConnections;
179 
182 
185 
186  // The edge which holds the cluster
187  std::vector<int> myEdges;
188 
189  std::vector<int> myNodes;
190 
191  std::vector<int> myTLs;
192 
193  std::vector<int> myOutgoingEdges, myIncomingEdges;
194 
195 private:
196  typedef std::vector<NIVissimConnectionCluster*> ContType;
198  static int myFirstFreeID;
199  static int myStaticBlaID;
200  int myBlaID;
201 };
202 
203 
204 #endif
205 
206 /****************************************************************************/
207