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
/****************************************************************************/
9
// Storage for geometrical objects, sorted by the layers they are in
10
/****************************************************************************/
11
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12
// Copyright (C) 2001-2013 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
#include <fstream>
34
#include <stdlib.h>
35
#include <iostream>
36
#include <utility>
37
#include <string>
38
#include <cmath>
39
#include <
utils/common/NamedObjectCont.h
>
40
#include <
utils/shapes/PointOfInterest.h
>
41
#include <
utils/shapes/Polygon.h
>
42
#include <
utils/shapes/ShapeContainer.h
>
43
#include <
utils/common/MsgHandler.h
>
44
#include <
utils/common/UtilExceptions.h
>
45
#include <
utils/common/ToString.h
>
46
#include <
utils/common/StdDefs.h
>
47
48
#ifdef CHECK_MEMORY_LEAKS
49
#include <
foreign/nvwa/debug_new.h
>
50
#endif // CHECK_MEMORY_LEAKS
51
52
53
// ===========================================================================
54
// method definitions
55
// ===========================================================================
56
ShapeContainer::ShapeContainer
() {}
57
58
ShapeContainer::~ShapeContainer
() {}
59
60
bool
61
ShapeContainer::addPolygon
(
const
std::string&
id
,
const
std::string& type,
62
const
RGBColor
& color,
SUMOReal
layer,
63
SUMOReal
angle,
const
std::string& imgFile,
64
const
PositionVector
& shape,
bool
fill) {
65
Polygon
* p =
new
Polygon
(
id
, type, color, shape, fill, layer, angle, imgFile);
66
if
(!
myPolygons
.
add
(
id
, p)) {
67
delete
p;
68
return
false
;
69
}
70
return
true
;
71
}
72
73
74
bool
75
ShapeContainer::addPOI
(
const
std::string&
id
,
const
std::string& type,
76
const
RGBColor
& color,
SUMOReal
layer,
SUMOReal
angle,
const
std::string& imgFile,
77
const
Position
& pos,
SUMOReal
width,
SUMOReal
height) {
78
PointOfInterest
* p =
new
PointOfInterest
(
id
, type, color, pos, layer, angle, imgFile, width, height);
79
if
(!
myPOIs
.
add
(
id
, p)) {
80
delete
p;
81
return
false
;
82
}
83
return
true
;
84
}
85
86
87
bool
88
ShapeContainer::removePolygon
(
const
std::string&
id
) {
89
return
myPolygons
.
remove
(
id
);
90
}
91
92
93
bool
94
ShapeContainer::removePOI
(
const
std::string&
id
) {
95
return
myPOIs
.
remove
(
id
);
96
}
97
98
99
100
void
101
ShapeContainer::movePOI
(
const
std::string&
id
,
const
Position
& pos) {
102
PointOfInterest
* p =
myPOIs
.
get
(
id
);
103
if
(p != 0) {
104
static_cast<
Position
*
>
(p)->set(pos);
105
}
106
}
107
108
109
void
110
ShapeContainer::reshapePolygon
(
const
std::string&
id
,
const
PositionVector
& shape) {
111
Polygon
* p =
myPolygons
.
get
(
id
);
112
if
(p != 0) {
113
p->
setShape
(shape);
114
}
115
}
116
117
/****************************************************************************/
118
build
buildd
sumo-0.18~dfsg
src
utils
shapes
ShapeContainer.cpp
Generated on Wed Oct 23 2013 01:15:12 for SUMO - Simulation of Urban MObility by
1.8.4