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 searchForConnection(int id);
106 
107  static void _debugOut(std::ostream& into);
108 
109  static size_t dictSize();
110 
111 
112  static int getNextFreeNodeID();
113 
114  static void clearDict();
115 
116 private:
118  public:
120  ~NodeSubCluster();
121  void add(NIVissimConnection* c);
122  void add(const NodeSubCluster& c);
123  size_t size() const;
124  bool overlapsWith(const NodeSubCluster& c, SUMOReal offset = 0);
125  std::vector<int> getConnectionIDs() const;
127  public:
129  typedef std::vector<NIVissimConnection*> ConnectionCont;
131  };
132 
134  private:
136 
137  public:
140  : myAngle(angle) { }
141 
142  public:
145  return
146  fabs(c1->getGeometry().beginEndAngle() - myAngle)
147  <
148  fabs(c2->getGeometry().beginEndAngle() - myAngle);
149  }
150  };
151 
152 
153 
154 private:
157 
158  void removeConnections(const NodeSubCluster& c);
159 
160  void recomputeBoundary();
161 
162  void recheckEdges();
163 
164  bool joinable(NIVissimConnectionCluster* c2, SUMOReal offset);
165 
166 
167  std::vector<int> getDisturbanceParticipators();
168 
169  std::vector<int> extendByToTreatAsSame(const std::vector<int>& iv1,
170  const std::vector<int>& iv2) const;
171 
173 
175 
176 
177 
178 private:
180  std::vector<int> myConnections;
181 
184 
187 
188  // The edge which holds the cluster
189  std::vector<int> myEdges;
190 
191  std::vector<int> myNodes;
192 
193  std::vector<int> myTLs;
194 
195  std::vector<int> myOutgoingEdges, myIncomingEdges;
196 
197 private:
198  typedef std::vector<NIVissimConnectionCluster*> ContType;
200  static int myFirstFreeID;
201  static int myStaticBlaID;
202  int myBlaID;
203 };
204 
205 
206 #endif
207 
208 /****************************************************************************/
209