1 /****************************************************************************/ 2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo 3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others. 4 // This program and the accompanying materials 5 // are made available under the terms of the Eclipse Public License v2.0 6 // which accompanies this distribution, and is available at 7 // http://www.eclipse.org/legal/epl-v20.html 8 // SPDX-License-Identifier: EPL-2.0 9 /****************************************************************************/ 10 /// @file NIVissimConnection.h 11 /// @author Daniel Krajzewicz 12 /// @author Michael Behrisch 13 /// @date Sept 2002 14 /// @version $Id$ 15 /// 16 // ------------------- 17 /****************************************************************************/ 18 #ifndef NIVissimConnection_h 19 #define NIVissimConnection_h 20 21 22 // =========================================================================== 23 // included modules 24 // =========================================================================== 25 #include <config.h> 26 27 #include <string> 28 #include <map> 29 #include "NIVissimExtendedEdgePoint.h" 30 #include <utils/geom/Position.h> 31 #include <utils/geom/AbstractPoly.h> 32 #include "NIVissimAbstractEdge.h" 33 #include "NIVissimClosedLanesVector.h" 34 #include "NIVissimBoundedClusterObject.h" 35 36 37 // =========================================================================== 38 // class declarations 39 // =========================================================================== 40 class NBEdgeCont; 41 42 43 // =========================================================================== 44 // class definitions 45 // =========================================================================== 46 class NIVissimConnection 47 : public NIVissimBoundedClusterObject, 48 public NIVissimAbstractEdge { 49 public: 50 /* enum Direction { 51 NIVC_DIR_RIGHT, 52 NIVC_DIR_LEFT, 53 NIVC_DIR_ALL 54 }; */ 55 56 NIVissimConnection(int id, const std::string& name, 57 const NIVissimExtendedEdgePoint& from_def, 58 const NIVissimExtendedEdgePoint& to_def, 59 const PositionVector& geom, 60 const std::vector<int>& assignedVehicles, 61 const NIVissimClosedLanesVector& clv); 62 virtual ~NIVissimConnection(); 63 void computeBounding(); 64 int getFromEdgeID() const; 65 int getToEdgeID() const; 66 double getFromPosition() const; 67 double getToPosition() const; 68 Position getFromGeomPosition() const; 69 Position getToGeomPosition() const; 70 void setNodeCluster(int nodeid); 71 const Boundary& getBoundingBox() const; 72 73 int buildEdgeConnections(NBEdgeCont& ec); 74 75 void buildGeom(); 76 77 78 /** @brief Resets lane numbers if all lanes shall be used 79 * 80 * Calls "NIVissimExtendedEdgePoint::recheckLanes" for both used 81 * edges. 82 * 83 * @param[in] The built from-edge 84 * @param[in] The built to-edge 85 */ 86 void recheckLanes(const NBEdge* const fromEdge, const NBEdge* const toEdge); 87 88 public: 89 const std::vector<int>& getFromLanes() const; 90 const std::vector<int>& getToLanes() const; 91 92 93 94 static bool dictionary(int id, NIVissimConnection* o); 95 static NIVissimConnection* dictionary(int id); 96 static std::vector<int> getWithin(const AbstractPoly& poly); 97 static void buildNodeClusters(); 98 static std::vector<int> getForEdge(int edgeid, bool omitNodeAssigned = true); 99 static void dict_buildNBEdgeConnections(NBEdgeCont& ec); 100 static void dict_assignToEdges(); 101 static int getMaxID(); 102 103 private: 104 std::string myName; 105 NIVissimExtendedEdgePoint myFromDef, myToDef; 106 std::vector<int> myAssignedVehicles; 107 NIVissimClosedLanesVector myClosedLanes; 108 private: 109 typedef std::map<int, NIVissimConnection*> DictType; 110 static DictType myDict; 111 static int myMaxID; 112 }; 113 114 115 #endif 116 117 /****************************************************************************/ 118 119