SUMO - Simulation of Urban MObility
NIVissimConnectionCluster.h
Go to the documentation of this file.
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 "NIVissimConnection.h"
00040 
00041 
00042 // ===========================================================================
00043 // class declarations
00044 // ===========================================================================
00045 class NBNode;
00046 class NIVissimEdge;
00047 
00048 
00049 // ===========================================================================
00050 // class definitions
00051 // ===========================================================================
00060 class NIVissimConnectionCluster {
00061 public:
00064     NIVissimConnectionCluster(const std::vector<int>& connections, int nodeCluster,
00065                               int edgeid);
00066 
00067     NIVissimConnectionCluster(const std::vector<int>& connections,
00068                               const Boundary& boundary, int nodeCluster, const std::vector<int>& edges);
00069 
00071     ~NIVissimConnectionCluster();
00072 
00074     bool overlapsWith(NIVissimConnectionCluster* c, SUMOReal offset = 0) const;
00075 
00076     bool hasNodeCluster() const;
00077 
00078     NBNode* getNBNode() const;
00079 
00080     bool around(const Position& p, SUMOReal offset = 0) const;
00081 
00082     SUMOReal getPositionForEdge(int edgeid) const;
00083 
00084     friend class NIVissimEdge; // !!! debug
00085 
00086     const std::vector<int>& getConnections() const {
00087         return myConnections;
00088     }
00089 
00090     PositionVector getIncomingContinuationGeometry(NIVissimEdge* e) const;
00091     PositionVector getOutgoingContinuationGeometry(NIVissimEdge* e) const;
00092     NIVissimConnection* getIncomingContinuation(NIVissimEdge* e) const;
00093     NIVissimConnection* getOutgoingContinuation(NIVissimEdge* e) const;
00094 
00095 
00096 public:
00099     static void joinBySameEdges(SUMOReal offset);
00100 
00101     static void joinByDisturbances(SUMOReal offset);
00102 
00103     static void buildNodeClusters();
00104 
00105     static void searchForConnection(int id);
00106 
00107     static void _debugOut(std::ostream& into);
00108 
00109     static size_t dictSize();
00110 
00111 
00112     static int getNextFreeNodeID();
00113 
00114     static void clearDict();
00115 
00116 private:
00117     class NodeSubCluster {
00118     public:
00119         NodeSubCluster(NIVissimConnection* c);
00120         ~NodeSubCluster();
00121         void add(NIVissimConnection* c);
00122         void add(const NodeSubCluster& c);
00123         size_t size() const;
00124         bool overlapsWith(const NodeSubCluster& c, SUMOReal offset = 0);
00125         std::vector<int> getConnectionIDs() const;
00126         friend class NIVissimConnectionCluster;
00127     public:
00128         Boundary myBoundary;
00129         typedef std::vector<NIVissimConnection*> ConnectionCont;
00130         ConnectionCont myConnections;
00131     };
00132 
00133     class same_direction_sorter {
00134     private:
00135         SUMOReal myAngle;
00136 
00137     public:
00139         explicit same_direction_sorter(SUMOReal angle)
00140             : myAngle(angle) { }
00141 
00142     public:
00144         int operator()(NIVissimConnection* c1, NIVissimConnection* c2) const {
00145             return
00146                 fabs(c1->getGeometry().beginEndAngle() - myAngle)
00147                 <
00148                 fabs(c2->getGeometry().beginEndAngle() - myAngle);
00149         }
00150     };
00151 
00152 
00153 
00154 private:
00156     void add(NIVissimConnectionCluster* c);
00157 
00158     void removeConnections(const NodeSubCluster& c);
00159 
00160     void recomputeBoundary();
00161 
00162     void recheckEdges();
00163 
00164     bool joinable(NIVissimConnectionCluster* c2, SUMOReal offset);
00165 
00166 
00167     std::vector<int> getDisturbanceParticipators();
00168 
00169     std::vector<int> extendByToTreatAsSame(const std::vector<int>& iv1,
00170                                     const std::vector<int>& iv2) const;
00171 
00172     bool isWeakDistrictConnRealisation(NIVissimConnectionCluster* c2);
00173 
00174     bool liesOnSameEdgesEnd(NIVissimConnectionCluster* cc2);
00175 
00176 
00177 
00178 private:
00180     std::vector<int> myConnections;
00181 
00183     Boundary myBoundary;
00184 
00186     int myNodeCluster;
00187 
00188     // The edge which holds the cluster
00189     std::vector<int> myEdges;
00190 
00191     std::vector<int> myNodes;
00192 
00193     std::vector<int> myTLs;
00194 
00195     std::vector<int> myOutgoingEdges, myIncomingEdges;
00196 
00197 private:
00198     typedef std::vector<NIVissimConnectionCluster*> ContType;
00199     static ContType myClusters;
00200     static int myFirstFreeID;
00201     static int myStaticBlaID;
00202     int myBlaID;
00203 };
00204 
00205 
00206 #endif
00207 
00208 /****************************************************************************/
00209 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines