landr/PolygonEdge.hpp
Go to the documentation of this file.
00001 /*
00002 
00003   This file is part of OpenFLUID software
00004   Copyright(c) 2007, INRA - Montpellier SupAgro
00005 
00006 
00007  == GNU General Public License Usage ==
00008 
00009   OpenFLUID is free software: you can redistribute it and/or modify
00010   it under the terms of the GNU General Public License as published by
00011   the Free Software Foundation, either version 3 of the License, or
00012   (at your option) any later version.
00013 
00014   OpenFLUID is distributed in the hope that it will be useful,
00015   but WITHOUT ANY WARRANTY; without even the implied warranty of
00016   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017   GNU General Public License for more details.
00018 
00019   You should have received a copy of the GNU General Public License
00020   along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
00021 
00022 
00023  == Other Usage ==
00024 
00025   Other Usage means a use of OpenFLUID that is inconsistent with the GPL
00026   license, and requires a written agreement between You and INRA.
00027   Licensees for Other Usage of OpenFLUID may use this file in accordance
00028   with the terms contained in the written agreement between You and INRA.
00029   
00030 */
00031 
00032 /**
00033  \file PolygonEdge.hpp
00034  \brief Header of ...
00035 
00036  \author Aline LIBRES <aline.libres@gmail.com>
00037  */
00038 
00039 #ifndef POLYGONEDGE_HPP_
00040 #define POLYGONEDGE_HPP_
00041 
00042 #include <geos/planargraph/Edge.h>
00043 #include <openfluid/dllexport.hpp>
00044 
00045 #include <map>
00046 
00047 namespace geos {
00048 namespace geom {
00049 class LineString;
00050 class CoordinateSequence;
00051 }
00052 namespace planargraph {
00053 class Edge;
00054 } }
00055 
00056 namespace openfluid {
00057 namespace core {
00058 class Value;
00059 }
00060 
00061 namespace landr {
00062 
00063 class PolygonEntity;
00064 
00065 /**
00066  @brief A part of a PolygonEntity exterior ring, that may be share between to adjacent PolygonEntity.
00067  @details A PolygonEdge  has one or two Faces. The Faces are the PolygonEntity that share this PolygonEdge.
00068  */
00069 class DLLEXPORT PolygonEdge: public geos::planargraph::Edge
00070 {
00071   private:
00072 
00073     /**
00074      @brief The geos::geom::LineString associated to this PolygonEdge.
00075      */
00076     geos::geom::LineString& m_Line;
00077 
00078     /**
00079      @brief A vector of the PolygonEntity associated to this PolygonEdge.
00080      @details At most two elements vector.
00081      */
00082     std::vector<PolygonEntity*> m_Faces;
00083 
00084 
00085   public:
00086 
00087     PolygonEdge(geos::geom::LineString& Line);
00088 
00089     ~PolygonEdge();
00090 
00091     /**
00092      @brief Map of Attributes which are carried by this PolygonEdge.
00093      */
00094     std::map<std::string, core::Value*> m_EdgeAttributes;
00095 
00096 
00097     /**
00098      @brief Returns the geos::geom::LineString representing this PolygonEdge.
00099      */
00100     geos::geom::LineString* getLine();
00101 
00102     /**
00103      @brief Add a PolygonEntity as a Face to this PolygonEdge.
00104      @param NewFace A PolygonEntity.
00105      @throw base::OFException if this PolygonEdge is not in the boundary of the input PolygonEntity,
00106      or if this PolygonEdge has already two Faces.
00107      */
00108     void addFace(PolygonEntity& NewFace);
00109 
00110     /**
00111      @brief Returns true if this PolygonEdge is in the boundary of the input PolygonEntity.
00112      @param Face A PolygonEntity.
00113      @return True if this PolygonEdge is in the boundary of the input PolygonEntity, false otherwise.
00114      */
00115     bool isLineInFace(PolygonEntity& Face);
00116 
00117     /**
00118      @brief Returns a vector of PolygonEntity which represent the Faces of this PolygonEdge.
00119      */
00120     const std::vector<PolygonEntity*> getFaces();
00121 
00122     /**
00123      @brief Removes a Face from the Faces of this PolygonEdge.
00124      @details Does nothing if the input Face is not a part of this PolygonEdge Faces.
00125      @param Face A PolygonEntity.
00126      */
00127     void removeFace(PolygonEntity* Face);
00128 
00129     /**
00130      @brief Gets the value of an attribute of this PolygonEdge.
00131      @param AttributeName The name of the attribute to get.
00132      @param Value The core::Value to assign the attribute value.
00133      @return True if the attribute exists, false otherwise.
00134      */
00135     bool getAttributeValue(const std::string& AttributeName, core::Value& Value) const;
00136 
00137     /**
00138      @brief Sets the value of an attribute of this PolygonEdge.
00139      @details Takes the ownership of Value.
00140      @param AttributeName The name of the attribute to set.
00141      @param Value The core::Value assign to the attribute value.
00142      @return True if the attribute exists, false otherwise.
00143      */
00144     bool setAttributeValue(const std::string& AttributeName, const core::Value* Value);
00145 
00146     /**
00147      @brief Removes an attribute of this PolygonEdge.
00148      @param AttributeName The name of the attribute to set.
00149      */
00150     void removeAttribute(const std::string& AttributeName);
00151 
00152     /**
00153      @brief Returns true if this PolygonEdge is coincident with an other PolygonEdge.
00154      @param Edge The PolygonEdge to test the coincidence.
00155      @return True if the two PolygonEdge are coincidents, false otherwise.
00156      */
00157     bool isCoincident(PolygonEdge *Edge);
00158 
00159 };
00160 
00161 } } // namespace landr, openfluid
00162 #endif /* POLYGONEDGE_HPP_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines