SUMO - Simulation of Urban MObility
NIVissimNodeDef_Edges.cpp
Go to the documentation of this file.
1 /****************************************************************************/
8 // -------------------
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
11 // Copyright (C) 2001-2015 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 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 
33 
34 #include <string>
35 #include <map>
36 #include <algorithm>
37 #include <cassert>
38 #include <utils/geom/Boundary.h>
40 #include "NIVissimNodeDef.h"
41 #include "NIVissimEdge.h"
42 #include "NIVissimNodeDef_Edges.h"
43 #include "NIVissimDisturbance.h"
44 #include "NIVissimConnection.h"
45 
46 #ifdef CHECK_MEMORY_LEAKS
47 #include <foreign/nvwa/debug_new.h>
48 #endif // CHECK_MEMORY_LEAKS
49 
50 
51 // ===========================================================================
52 // method definitions
53 // ===========================================================================
55  const std::string& name, const NIVissimNodeParticipatingEdgeVector& edges)
56  : NIVissimNodeDef(id, name), myEdges(edges) {}
57 
58 
60  for (NIVissimNodeParticipatingEdgeVector::iterator i = myEdges.begin(); i != myEdges.end(); i++) {
61  delete(*i);
62  }
63  myEdges.clear();
64 }
65 
66 
67 bool
68 NIVissimNodeDef_Edges::dictionary(int id, const std::string& name,
70  NIVissimNodeDef_Edges* o = new NIVissimNodeDef_Edges(id, name, edges);
71  if (!NIVissimNodeDef::dictionary(id, o)) {
72  delete o;
73  return false;
74  }
75  return true;
76 }
77 
78 
79 /*
80 void
81 NIVissimNodeDef_Edges::searchAndSetConnections() {
82  std::vector<int> connections;
83  std::vector<int> edges;
84  Boundary boundary;
85  for (NIVissimNodeParticipatingEdgeVector::const_iterator i = myEdges.begin(); i != myEdges.end(); i++) {
86  NIVissimNodeParticipatingEdge* edge = *i;
87  NIVissimConnection* c =
88  NIVissimConnection::dictionary(edge->getID());
89  NIVissimEdge* e =
90  NIVissimEdge::dictionary(edge->getID());
91  if (c != 0) {
92  connections.push_back(edge->getID());
93  boundary.add(c->getFromGeomPosition());
94  boundary.add(c->getToGeomPosition());
95  c->setNodeCluster(myID);
96  }
97  if (e != 0) {
98  edges.push_back(edge->getID());
99  boundary.add(e->getGeomPosition(edge->getFromPos()));
100  boundary.add(e->getGeomPosition(edge->getToPos()));
101  }
102  }
103  NIVissimConnectionCluster* c =
104  new NIVissimConnectionCluster(connections, boundary, myID, edges);
105  for (std::vector<int>::iterator j = edges.begin(); j != edges.end(); j++) {
106  NIVissimEdge* edge = NIVissimEdge::dictionary(*j);
107  edge->myConnectionClusters.push_back(c);
108  }
109 }
110 */
111 
112 
113 SUMOReal
115  for (NIVissimNodeParticipatingEdgeVector::const_iterator i = myEdges.begin(); i != myEdges.end(); i++) {
117  if (edge->getID() == edgeid) {
118  return (edge->getFromPos() + edge->getToPos()) / (SUMOReal) 2.0;
119  }
120  }
121  return -1;
122 }
123 
124 
125 
126 /****************************************************************************/
127 
virtual SUMOReal getEdgePosition(int edgeid) const
static bool dictionary(int id, const std::string &name, const NIVissimNodeParticipatingEdgeVector &edges)
static bool dictionary(int id, NIVissimNodeDef *o)
std::vector< NIVissimNodeParticipatingEdge * > NIVissimNodeParticipatingEdgeVector
NIVissimNodeDef_Edges(int id, const std::string &name, const NIVissimNodeParticipatingEdgeVector &edges)
#define SUMOReal
Definition: config.h:214
NIVissimNodeParticipatingEdgeVector myEdges