SUMO - Simulation of Urban MObility
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
PositionVector.h
Go to the documentation of this file.
1
/****************************************************************************/
9
// A list of positions
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
#ifndef PositionVector_h
23
#define PositionVector_h
24
25
26
// ===========================================================================
27
// included modules
28
// ===========================================================================
29
#ifdef _MSC_VER
30
#include <
windows_config.h
>
31
#else
32
#include <
config.h
>
33
#endif
34
35
#include <vector>
36
#include "
AbstractPoly.h
"
37
38
39
// ===========================================================================
40
// class declarations
41
// ===========================================================================
42
class
Line
;
43
class
Boundary
;
44
45
46
// ===========================================================================
47
// class definitions
48
// ===========================================================================
53
class
PositionVector
:
public
AbstractPoly
,
private
std::vector<Position> {
54
55
private
:
56
typedef
std::vector<Position>
vp
;
57
58
public
:
63
PositionVector
();
64
65
69
PositionVector
(
const
std::vector<Position>& v);
70
71
73
~PositionVector
();
74
75
using
vp::iterator;
76
using
vp::const_iterator;
77
using
vp::const_reference;
78
using
vp::value_type;
79
using
vp::begin;
80
using
vp::end;
81
using
vp::push_back
;
82
using
vp::pop_back;
83
using
vp::clear;
84
using
vp::size;
85
using
vp::front;
86
using
vp::back;
87
using
vp::reference;
88
89
92
93
97
void
push_back
(
const
PositionVector
& p);
99
100
102
void
push_front
(
const
Position
& p);
103
105
Position
pop_front
();
106
107
void
insertAt
(
int
index,
const
Position
& p);
108
109
void
replaceAt
(
int
index,
const
Position
& by);
110
111
void
eraseAt
(
int
i);
112
115
bool
around
(
const
Position
& p,
SUMOReal
offset = 0)
const
;
116
119
bool
overlapsWith
(
const
AbstractPoly
& poly,
SUMOReal
offset = 0)
const
;
120
122
bool
intersects
(
const
Position
& p1,
const
Position
& p2)
const
;
123
125
bool
intersects
(
const
PositionVector
& v1)
const
;
126
128
Position
intersectsAtPoint
(
const
Position
& p1,
129
const
Position
& p2)
const
;
// !!!
130
132
PositionVector
intersectionPoints2D
(
const
Line
& line)
const
;
133
136
std::vector<SUMOReal>
intersectsAtLengths2D
(
const
PositionVector
& other)
const
;
// !!!
137
140
std::vector<SUMOReal>
intersectsAtLengths2D
(
const
Line
& line)
const
;
// !!!
141
143
Position
intersectsAtPoint
(
const
PositionVector
& v1)
const
;
// !!!
144
146
void
closePolygon
();
147
150
const
Position
&
operator[]
(
int
index)
const
;
151
Position
&
operator[]
(
int
index);
152
154
Position
positionAtOffset
(
SUMOReal
pos,
SUMOReal
lateralOffset = 0)
const
;
155
157
Position
positionAtOffset2D
(
SUMOReal
pos,
SUMOReal
lateralOffset = 0)
const
;
158
160
SUMOReal
rotationDegreeAtOffset
(
SUMOReal
pos)
const
;
161
163
SUMOReal
slopeDegreeAtOffset
(
SUMOReal
pos)
const
;
164
166
static
Position
positionAtOffset
(
const
Position
& p1,
167
const
Position
& p2,
SUMOReal
pos,
SUMOReal
lateralOffset);
168
170
static
Position
positionAtOffset2D
(
const
Position
& p1,
171
const
Position
& p2,
SUMOReal
pos,
SUMOReal
lateralOffset);
172
174
Boundary
getBoxBoundary
()
const
;
175
178
Position
getPolygonCenter
()
const
;
179
181
Position
getCentroid
()
const
;
182
184
void
scaleRelative
(
SUMOReal
factor);
185
187
void
scaleAbsolute
(
SUMOReal
offset);
188
189
Position
getLineCenter
()
const
;
190
192
SUMOReal
length
()
const
;
194
SUMOReal
length2D
()
const
;
195
196
198
SUMOReal
area
()
const
;
199
201
bool
partialWithin
(
const
AbstractPoly
& poly,
SUMOReal
offset = 0)
const
;
202
204
std::pair<PositionVector, PositionVector>
splitAt
(
SUMOReal
where)
const
;
205
207
friend
std::ostream&
operator<<
(std::ostream& os,
const
PositionVector
& geom);
208
209
bool
crosses
(
const
Position
& p1,
const
Position
& p2)
const
;
210
211
void
add
(
SUMOReal
xoff,
SUMOReal
yoff,
SUMOReal
zoff);
212
213
void
reshiftRotate
(
SUMOReal
xoff,
SUMOReal
yoff,
SUMOReal
rot);
214
215
PositionVector
convexHull
()
const
;
216
217
int
appendWithCrossingPoint
(
const
PositionVector
& v);
218
219
// @brief append the given vector to this one
220
void
append
(
const
PositionVector
& v);
221
222
PositionVector
getSubpart
(
SUMOReal
beginOffset,
SUMOReal
endOffset)
const
;
223
224
PositionVector
getSubpart2D
(
SUMOReal
beginOffset,
SUMOReal
endOffset)
const
;
225
226
PositionVector
getSubpartByIndex
(
int
beginIndex,
int
count)
const
;
227
228
void
sortAsPolyCWByAngle
();
229
230
void
sortByIncreasingXY
();
231
232
void
extrapolate
(
SUMOReal
val);
233
234
PositionVector
reverse
()
const
;
235
236
void
move2side
(
SUMOReal
amount);
237
238
Line
lineAt
(
int
pos)
const
;
239
240
Line
getBegLine
()
const
;
241
242
Line
getEndLine
()
const
;
243
244
245
// @brief inserts p between the two closest positions and returns the insertion index
246
int
insertAtClosest
(
const
Position
& p);
247
249
bool
operator==
(
const
PositionVector
& v2)
const
;
250
251
class
as_poly_cw_sorter
{
252
public
:
254
as_poly_cw_sorter
() {};
255
256
public
:
258
int
operator()
(
const
Position
& p1,
const
Position
& p2)
const
;
259
260
};
261
262
class
increasing_x_y_sorter
{
263
public
:
265
explicit
increasing_x_y_sorter
();
266
267
public
:
269
int
operator()
(
const
Position
& p1,
const
Position
& p2)
const
;
270
271
};
272
273
// !!!
274
SUMOReal
isLeft
(
const
Position
& P0,
const
Position
& P1,
const
Position
& P2)
const
;
275
276
void
pruneFromBeginAt
(
const
Position
& p);
277
void
pruneFromEndAt
(
const
Position
& p);
278
279
SUMOReal
beginEndAngle
()
const
;
280
281
SUMOReal
nearest_offset_to_point2D
(
const
Position
& p,
bool
perpendicular =
true
)
const
;
282
283
/* @brief index of the closest position to p
284
* @note: may only be called for a non-empty vector */
285
int
indexOfClosest
(
const
Position
& p)
const
;
286
287
// distances of all my points to s and all of s points to myself
288
std::vector<SUMOReal>
distances
(
const
PositionVector
& s)
const
;
289
290
SUMOReal
distance
(
const
Position
& p)
const
;
291
292
void
push_back_noDoublePos
(
const
Position
& p);
293
void
push_front_noDoublePos
(
const
Position
& p);
294
295
bool
isClosed
()
const
;
296
301
void
removeDoublePoints
(
SUMOReal
minDist =
POSITION_EPS
,
bool
assertLength =
false
);
302
303
void
removeColinearPoints
();
304
305
};
306
307
308
#endif
309
310
/****************************************************************************/
311
tmp
buildd
sumo-0.21.0+dfsg
src
utils
geom
PositionVector.h
Generated on Thu Nov 20 2014 19:49:58 for SUMO - Simulation of Urban MObility by
1.8.1.2