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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
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 
40 // ===========================================================================
41 // static member variables
42 // ===========================================================================
45 
46 
47 // ===========================================================================
48 // method definitions
49 // ===========================================================================
50 NIVissimNodeDef::NIVissimNodeDef(int id, const std::string& name)
51  : myID(id), myName(name) {}
52 
53 
55 
56 
57 bool
59  DictType::iterator i = myDict.find(id);
60  if (i == myDict.end()) {
61  myDict[id] = o;
62  myMaxID = myMaxID > id
63  ? myMaxID
64  : id;
65 // o->computeBounding();
66  return true;
67  }
68  return false;
69 }
70 
71 
74  DictType::iterator i = myDict.find(id);
75  if (i == myDict.end()) {
76  return 0;
77  }
78  return (*i).second;
79 }
80 
81 /*
82 void
83 NIVissimNodeDef::buildNodeClusters()
84 {
85  for(DictType::iterator i=myDict.begin(); i!=myDict.end(); i++) {
86  int cluster = (*i).second->buildNodeCluster();
87  }
88 }
89 */
90 
91 
92 /*
93 
94 std::vector<int>
95 NIVissimNodeDef::getWithin(const AbstractPoly &p, double off)
96 {
97  std::vector<int> ret;
98  for(DictType::iterator i=myDict.begin(); i!=myDict.end(); i++) {
99  NIVissimNodeDef *d = (*i).second;
100  if(d->partialWithin(p, off)) {
101  ret.push_back((*i).first);
102  }
103  }
104  return ret;
105 }
106 
107 bool
108 NIVissimNodeDef::partialWithin(const AbstractPoly &p, double off) const
109 {
110  assert(myBoundary!=0&&myBoundary->xmax()>=myBoundary->xmin());
111  return myBoundary->partialWithin(p, off);
112 }
113 
114 
115 void
116 NIVissimNodeDef::dict_assignConnectionsToNodes() {
117  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
118  (*i).second->searchAndSetConnections();
119  }
120 }
121 */
122 
123 
124 int
126  return (int)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 bool dictionary(int id, NIVissimNodeDef *o)
std::map< int, NIVissimNodeDef * > DictType
static DictType myDict
static int dictSize()
NIVissimNodeDef(int id, const std::string &name)