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 
43 #include <map>
44 
45 #include <geos/planargraph/Edge.h>
46 
47 #include <openfluid/dllexport.hpp>
48 
49 
50 namespace geos {
51 namespace geom {
52 class LineString;
53 class CoordinateSequence;
54 }
55 namespace planargraph {
56 class Edge;
57 } }
58 
59 namespace openfluid {
60 namespace core {
61 class Value;
62 }
63 
64 
65 namespace landr {
66 
67 
68 class PolygonEntity;
69 
70 /**
71  @brief A part of a PolygonEntity exterior ring, that may be share between to adjacent PolygonEntity.
72  @details A PolygonEdge has one or two Faces. The Faces are the PolygonEntity that share this PolygonEdge.
73 */
74 class OPENFLUID_API PolygonEdge: public geos::planargraph::Edge
75 {
76  private:
77 
78  /**
79  @brief The geos::geom::LineString associated to this PolygonEdge.
80  */
81  geos::geom::LineString& m_Line;
82 
83  /**
84  @brief A vector of the PolygonEntity associated to this PolygonEdge.
85  @details At most two elements vector.
86  */
87  std::vector<PolygonEntity*> m_Faces;
88 
89 
90  public:
91 
92  PolygonEdge(geos::geom::LineString& Line);
93 
94  ~PolygonEdge();
95 
96  /**
97  @brief Map of Attributes which are carried by this PolygonEdge.
98  */
99  std::map<std::string, core::Value*> m_EdgeAttributes;
100 
101  /**
102  @brief Returns the geos::geom::LineString representing this PolygonEdge.
103  */
104  geos::geom::LineString* line();
105 
106  /**
107  @brief Add a PolygonEntity as a Face to this PolygonEdge.
108  @param NewFace A PolygonEntity.
109  @throw base::FrameworkException if this PolygonEdge is not in the boundary of the input PolygonEntity,
110  or if this PolygonEdge has already two Faces.
111  */
112  void addFace(PolygonEntity& NewFace);
113 
114  /**
115  @brief Returns true if this PolygonEdge is in the boundary of the input PolygonEntity.
116  @param Face A PolygonEntity.
117  @return True if this PolygonEdge is in the boundary of the input PolygonEntity, false otherwise.
118  */
119  bool isLineInFace(PolygonEntity& Face);
120 
121  /**
122  @brief Returns a vector of PolygonEntity which represent the Faces of this PolygonEdge.
123  */
124  const std::vector<PolygonEntity*> getFaces();
125 
126  /**
127  @brief Removes a Face from the Faces of this PolygonEdge.
128  @details Does nothing if the input Face is not a part of this PolygonEdge Faces.
129  @param Face A PolygonEntity.
130  */
131  void removeFace(PolygonEntity* Face);
132 
133  /**
134  @brief Gets the value of an attribute of this PolygonEdge.
135  @param AttributeName The name of the attribute to get.
136  @param Value The core::Value to assign the attribute value.
137  @return True if the attribute exists, false otherwise.
138  */
139  bool getAttributeValue(const std::string& AttributeName, core::Value& Value) const;
140 
141  /**
142  @brief Sets the value of an attribute of this PolygonEdge.
143  @details Takes the ownership of Value.
144  @param AttributeName The name of the attribute to set.
145  @param Value The core::Value assign to the attribute value.
146  @return True if the attribute exists, false otherwise.
147  */
148  bool setAttributeValue(const std::string& AttributeName, const core::Value* Value);
149 
150  /**
151  @brief Removes an attribute of this PolygonEdge.
152  @param AttributeName The name of the attribute to set.
153  */
154  void removeAttribute(const std::string& AttributeName);
155 
156  /**
157  @brief Returns true if this PolygonEdge is coincident with an other PolygonEdge.
158  @param Edge The PolygonEdge to test the coincidence.
159  @return True if the two PolygonEdge are coincidents, false otherwise.
160  */
161  bool isCoincident(PolygonEdge *Edge);
162 
163 };
164 
165 
166 } } // namespaces
167 
168 
169 #endif /* __OPENFLUID_LANDR_POLYGONEDGE_HPP__ */
Definition: Value.hpp:64
Definition: LandRGraph.hpp:60
Definition: LandREntity.hpp:53
A LandREntity representing a geos::geom::Polygon.
Definition: PolygonEntity.hpp:67
Definition: ApplicationException.hpp:47
std::map< std::string, core::Value * > m_EdgeAttributes
Map of Attributes which are carried by this PolygonEdge.
Definition: PolygonEdge.hpp:99
#define OPENFLUID_API
Definition: dllexport.hpp:87
A part of a PolygonEntity exterior ring, that may be share between to adjacent PolygonEntity.
Definition: PolygonEdge.hpp:74