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-sim.org/
12 // Copyright (C) 2001-2014 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 <netbuild/NBNetBuilder.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  // convert/publicate geometry
55  for (PositionVector::const_iterator i = geom.begin(); i != geom.end(); ++i) {
56  Position p = *i;
58  WRITE_WARNING("Unable to project coordinates for edge '" + toString(id) + "'.");
59  }
61  }
62  //
63  dictionary(id, this);
64 }
65 
66 
68 
69 
70 bool
72  DictType::iterator i = myDict.find(id);
73  if (i == myDict.end()) {
74  myDict[id] = e;
75  return true;
76  }
77  return false;
78 }
79 
80 
83  DictType::iterator i = myDict.find(id);
84  if (i == myDict.end()) {
85  return 0;
86  }
87  return (*i).second;
88 }
89 
90 
91 
94  if (myGeom.length() > pos) {
95  return myGeom.positionAtOffset(pos);
96  } else if (myGeom.length() == pos) {
97  return myGeom[-1];
98  } else {
100  SUMOReal amount = pos - myGeom.length();
101  Position ne = GeomHelper::extrapolate_second(g[-2], g[-1], amount * 2);
102  g.pop_back();
103  g.push_back(ne);
104  return g.positionAtOffset(pos);
105  }
106 }
107 
108 
109 void
111  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
112  NIVissimAbstractEdge* e = (*i).second;
113  e->splitAssigning();
114  }
115 }
116 
117 void
119 
120 
121 
122 
123 
124 bool
126  return myGeom.intersects(c->myGeom);
127 }
128 
129 
130 Position
132  return myGeom.intersectsAtPoint(c->myGeom);
133 }
134 
135 
136 SUMOReal
138  const Position& p2) const {
139  // !!! not needed
141  myGeom.front(), myGeom.back(), p1, p2);
143  myGeom.front(), myGeom.back(), p);
144 }
145 
146 
147 
148 std::vector<int>
150  std::vector<int> ret;
151  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
152  NIVissimAbstractEdge* e = (*i).second;
153  if (e->overlapsWith(p, offset)) {
154  ret.push_back(e->myID);
155  }
156  }
157  return ret;
158 }
159 
160 
161 bool
163  return myGeom.overlapsWith(p, offset);
164 }
165 
166 
167 bool
169  return myNode != -1;
170 }
171 
172 
173 int
175  return myID;
176 }
177 
178 void
180  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
181  delete(*i).second;
182  }
183  myDict.clear();
184 }
185 
186 
187 const PositionVector&
189  return myGeom;
190 }
191 
192 
193 void
195  myDisturbances.push_back(disturbance);
196 }
197 
198 
199 const std::vector<int>&
201  return myDisturbances;
202 }
203 
204 
205 
206 /****************************************************************************/
207 
bool overlapsWith(const AbstractPoly &p, SUMOReal offset=0.0) const
static Position intersection_position2D(const Position &p11, const Position &p12, const Position &p21, const Position &p22)
returns the intersection point of the (infinite) lines p11,p12 and p21,p22. If the given lines are pa...
Definition: GeomHelper.cpp:193
static bool dictionary(int id, NIVissimAbstractEdge *e)
static bool transformCoordinates(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
void addDisturbance(int disturbance)
bool intersects(const Position &p1, const Position &p2) const
static Position extrapolate_second(const Position &p1, const Position &p2, SUMOReal length)
Definition: GeomHelper.cpp:243
const PositionVector & getGeometry() const
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
bool crossesEdge(NIVissimAbstractEdge *c) const
static SUMOReal nearest_offset_on_line_to_point2D(const Position &l1, const Position &l2, const Position &p, bool perpendicular=true)
Definition: GeomHelper.cpp:251
NIVissimAbstractEdge(int id, const PositionVector &geom)
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A list of positions.
Position getGeomPosition(SUMOReal pos) const
Position positionAtOffset(SUMOReal pos, SUMOReal lateralOffset=0) const
Returns the position at the given length.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:53
Position intersectsAtPoint(const Position &p1, const Position &p2) const
SUMOReal length() const
Returns the length.
void push_back(const PositionVector &p)
Appends all positions from the given vector.
bool overlapsWith(const AbstractPoly &poly, SUMOReal offset=0) const
Returns the information whether the given polygon overlaps with this Again a boundary may be specifie...
std::vector< int > myDisturbances
std::map< int, NIVissimAbstractEdge * > DictType
#define SUMOReal
Definition: config.h:215
const std::vector< int > & getDisturbances() const
Position crossesEdgeAtPoint(NIVissimAbstractEdge *c) const
void push_back_noDoublePos(const Position &p)
static std::vector< int > getWithin(const AbstractPoly &p, SUMOReal offset=0.0)
SUMOReal crossesAtPoint(const Position &p1, const Position &p2) const