SUMO - Simulation of Urban MObility
NIVissimNodeDef.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) 2002-2016 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 #include <iostream> // !!! debug
34 #include <cassert>
35 #include "NIVissimNodeDef.h"
36 #include "NIVissimConnection.h"
37 #include "NIVissimDisturbance.h"
38 #include "NIVissimTL.h"
39 
40 #ifdef CHECK_MEMORY_LEAKS
41 #include <foreign/nvwa/debug_new.h>
42 #endif // CHECK_MEMORY_LEAKS
43 
44 
45 // ===========================================================================
46 // static member variables
47 // ===========================================================================
50 
51 
52 // ===========================================================================
53 // method definitions
54 // ===========================================================================
55 NIVissimNodeDef::NIVissimNodeDef(int id, const std::string& name)
56  : myID(id), myName(name) {}
57 
58 
60 
61 
62 bool
64  DictType::iterator i = myDict.find(id);
65  if (i == myDict.end()) {
66  myDict[id] = o;
67  myMaxID = myMaxID > id
68  ? myMaxID
69  : id;
70 // o->computeBounding();
71  return true;
72  }
73  return false;
74 }
75 
76 
79  DictType::iterator i = myDict.find(id);
80  if (i == myDict.end()) {
81  return 0;
82  }
83  return (*i).second;
84 }
85 
86 /*
87 void
88 NIVissimNodeDef::buildNodeClusters()
89 {
90  for(DictType::iterator i=myDict.begin(); i!=myDict.end(); i++) {
91  int cluster = (*i).second->buildNodeCluster();
92  }
93 }
94 */
95 
96 
97 /*
98 
99 std::vector<int>
100 NIVissimNodeDef::getWithin(const AbstractPoly &p, SUMOReal off)
101 {
102  std::vector<int> ret;
103  for(DictType::iterator i=myDict.begin(); i!=myDict.end(); i++) {
104  NIVissimNodeDef *d = (*i).second;
105  if(d->partialWithin(p, off)) {
106  ret.push_back((*i).first);
107  }
108  }
109  return ret;
110 }
111 
112 bool
113 NIVissimNodeDef::partialWithin(const AbstractPoly &p, SUMOReal off) const
114 {
115  assert(myBoundary!=0&&myBoundary->xmax()>=myBoundary->xmin());
116  return myBoundary->partialWithin(p, off);
117 }
118 
119 
120 void
121 NIVissimNodeDef::dict_assignConnectionsToNodes() {
122  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
123  (*i).second->searchAndSetConnections();
124  }
125 }
126 */
127 
128 
129 size_t
131  return myDict.size();
132 }
133 
134 
135 
136 void
138  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
139  delete(*i).second;
140  }
141  myDict.clear();
142 }
143 
144 
145 int
147  return myMaxID;
148 }
149 
150 
151 
152 /****************************************************************************/
153 
static void clearDict()
virtual ~NIVissimNodeDef()
static int myMaxID
static int getMaxID()
static size_t dictSize()
static bool dictionary(int id, NIVissimNodeDef *o)
std::map< int, NIVissimNodeDef * > DictType
static DictType myDict
NIVissimNodeDef(int id, const std::string &name)