Line data Source code
1 : /****************************************************************************/ 2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo 3 : // Copyright (C) 2004-2024 German Aerospace Center (DLR) and others. 4 : // This program and the accompanying materials are made available under the 5 : // terms of the Eclipse Public License 2.0 which is available at 6 : // https://www.eclipse.org/legal/epl-2.0/ 7 : // This Source Code may also be made available under the following Secondary 8 : // Licenses when the conditions for such availability set forth in the Eclipse 9 : // Public License 2.0 are satisfied: GNU General Public License, version 2 10 : // or later which is available at 11 : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html 12 : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later 13 : /****************************************************************************/ 14 : /// @file SUMOPolygon.h 15 : /// @author Daniel Krajzewicz 16 : /// @author Michael Behrisch 17 : /// @author Jakob Erdmann 18 : /// @author Melanie Knocke 19 : /// @date Jun 2004 20 : /// 21 : // A 2D- or 3D-polygon 22 : /****************************************************************************/ 23 : #pragma once 24 : #include <config.h> 25 : 26 : #include <utils/geom/PositionVector.h> 27 : #include <utils/common/Parameterised.h> 28 : #include "Shape.h" 29 : 30 : 31 : // =========================================================================== 32 : // class declarations 33 : // =========================================================================== 34 : class OutputDevice; 35 : 36 : 37 : // =========================================================================== 38 : // class definitions 39 : // =========================================================================== 40 : /** 41 : * @class Polygon 42 : * @brief A 2D- or 3D-polygon 43 : */ 44 : class SUMOPolygon : public Shape, public Parameterised { 45 : 46 : public: 47 : /// @brief friend class 48 : friend class PolygonDynamics; 49 : 50 : /** @brief Constructor 51 : * @param[in] id The name of the polygon 52 : * @param[in] type The (abstract) type of the polygon 53 : * @param[in] color The color of the polygon 54 : * @param[in] layer The layer of the polygon 55 : * @param[in] angle The rotation of the polygon 56 : * @param[in] imgFile The raster image of the polygon 57 : * @param[in] shape The shape of the polygon 58 : * @param[in] geo specify if shape was loaded as GEO 59 : * @param[in] fill Whether the polygon shall be filled 60 : * @param[in] lineWidth The line with for drawing an unfilled polygon 61 : * @param[in] relativePath set image file as relative path 62 : * @param[in] name Polygon name 63 : * @param[in] parameters generic parameters 64 : */ 65 : SUMOPolygon(const std::string& id, const std::string& type, const RGBColor& color, 66 : const PositionVector& shape, bool geo, bool fill, double lineWidth, 67 : double layer = DEFAULT_LAYER, 68 : double angle = DEFAULT_ANGLE, 69 : const std::string& imgFile = DEFAULT_IMG_FILE, 70 : bool relativePath = DEFAULT_RELATIVEPATH, 71 : const std::string& name = DEFAULT_NAME, 72 : const Parameterised::Map& parameters = DEFAULT_PARAMETERS); 73 : 74 : /// @brief Destructor 75 : ~SUMOPolygon(); 76 : 77 : /// @name Getter 78 : /// @{ 79 : 80 : /** @brief Returns the shape of the polygon 81 : * @return The shape of the polygon 82 : */ 83 : const PositionVector& getShape() const; 84 : 85 : /** @brief Returns the holers of the polygon 86 : * @return The holes of the polygon 87 : */ 88 : const std::vector<PositionVector>& getHoles() const; 89 : 90 : /** @brief Returns whether the polygon is filled 91 : * @return Whether the polygon is filled 92 : */ 93 : bool getFill() const; 94 : 95 : /** @brief Returns whether the polygon is filled 96 : * @return Whether the polygon is filled 97 : */ 98 : double getLineWidth() const; 99 : /// @} 100 : 101 : /// @name Setter 102 : /// @{ 103 : 104 : /** @brief Sets whether the polygon shall be filled 105 : * @param[in] fill Whether the polygon shall be filled 106 : */ 107 : void setFill(bool fill); 108 : 109 : /// @brief set line width 110 : void setLineWidth(double lineWidth); 111 : 112 : /** @brief Sets the shape of the polygon 113 : * @param[in] shape The new shape of the polygon 114 : */ 115 : virtual void setShape(const PositionVector& shape); 116 : 117 : /** @brief Sets the holes of the polygon 118 : * @param[in] holes The new holes of the polygon 119 : */ 120 : virtual void setHoles(const std::vector<PositionVector>& holes); 121 : 122 : /// @} 123 : 124 : /* @brief polygon definition to the given device 125 : * @param[in] geo Whether to write the output in geo-coordinates 126 : */ 127 : void writeXML(OutputDevice& out, bool geo = false) const; 128 : 129 : /// @brief Return the exterior shape of the polygon. 130 : PositionVector& getShapeRef() { 131 82108 : return myShape; 132 : } 133 : 134 : protected: 135 : /// @brief The positions of the polygon 136 : PositionVector myShape; 137 : 138 : /// @brief The collection of the holes of the polygon, each given by a sequence of coodinates. 139 : std::vector<PositionVector> myHoles; 140 : 141 : /// @brief specify if shape is handled as GEO coordinate (Main used in netedit) 142 : bool myGEO; 143 : 144 : /// @brief Information whether the polygon has to be filled 145 : bool myFill; 146 : 147 : /// @brief The line width for drawing an unfilled polygon 148 : double myLineWidth; 149 : };