Eclipse SUMO - Simulation of Urban MObility
NIVissimNodeDef.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2002-2019 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 #include <iostream> // !!! debug
27 #include <cassert>
28 #include "NIVissimNodeDef.h"
29 #include "NIVissimConnection.h"
30 #include "NIVissimDisturbance.h"
31 #include "NIVissimTL.h"
32 
33 
34 // ===========================================================================
35 // static member variables
36 // ===========================================================================
39 
40 
41 // ===========================================================================
42 // method definitions
43 // ===========================================================================
44 NIVissimNodeDef::NIVissimNodeDef(int id, const std::string& name)
45  : myID(id), myName(name) {}
46 
47 
49 
50 
51 bool
53  DictType::iterator i = myDict.find(id);
54  if (i == myDict.end()) {
55  myDict[id] = o;
56  myMaxID = myMaxID > id
57  ? myMaxID
58  : id;
59 // o->computeBounding();
60  return true;
61  }
62  return false;
63 }
64 
65 
68  DictType::iterator i = myDict.find(id);
69  if (i == myDict.end()) {
70  return nullptr;
71  }
72  return (*i).second;
73 }
74 
75 /*
76 void
77 NIVissimNodeDef::buildNodeClusters()
78 {
79  for(DictType::iterator i=myDict.begin(); i!=myDict.end(); i++) {
80  int cluster = (*i).second->buildNodeCluster();
81  }
82 }
83 */
84 
85 
86 /*
87 
88 std::vector<int>
89 NIVissimNodeDef::getWithin(const AbstractPoly &p, double off)
90 {
91  std::vector<int> ret;
92  for(DictType::iterator i=myDict.begin(); i!=myDict.end(); i++) {
93  NIVissimNodeDef *d = (*i).second;
94  if(d->partialWithin(p, off)) {
95  ret.push_back((*i).first);
96  }
97  }
98  return ret;
99 }
100 
101 bool
102 NIVissimNodeDef::partialWithin(const AbstractPoly &p, double off) const
103 {
104  assert(myBoundary!=0&&myBoundary->xmax()>=myBoundary->xmin());
105  return myBoundary->partialWithin(p, off);
106 }
107 
108 
109 void
110 NIVissimNodeDef::dict_assignConnectionsToNodes() {
111  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
112  (*i).second->searchAndSetConnections();
113  }
114 }
115 */
116 
117 
118 int
120  return (int)myDict.size();
121 }
122 
123 
124 
125 void
127  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
128  delete (*i).second;
129  }
130  myDict.clear();
131 }
132 
133 
134 int
136  return myMaxID;
137 }
138 
139 
140 
141 /****************************************************************************/
142 
NIVissimNodeDef::dictionary
static bool dictionary(int id, NIVissimNodeDef *o)
Definition: NIVissimNodeDef.cpp:52
NIVissimNodeDef::dictSize
static int dictSize()
Definition: NIVissimNodeDef.cpp:119
NIVissimNodeDef::myDict
static DictType myDict
Definition: NIVissimNodeDef.h:59
NIVissimNodeDef::myMaxID
static int myMaxID
Definition: NIVissimNodeDef.h:60
NIVissimNodeDef::NIVissimNodeDef
NIVissimNodeDef(int id, const std::string &name)
Definition: NIVissimNodeDef.cpp:44
NIVissimNodeDef::~NIVissimNodeDef
virtual ~NIVissimNodeDef()
Definition: NIVissimNodeDef.cpp:48
NIVissimDisturbance.h
NIVissimNodeDef.h
NIVissimNodeDef
Definition: NIVissimNodeDef.h:34
NIVissimConnection.h
NIVissimTL.h
NIVissimNodeDef::clearDict
static void clearDict()
Definition: NIVissimNodeDef.cpp:126
NIVissimNodeDef::getMaxID
static int getMaxID()
Definition: NIVissimNodeDef.cpp:135
config.h
NIVissimNodeDef::DictType
std::map< int, NIVissimNodeDef * > DictType
Definition: NIVissimNodeDef.h:58