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-2017 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 
47 // ===========================================================================
48 // method definitions
49 // ===========================================================================
51  const std::string& name, const NIVissimNodeParticipatingEdgeVector& edges)
52  : NIVissimNodeDef(id, name), myEdges(edges) {}
53 
54 
56  for (NIVissimNodeParticipatingEdgeVector::iterator i = myEdges.begin(); i != myEdges.end(); i++) {
57  delete(*i);
58  }
59  myEdges.clear();
60 }
61 
62 
63 bool
64 NIVissimNodeDef_Edges::dictionary(int id, const std::string& name,
66  NIVissimNodeDef_Edges* o = new NIVissimNodeDef_Edges(id, name, edges);
67  if (!NIVissimNodeDef::dictionary(id, o)) {
68  delete o;
69  return false;
70  }
71  return true;
72 }
73 
74 
75 /*
76 void
77 NIVissimNodeDef_Edges::searchAndSetConnections() {
78  std::vector<int> connections;
79  std::vector<int> edges;
80  Boundary boundary;
81  for (NIVissimNodeParticipatingEdgeVector::const_iterator i = myEdges.begin(); i != myEdges.end(); i++) {
82  NIVissimNodeParticipatingEdge* edge = *i;
83  NIVissimConnection* c =
84  NIVissimConnection::dictionary(edge->getID());
85  NIVissimEdge* e =
86  NIVissimEdge::dictionary(edge->getID());
87  if (c != 0) {
88  connections.push_back(edge->getID());
89  boundary.add(c->getFromGeomPosition());
90  boundary.add(c->getToGeomPosition());
91  c->setNodeCluster(myID);
92  }
93  if (e != 0) {
94  edges.push_back(edge->getID());
95  boundary.add(e->getGeomPosition(edge->getFromPos()));
96  boundary.add(e->getGeomPosition(edge->getToPos()));
97  }
98  }
99  NIVissimConnectionCluster* c =
100  new NIVissimConnectionCluster(connections, boundary, myID, edges);
101  for (std::vector<int>::iterator j = edges.begin(); j != edges.end(); j++) {
102  NIVissimEdge* edge = NIVissimEdge::dictionary(*j);
103  edge->myConnectionClusters.push_back(c);
104  }
105 }
106 */
107 
108 
109 double
111  for (NIVissimNodeParticipatingEdgeVector::const_iterator i = myEdges.begin(); i != myEdges.end(); i++) {
113  if (edge->getID() == edgeid) {
114  return (edge->getFromPos() + edge->getToPos()) / (double) 2.0;
115  }
116  }
117  return -1;
118 }
119 
120 
121 
122 /****************************************************************************/
123 
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