All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PolygonEdge.hpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of OpenFLUID software
4  Copyright(c) 2007, INRA - Montpellier SupAgro
5 
6 
7  == GNU General Public License Usage ==
8 
9  OpenFLUID is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  OpenFLUID is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
21 
22 
23  == Other Usage ==
24 
25  Other Usage means a use of OpenFLUID that is inconsistent with the GPL
26  license, and requires a written agreement between You and INRA.
27  Licensees for Other Usage of OpenFLUID may use this file in accordance
28  with the terms contained in the written agreement between You and INRA.
29 
30 */
31 
32 /**
33  @file PolygonEdge.hpp
34 
35  @author Aline LIBRES <aline.libres@gmail.com>
36  @author Michael RABOTIN <michael.rabotin@supagro.inra.fr>
37  */
38 
39 #ifndef __OPENFLUID_LANDR_POLYGONEDGE_HPP__
40 #define __OPENFLUID_LANDR_POLYGONEDGE_HPP__
41 
42 #include <geos/planargraph/Edge.h>
43 #include <openfluid/dllexport.hpp>
44 
45 #include <map>
46 
47 namespace geos {
48 namespace geom {
49 class LineString;
50 class CoordinateSequence;
51 }
52 namespace planargraph {
53 class Edge;
54 } }
55 
56 namespace openfluid {
57 namespace core {
58 class Value;
59 }
60 
61 namespace landr {
62 
63 class PolygonEntity;
64 
65 /**
66  @brief A part of a PolygonEntity exterior ring, that may be share between to adjacent PolygonEntity.
67  @details A PolygonEdge has one or two Faces. The Faces are the PolygonEntity that share this PolygonEdge.
68 */
69 class OPENFLUID_API PolygonEdge: public geos::planargraph::Edge
70 {
71  private:
72 
73  /**
74  @brief The geos::geom::LineString associated to this PolygonEdge.
75  */
76  geos::geom::LineString& m_Line;
77 
78  /**
79  @brief A vector of the PolygonEntity associated to this PolygonEdge.
80  @details At most two elements vector.
81  */
82  std::vector<PolygonEntity*> m_Faces;
83 
84 
85  public:
86 
87  PolygonEdge(geos::geom::LineString& Line);
88 
89  ~PolygonEdge();
90 
91  /**
92  @brief Map of Attributes which are carried by this PolygonEdge.
93  */
94  std::map<std::string, core::Value*> m_EdgeAttributes;
95 
96  /**
97  @brief Returns the geos::geom::LineString representing this PolygonEdge.
98  */
99  geos::geom::LineString* line();
100 
101  /**
102  @brief Add a PolygonEntity as a Face to this PolygonEdge.
103  @param NewFace A PolygonEntity.
104  @throw base::FrameworkException if this PolygonEdge is not in the boundary of the input PolygonEntity,
105  or if this PolygonEdge has already two Faces.
106  */
107  void addFace(PolygonEntity& NewFace);
108 
109  /**
110  @brief Returns true if this PolygonEdge is in the boundary of the input PolygonEntity.
111  @param Face A PolygonEntity.
112  @return True if this PolygonEdge is in the boundary of the input PolygonEntity, false otherwise.
113  */
114  bool isLineInFace(PolygonEntity& Face);
115 
116  /**
117  @brief Returns a vector of PolygonEntity which represent the Faces of this PolygonEdge.
118  */
119  const std::vector<PolygonEntity*> getFaces();
120 
121  /**
122  @brief Removes a Face from the Faces of this PolygonEdge.
123  @details Does nothing if the input Face is not a part of this PolygonEdge Faces.
124  @param Face A PolygonEntity.
125  */
126  void removeFace(PolygonEntity* Face);
127 
128  /**
129  @brief Gets the value of an attribute of this PolygonEdge.
130  @param AttributeName The name of the attribute to get.
131  @param Value The core::Value to assign the attribute value.
132  @return True if the attribute exists, false otherwise.
133  */
134  bool getAttributeValue(const std::string& AttributeName, core::Value& Value) const;
135 
136  /**
137  @brief Sets the value of an attribute of this PolygonEdge.
138  @details Takes the ownership of Value.
139  @param AttributeName The name of the attribute to set.
140  @param Value The core::Value assign to the attribute value.
141  @return True if the attribute exists, false otherwise.
142  */
143  bool setAttributeValue(const std::string& AttributeName, const core::Value* Value);
144 
145  /**
146  @brief Removes an attribute of this PolygonEdge.
147  @param AttributeName The name of the attribute to set.
148  */
149  void removeAttribute(const std::string& AttributeName);
150 
151  /**
152  @brief Returns true if this PolygonEdge is coincident with an other PolygonEdge.
153  @param Edge The PolygonEdge to test the coincidence.
154  @return True if the two PolygonEdge are coincidents, false otherwise.
155  */
156  bool isCoincident(PolygonEdge *Edge);
157 
158 };
159 
160 } } // namespace landr, openfluid
161 #endif /* __OPENFLUID_LANDR_POLYGONEDGE_HPP__ */
A part of a PolygonEntity exterior ring, that may be share between to adjacent PolygonEntity.
Definition: PolygonEdge.hpp:69
Definition: Value.hpp:64
std::map< std::string, core::Value * > m_EdgeAttributes
Map of Attributes which are carried by this PolygonEdge.
Definition: PolygonEdge.hpp:94
A LandREntity representing a geos::geom::Polygon.
Definition: PolygonEntity.hpp:64
#define OPENFLUID_API
Definition: dllexport.hpp:87