|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00007 // ------------------- 00008 /****************************************************************************/ 00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors 00011 /****************************************************************************/ 00012 // 00013 // This program is free software; you can redistribute it and/or modify 00014 // it under the terms of the GNU General Public License as published by 00015 // the Free Software Foundation; either version 2 of the License, or 00016 // (at your option) any later version. 00017 // 00018 /****************************************************************************/ 00019 #ifndef NIVissimConnectionCluster_h 00020 #define NIVissimConnectionCluster_h 00021 00022 00023 // =========================================================================== 00024 // included modules 00025 // =========================================================================== 00026 #ifdef _MSC_VER 00027 #include <windows_config.h> 00028 #else 00029 #include <config.h> 00030 #endif 00031 00032 00033 #include <iostream> 00034 #include <vector> 00035 #include <utils/geom/Position.h> 00036 #include <utils/geom/Boundary.h> 00037 #include <utils/common/VectorHelper.h> 00038 #include "NIVissimConnection.h" 00039 00040 00041 // =========================================================================== 00042 // class declarations 00043 // =========================================================================== 00044 class NBNode; 00045 class NIVissimEdge; 00046 00047 00048 // =========================================================================== 00049 // class definitions 00050 // =========================================================================== 00059 class NIVissimConnectionCluster { 00060 public: 00063 NIVissimConnectionCluster(const IntVector& connections, int nodeCluster, 00064 int edgeid); 00065 00066 NIVissimConnectionCluster(const IntVector& connections, 00067 const Boundary& boundary, int nodeCluster, const IntVector& edges); 00068 00070 ~NIVissimConnectionCluster(); 00071 00073 bool overlapsWith(NIVissimConnectionCluster* c, SUMOReal offset=0) const; 00074 00075 bool hasNodeCluster() const; 00076 00077 NBNode* getNBNode() const; 00078 00079 bool around(const Position& p, SUMOReal offset=0) const; 00080 00081 SUMOReal getPositionForEdge(int edgeid) const; 00082 00083 friend class NIVissimEdge; // !!! debug 00084 00085 const IntVector& getConnections() const { 00086 return myConnections; 00087 } 00088 00089 PositionVector getIncomingContinuationGeometry(NIVissimEdge* e) const; 00090 PositionVector getOutgoingContinuationGeometry(NIVissimEdge* e) const; 00091 NIVissimConnection* getIncomingContinuation(NIVissimEdge* e) const; 00092 NIVissimConnection* getOutgoingContinuation(NIVissimEdge* e) const; 00093 00094 00095 public: 00098 static void joinBySameEdges(SUMOReal offset); 00099 00100 static void joinByDisturbances(SUMOReal offset); 00101 00102 static void buildNodeClusters(); 00103 00104 static void searchForConnection(int id); 00105 00106 static void _debugOut(std::ostream& into); 00107 00108 static size_t dictSize(); 00109 00110 00111 static int getNextFreeNodeID(); 00112 00113 static void clearDict(); 00114 00115 private: 00116 class NodeSubCluster { 00117 public: 00118 NodeSubCluster(NIVissimConnection* c); 00119 ~NodeSubCluster(); 00120 void add(NIVissimConnection* c); 00121 void add(const NodeSubCluster& c); 00122 size_t size() const; 00123 bool overlapsWith(const NodeSubCluster& c, SUMOReal offset=0); 00124 IntVector getConnectionIDs() const; 00125 friend class NIVissimConnectionCluster; 00126 public: 00127 Boundary myBoundary; 00128 typedef std::vector<NIVissimConnection*> ConnectionCont; 00129 ConnectionCont myConnections; 00130 }; 00131 00132 class same_direction_sorter { 00133 private: 00134 SUMOReal myAngle; 00135 00136 public: 00138 explicit same_direction_sorter(SUMOReal angle) 00139 : myAngle(angle) { } 00140 00141 public: 00143 int operator()(NIVissimConnection* c1, NIVissimConnection* c2) const { 00144 return 00145 fabs(c1->getGeometry().beginEndAngle()-myAngle) 00146 < 00147 fabs(c2->getGeometry().beginEndAngle()-myAngle); 00148 } 00149 }; 00150 00151 00152 00153 private: 00155 void add(NIVissimConnectionCluster* c); 00156 00157 void removeConnections(const NodeSubCluster& c); 00158 00159 void recomputeBoundary(); 00160 00161 void recheckEdges(); 00162 00163 bool joinable(NIVissimConnectionCluster* c2, SUMOReal offset); 00164 00165 00166 IntVector getDisturbanceParticipators(); 00167 00168 IntVector extendByToTreatAsSame(const IntVector& iv1, 00169 const IntVector& iv2) const; 00170 00171 bool isWeakDistrictConnRealisation(NIVissimConnectionCluster* c2); 00172 00173 bool liesOnSameEdgesEnd(NIVissimConnectionCluster* cc2); 00174 00175 00176 00177 private: 00179 IntVector myConnections; 00180 00182 Boundary myBoundary; 00183 00185 int myNodeCluster; 00186 00187 // The edge which holds the cluster 00188 IntVector myEdges; 00189 00190 IntVector myNodes; 00191 00192 IntVector myTLs; 00193 00194 IntVector myOutgoingEdges, myIncomingEdges; 00195 00196 private: 00197 typedef std::vector<NIVissimConnectionCluster*> ContType; 00198 static ContType myClusters; 00199 static int myFirstFreeID; 00200 static int myStaticBlaID; 00201 int myBlaID; 00202 }; 00203 00204 00205 #endif 00206 00207 /****************************************************************************/ 00208