SUMO - Simulation of Urban MObility
Polygon.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // A 2D- or 3D-polygon
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2004-2017 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 #ifndef Polygon_h
24 #define Polygon_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
38 #include "Shape.h"
39 
40 
41 // ===========================================================================
42 // class declarations
43 // ===========================================================================
44 class OutputDevice;
45 
46 
47 // we need to put this into a namespace to avoid clashing with wingdi.h::Polygon function
48 namespace SUMO {
49 
50 // ===========================================================================
51 // class definitions
52 // ===========================================================================
57 class Polygon : public Shape, public Parameterised {
58 public:
69  Polygon(const std::string& id, const std::string& type,
70  const RGBColor& color, const PositionVector& shape, bool fill,
71  double layer = DEFAULT_LAYER,
72  double angle = DEFAULT_ANGLE,
73  const std::string& imgFile = DEFAULT_IMG_FILE);
74 
75 
77  virtual ~Polygon();
78 
79 
80 
83 
87  inline const PositionVector& getShape() const {
88  return myShape;
89  }
90 
91 
95  inline bool getFill() const {
96  return myFill;
97  }
99 
100 
101 
104 
108  inline void setFill(bool fill) {
109  myFill = fill;
110  }
111 
112 
116  inline virtual void setShape(const PositionVector& shape) {
117  myShape = shape;
118  }
120 
121  /* @brief polygon definition to the given device
122  * @param[in] geo Whether to write the output in geo-coordinates
123  */
124  void writeXML(OutputDevice& out, bool geo = false);
125 
126 protected:
129 
131  bool myFill;
132 
133 };
134 
135 }
136 
137 #endif
138 
139 /****************************************************************************/
140 
static const std::string DEFAULT_IMG_FILE
Definition: Shape.h:152
bool getFill() const
Returns whether the polygon is filled.
Definition: Polygon.h:95
void writeXML(OutputDevice &out, bool geo=false)
Definition: Polygon.cpp:56
virtual void setShape(const PositionVector &shape)
Sets the shape of the polygon.
Definition: Polygon.h:116
const PositionVector & getShape() const
Returns whether the shape of the polygon.
Definition: Polygon.h:87
A 2D- or 3D-polygon.
Definition: Polygon.h:57
Polygon(const std::string &id, const std::string &type, const RGBColor &color, const PositionVector &shape, bool fill, double layer=DEFAULT_LAYER, double angle=DEFAULT_ANGLE, const std::string &imgFile=DEFAULT_IMG_FILE)
Constructor.
Definition: Polygon.cpp:43
A list of positions.
A 2D- or 3D-Shape.
Definition: Shape.h:46
An upper class for objects with additional parameters.
Definition: Parameterised.h:51
bool myFill
Information whether the polygon has to be filled.
Definition: Polygon.h:131
Definition: Polygon.h:48
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
void setFill(bool fill)
Sets whether the polygon shall be filled.
Definition: Polygon.h:108
PositionVector myShape
The positions of the polygon.
Definition: Polygon.h:128
static const double DEFAULT_ANGLE
Definition: Shape.h:151
virtual ~Polygon()
Destructor.
Definition: Polygon.cpp:52
static const double DEFAULT_LAYER
Definition: Shape.h:150