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
ShapeContainer.cpp
Go to the documentation of this file.
1
/****************************************************************************/
10
// Storage for geometrical objects, sorted by the layers they are in
11
/****************************************************************************/
12
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
13
// Copyright (C) 2002-2014 DLR (http://www.dlr.de/) and contributors
14
/****************************************************************************/
15
//
16
// This file is part of SUMO.
17
// SUMO is free software: you can redistribute it and/or modify
18
// it under the terms of the GNU General Public License as published by
19
// the Free Software Foundation, either version 3 of the License, or
20
// (at your option) any later version.
21
//
22
/****************************************************************************/
23
24
25
// ===========================================================================
26
// included modules
27
// ===========================================================================
28
#ifdef _MSC_VER
29
#include <
windows_config.h
>
30
#else
31
#include <
config.h
>
32
#endif
33
34
#include <fstream>
35
#include <stdlib.h>
36
#include <iostream>
37
#include <utility>
38
#include <string>
39
#include <cmath>
40
#include <
utils/common/NamedObjectCont.h
>
41
#include <
utils/shapes/PointOfInterest.h
>
42
#include <
utils/shapes/Polygon.h
>
43
#include <
utils/shapes/ShapeContainer.h
>
44
#include <
utils/common/MsgHandler.h
>
45
#include <
utils/common/UtilExceptions.h
>
46
#include <
utils/common/ToString.h
>
47
#include <
utils/common/StdDefs.h
>
48
49
#ifdef CHECK_MEMORY_LEAKS
50
#include <
foreign/nvwa/debug_new.h
>
51
#endif // CHECK_MEMORY_LEAKS
52
53
54
// ===========================================================================
55
// method definitions
56
// ===========================================================================
57
ShapeContainer::ShapeContainer
() {}
58
59
ShapeContainer::~ShapeContainer
() {}
60
61
bool
62
ShapeContainer::addPolygon
(
const
std::string&
id
,
const
std::string& type,
63
const
RGBColor
& color,
SUMOReal
layer,
64
SUMOReal
angle,
const
std::string& imgFile,
65
const
PositionVector
& shape,
bool
fill) {
66
Polygon
* p =
new
Polygon
(
id
, type, color, shape, fill, layer, angle, imgFile);
67
if
(!
myPolygons
.
add
(
id
, p)) {
68
delete
p;
69
return
false
;
70
}
71
return
true
;
72
}
73
74
75
bool
76
ShapeContainer::addPOI
(
const
std::string&
id
,
const
std::string& type,
77
const
RGBColor
& color,
SUMOReal
layer,
SUMOReal
angle,
const
std::string& imgFile,
78
const
Position
& pos,
SUMOReal
width,
SUMOReal
height) {
79
PointOfInterest
* p =
new
PointOfInterest
(
id
, type, color, pos, layer, angle, imgFile, width, height);
80
if
(!
myPOIs
.
add
(
id
, p)) {
81
delete
p;
82
return
false
;
83
}
84
return
true
;
85
}
86
87
88
bool
89
ShapeContainer::removePolygon
(
const
std::string&
id
) {
90
return
myPolygons
.
remove
(
id
);
91
}
92
93
94
bool
95
ShapeContainer::removePOI
(
const
std::string&
id
) {
96
return
myPOIs
.
remove
(
id
);
97
}
98
99
100
101
void
102
ShapeContainer::movePOI
(
const
std::string&
id
,
const
Position
& pos) {
103
PointOfInterest
* p =
myPOIs
.
get
(
id
);
104
if
(p != 0) {
105
static_cast<
Position
*
>
(p)->
set
(pos);
106
}
107
}
108
109
110
void
111
ShapeContainer::reshapePolygon
(
const
std::string&
id
,
const
PositionVector
& shape) {
112
Polygon
* p =
myPolygons
.
get
(
id
);
113
if
(p != 0) {
114
p->
setShape
(shape);
115
}
116
}
117
118
/****************************************************************************/
119
tmp
buildd
sumo-0.21.0+dfsg
src
utils
shapes
ShapeContainer.cpp
Generated on Thu Nov 20 2014 19:49:59 for SUMO - Simulation of Urban MObility by
1.8.1.2