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