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-2018 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 /****************************************************************************/
16 // -------------------
17 /****************************************************************************/
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
25 
26 
27 #include <string>
28 #include <map>
29 #include <algorithm>
30 #include <cassert>
31 #include <utils/geom/Boundary.h>
33 #include "NIVissimNodeDef.h"
34 #include "NIVissimEdge.h"
35 #include "NIVissimNodeDef_Edges.h"
36 #include "NIVissimDisturbance.h"
37 #include "NIVissimConnection.h"
38 
39 
40 // ===========================================================================
41 // method definitions
42 // ===========================================================================
44  const std::string& name, const NIVissimNodeParticipatingEdgeVector& edges)
45  : NIVissimNodeDef(id, name), myEdges(edges) {}
46 
47 
49  for (NIVissimNodeParticipatingEdgeVector::iterator i = myEdges.begin(); i != myEdges.end(); i++) {
50  delete(*i);
51  }
52  myEdges.clear();
53 }
54 
55 
56 bool
57 NIVissimNodeDef_Edges::dictionary(int id, const std::string& name,
59  NIVissimNodeDef_Edges* o = new NIVissimNodeDef_Edges(id, name, edges);
60  if (!NIVissimNodeDef::dictionary(id, o)) {
61  delete o;
62  return false;
63  }
64  return true;
65 }
66 
67 
68 /*
69 void
70 NIVissimNodeDef_Edges::searchAndSetConnections() {
71  std::vector<int> connections;
72  std::vector<int> edges;
73  Boundary boundary;
74  for (NIVissimNodeParticipatingEdgeVector::const_iterator i = myEdges.begin(); i != myEdges.end(); i++) {
75  NIVissimNodeParticipatingEdge* edge = *i;
76  NIVissimConnection* c =
77  NIVissimConnection::dictionary(edge->getID());
78  NIVissimEdge* e =
79  NIVissimEdge::dictionary(edge->getID());
80  if (c != 0) {
81  connections.push_back(edge->getID());
82  boundary.add(c->getFromGeomPosition());
83  boundary.add(c->getToGeomPosition());
84  c->setNodeCluster(myID);
85  }
86  if (e != 0) {
87  edges.push_back(edge->getID());
88  boundary.add(e->getGeomPosition(edge->getFromPos()));
89  boundary.add(e->getGeomPosition(edge->getToPos()));
90  }
91  }
92  NIVissimConnectionCluster* c =
93  new NIVissimConnectionCluster(connections, boundary, myID, edges);
94  for (std::vector<int>::iterator j = edges.begin(); j != edges.end(); j++) {
95  NIVissimEdge* edge = NIVissimEdge::dictionary(*j);
96  edge->myConnectionClusters.push_back(c);
97  }
98 }
99 */
100 
101 
102 double
104  for (NIVissimNodeParticipatingEdgeVector::const_iterator i = myEdges.begin(); i != myEdges.end(); i++) {
106  if (edge->getID() == edgeid) {
107  return (edge->getFromPos() + edge->getToPos()) / (double) 2.0;
108  }
109  }
110  return -1;
111 }
112 
113 
114 
115 /****************************************************************************/
116 
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