SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NIVissimAbstractEdge.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // -------------------
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
12 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 
34 #include <map>
35 #include <cassert>
37 #include <utils/common/ToString.h>
38 #include <utils/geom/GeomHelper.h>
39 #include <utils/geom/Line.h>
41 #include <netimport/NILoader.h>
42 #include "NIVissimAbstractEdge.h"
43 
44 #ifdef CHECK_MEMORY_LEAKS
45 #include <foreign/nvwa/debug_new.h>
46 #endif // CHECK_MEMORY_LEAKS
47 
48 
50 
52  const PositionVector& geom)
53  : myID(id), myNode(-1)
54 {
55  // convert/publicate geometry
56  for (PositionVector::ContType::const_iterator i = geom.begin(); i != geom.end(); ++i) {
57  Position p = *i;
59  WRITE_WARNING("Unable to project coordinates for edge '" + toString(id) + "'.");
60  }
62  }
63  //
64  dictionary(id, this);
65 }
66 
67 
69 
70 
71 bool
73  DictType::iterator i = myDict.find(id);
74  if (i == myDict.end()) {
75  myDict[id] = e;
76  return true;
77  }
78  return false;
79 }
80 
81 
84  DictType::iterator i = myDict.find(id);
85  if (i == myDict.end()) {
86  return 0;
87  }
88  return (*i).second;
89 }
90 
91 
92 
95  if (myGeom.length() > pos) {
96  return myGeom.positionAtLengthPosition(pos);
97  } else if (myGeom.length() == pos) {
98  return myGeom[-1];
99  } else {
101  SUMOReal amount = pos - myGeom.length();
102  Position ne = GeomHelper::extrapolate_second(g[-2], g[-1], amount * 2);
103  g.pop_back();
104  g.push_back(ne);
105  return g.positionAtLengthPosition(pos);
106  }
107 }
108 
109 
110 void
112  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
113  NIVissimAbstractEdge* e = (*i).second;
114  e->splitAssigning();
115  }
116 }
117 
118 void
120 
121 
122 
123 
124 
125 bool
127  return myGeom.intersects(c->myGeom);
128 }
129 
130 
131 Position
133  return myGeom.intersectsAtPoint(c->myGeom);
134 }
135 
136 
137 SUMOReal
139  const Position& p2) const {
140  // !!! not needed
142  myGeom.getBegin(), myGeom.getEnd(), p1, p2);
144  myGeom.getBegin(), myGeom.getEnd(), p);
145 }
146 
147 
148 
149 std::vector<int>
151  std::vector<int> ret;
152  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
153  NIVissimAbstractEdge* e = (*i).second;
154  if (e->overlapsWith(p, offset)) {
155  ret.push_back(e->myID);
156  }
157  }
158  return ret;
159 }
160 
161 
162 bool
164  return myGeom.overlapsWith(p, offset);
165 }
166 
167 
168 bool
170  return myNode != -1;
171 }
172 
173 
174 int
176  return myID;
177 }
178 
179 void
181  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
182  delete(*i).second;
183  }
184  myDict.clear();
185 }
186 
187 
188 const PositionVector&
190  return myGeom;
191 }
192 
193 
194 void
196  myDisturbances.push_back(disturbance);
197 }
198 
199 
200 const std::vector<int>&
202  return myDisturbances;
203 }
204 
205 
206 
207 /****************************************************************************/
208