SUMO - Simulation of Urban MObility
NIVissimNodeDef_Edges.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
18 // -------------------
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
31 
32 
33 #include <string>
34 #include <map>
35 #include <algorithm>
36 #include <cassert>
37 #include <utils/geom/Boundary.h>
39 #include "NIVissimNodeDef.h"
40 #include "NIVissimEdge.h"
41 #include "NIVissimNodeDef_Edges.h"
42 #include "NIVissimDisturbance.h"
43 #include "NIVissimConnection.h"
44 
45 
46 // ===========================================================================
47 // method definitions
48 // ===========================================================================
50  const std::string& name, const NIVissimNodeParticipatingEdgeVector& edges)
51  : NIVissimNodeDef(id, name), myEdges(edges) {}
52 
53 
55  for (NIVissimNodeParticipatingEdgeVector::iterator i = myEdges.begin(); i != myEdges.end(); i++) {
56  delete(*i);
57  }
58  myEdges.clear();
59 }
60 
61 
62 bool
63 NIVissimNodeDef_Edges::dictionary(int id, const std::string& name,
65  NIVissimNodeDef_Edges* o = new NIVissimNodeDef_Edges(id, name, edges);
66  if (!NIVissimNodeDef::dictionary(id, o)) {
67  delete o;
68  return false;
69  }
70  return true;
71 }
72 
73 
74 /*
75 void
76 NIVissimNodeDef_Edges::searchAndSetConnections() {
77  std::vector<int> connections;
78  std::vector<int> edges;
79  Boundary boundary;
80  for (NIVissimNodeParticipatingEdgeVector::const_iterator i = myEdges.begin(); i != myEdges.end(); i++) {
81  NIVissimNodeParticipatingEdge* edge = *i;
82  NIVissimConnection* c =
83  NIVissimConnection::dictionary(edge->getID());
84  NIVissimEdge* e =
85  NIVissimEdge::dictionary(edge->getID());
86  if (c != 0) {
87  connections.push_back(edge->getID());
88  boundary.add(c->getFromGeomPosition());
89  boundary.add(c->getToGeomPosition());
90  c->setNodeCluster(myID);
91  }
92  if (e != 0) {
93  edges.push_back(edge->getID());
94  boundary.add(e->getGeomPosition(edge->getFromPos()));
95  boundary.add(e->getGeomPosition(edge->getToPos()));
96  }
97  }
98  NIVissimConnectionCluster* c =
99  new NIVissimConnectionCluster(connections, boundary, myID, edges);
100  for (std::vector<int>::iterator j = edges.begin(); j != edges.end(); j++) {
101  NIVissimEdge* edge = NIVissimEdge::dictionary(*j);
102  edge->myConnectionClusters.push_back(c);
103  }
104 }
105 */
106 
107 
108 double
110  for (NIVissimNodeParticipatingEdgeVector::const_iterator i = myEdges.begin(); i != myEdges.end(); i++) {
112  if (edge->getID() == edgeid) {
113  return (edge->getFromPos() + edge->getToPos()) / (double) 2.0;
114  }
115  }
116  return -1;
117 }
118 
119 
120 
121 /****************************************************************************/
122 
virtual double 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)
NIVissimNodeParticipatingEdgeVector myEdges