SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NIVissimNodeDef.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // -------------------
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
10 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
31 
32 #include <iostream> // !!! debug
33 #include <cassert>
34 #include "NIVissimNodeDef.h"
35 #include "NIVissimConnection.h"
36 #include "NIVissimDisturbance.h"
37 #include "NIVissimTL.h"
38 
39 #ifdef CHECK_MEMORY_LEAKS
40 #include <foreign/nvwa/debug_new.h>
41 #endif // CHECK_MEMORY_LEAKS
42 // ===========================================================================
43 // used namespaces
44 // ===========================================================================
45 
46 using namespace std;
47 
50 
51 NIVissimNodeDef::NIVissimNodeDef(int id, const std::string& name)
52  : myID(id), myName(name) {}
53 
54 
56 
57 
58 bool
60  DictType::iterator i = myDict.find(id);
61  if (i == myDict.end()) {
62  myDict[id] = o;
63  myMaxID = myMaxID > id
64  ? myMaxID
65  : id;
66 // o->computeBounding();
67  return true;
68  }
69  return false;
70 }
71 
72 
75  DictType::iterator i = myDict.find(id);
76  if (i == myDict.end()) {
77  return 0;
78  }
79  return (*i).second;
80 }
81 
82 /*
83 void
84 NIVissimNodeDef::buildNodeClusters()
85 {
86  for(DictType::iterator i=myDict.begin(); i!=myDict.end(); i++) {
87  int cluster = (*i).second->buildNodeCluster();
88  }
89 }
90 */
91 
92 
93 /*
94 
95 std::vector<int>
96 NIVissimNodeDef::getWithin(const AbstractPoly &p, SUMOReal off)
97 {
98  std::vector<int> ret;
99  for(DictType::iterator i=myDict.begin(); i!=myDict.end(); i++) {
100  NIVissimNodeDef *d = (*i).second;
101  if(d->partialWithin(p, off)) {
102  ret.push_back((*i).first);
103  }
104  }
105  return ret;
106 }
107 
108 bool
109 NIVissimNodeDef::partialWithin(const AbstractPoly &p, SUMOReal off) const
110 {
111  assert(myBoundary!=0&&myBoundary->xmax()>=myBoundary->xmin());
112  return myBoundary->partialWithin(p, off);
113 }
114 */
115 
116 void
118  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
119  (*i).second->searchAndSetConnections();
120  }
121 }
122 
123 
124 size_t
126  return myDict.size();
127 }
128 
129 
130 
131 void
133  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
134  delete(*i).second;
135  }
136  myDict.clear();
137 }
138 
139 
140 int
142  return myMaxID;
143 }
144 
145 
146 
147 /****************************************************************************/
148 
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
static void dict_assignConnectionsToNodes()
NIVissimNodeDef(int id, const std::string &name)