Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
NIVissimNodeDef_Edges.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
19// -------------------
20/****************************************************************************/
21#include <config.h>
22
23
24
25#include <string>
26#include <map>
27#include <algorithm>
28#include <cassert>
29#include <utils/geom/Boundary.h>
31#include "NIVissimNodeDef.h"
32#include "NIVissimEdge.h"
34#include "NIVissimDisturbance.h"
35#include "NIVissimConnection.h"
36
37
38// ===========================================================================
39// method definitions
40// ===========================================================================
42 const std::string& name, const NIVissimNodeParticipatingEdgeVector& edges)
43 : NIVissimNodeDef(id, name), myEdges(edges) {}
44
45
47 for (NIVissimNodeParticipatingEdgeVector::iterator i = myEdges.begin(); i != myEdges.end(); i++) {
48 delete (*i);
49 }
50 myEdges.clear();
51}
52
53
54bool
55NIVissimNodeDef_Edges::dictionary(int id, const std::string& name,
57 NIVissimNodeDef_Edges* o = new NIVissimNodeDef_Edges(id, name, edges);
58 if (!NIVissimNodeDef::dictionary(id, o)) {
59 delete o;
60 return false;
61 }
62 return true;
63}
64
65
66/*
67void
68NIVissimNodeDef_Edges::searchAndSetConnections() {
69 std::vector<int> connections;
70 std::vector<int> edges;
71 Boundary boundary;
72 for (NIVissimNodeParticipatingEdgeVector::const_iterator i = myEdges.begin(); i != myEdges.end(); i++) {
73 NIVissimNodeParticipatingEdge* edge = *i;
74 NIVissimConnection* c =
75 NIVissimConnection::dictionary(edge->getID());
76 NIVissimEdge* e =
77 NIVissimEdge::dictionary(edge->getID());
78 if (c != 0) {
79 connections.push_back(edge->getID());
80 boundary.add(c->getFromGeomPosition());
81 boundary.add(c->getToGeomPosition());
82 c->setNodeCluster(myID);
83 }
84 if (e != 0) {
85 edges.push_back(edge->getID());
86 boundary.add(e->getGeomPosition(edge->getFromPos()));
87 boundary.add(e->getGeomPosition(edge->getToPos()));
88 }
89 }
90 NIVissimConnectionCluster* c =
91 new NIVissimConnectionCluster(connections, boundary, myID, edges);
92 for (std::vector<int>::iterator j = edges.begin(); j != edges.end(); j++) {
93 NIVissimEdge* edge = NIVissimEdge::dictionary(*j);
94 edge->myConnectionClusters.push_back(c);
95 }
96}
97*/
98
99
100double
102 for (NIVissimNodeParticipatingEdgeVector::const_iterator i = myEdges.begin(); i != myEdges.end(); i++) {
104 if (edge->getID() == edgeid) {
105 return (edge->getFromPos() + edge->getToPos()) / (double) 2.0;
106 }
107 }
108 return -1;
109}
110
111
112/****************************************************************************/
std::vector< NIVissimNodeParticipatingEdge * > NIVissimNodeParticipatingEdgeVector
NIVissimNodeParticipatingEdgeVector myEdges
NIVissimNodeDef_Edges(int id, const std::string &name, const NIVissimNodeParticipatingEdgeVector &edges)
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)