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