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-2017 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 
41 // ===========================================================================
42 // static member variables
43 // ===========================================================================
46 
47 
48 // ===========================================================================
49 // method definitions
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, double 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, double off) const
110 {
111  assert(myBoundary!=0&&myBoundary->xmax()>=myBoundary->xmin());
112  return myBoundary->partialWithin(p, off);
113 }
114 
115 
116 void
117 NIVissimNodeDef::dict_assignConnectionsToNodes() {
118  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
119  (*i).second->searchAndSetConnections();
120  }
121 }
122 */
123 
124 
125 int
127  return (int)myDict.size();
128 }
129 
130 
131 
132 void
134  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
135  delete(*i).second;
136  }
137  myDict.clear();
138 }
139 
140 
141 int
143  return myMaxID;
144 }
145 
146 
147 
148 /****************************************************************************/
149 
static void clearDict()
virtual ~NIVissimNodeDef()
static int myMaxID
static int getMaxID()
static bool dictionary(int id, NIVissimNodeDef *o)
std::map< int, NIVissimNodeDef * > DictType
static DictType myDict
static int dictSize()
NIVissimNodeDef(int id, const std::string &name)