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 
00057 namespace openfluid {
00058 namespace core {
00059 class Value;
00060 
00061 }
00062 namespace landr {
00063 
00064 class PolygonEntity;
00065 
00066 /**
00067  * @brief A part of a PolygonEntity exterior ring, that may be share between to adjacent PolygonEntity.
00068  * @details A PolygonEdge  has one or two Faces. The Faces are the PolygonEntity that share this PolygonEdge.
00069  */
00070 class DLLEXPORT PolygonEdge: public geos::planargraph::Edge
00071 {
00072   private:
00073 
00074     /**
00075      * @brief The geos::geom::LineString associated to this PolygonEdge.
00076      */
00077     geos::geom::LineString& m_Line;
00078 
00079     /**
00080      * @brief A vector of the PolygonEntity associated to this PolygonEdge.
00081      * @details At most two elements vector.
00082      */
00083     std::vector<PolygonEntity*> m_Faces;
00084 
00085 
00086   public:
00087 
00088     PolygonEdge(geos::geom::LineString& Line);
00089 
00090     ~PolygonEdge();
00091 
00092     /**
00093      * @brief Map of Attributes which are carried by this PolygonEdge.
00094      */
00095     std::map<std::string, core::Value*> m_EdgeAttributes;
00096 
00097 
00098     /**
00099      * @brief Returns the geos::geom::LineString representing this PolygonEdge.
00100      */
00101     geos::geom::LineString* getLine();
00102 
00103     /**
00104      * @brief Add a PolygonEntity as a Face to this PolygonEdge.
00105      * @param NewFace A PolygonEntity.
00106      * @throw base::OFException if this PolygonEdge is not in the boundary of the input PolygonEntity,
00107      * or if this PolygonEdge has already two Faces.
00108      */
00109     void addFace(PolygonEntity& NewFace);
00110 
00111     /**
00112      * @brief Returns true if this PolygonEdge is in the boundary of the input PolygonEntity.
00113      * @param Face A PolygonEntity.
00114      * @return True if this PolygonEdge is in the boundary of the input PolygonEntity, false otherwise.
00115      */
00116     bool isLineInFace(PolygonEntity& Face);
00117 
00118     /**
00119      * @brief Returns a vector of PolygonEntity which represent the Faces of this PolygonEdge.
00120      */
00121     const std::vector<PolygonEntity*> getFaces();
00122 
00123     /**
00124      * @brief Removes a Face from the Faces of this PolygonEdge.
00125      * @details Does nothing if the input Face is not a part of this PolygonEdge Faces.
00126      * @param Face A PolygonEntity.
00127      */
00128     void removeFace(PolygonEntity* Face);
00129 
00130     /**
00131      * @brief Gets the value of an attribute of this PolygonEdge.
00132      *
00133      * @param AttributeName The name of the attribute to get.
00134      * @param Value The core::Value to assign the attribute value.
00135      * @return True if the attribute exists, false otherwise.
00136      */
00137     bool getAttributeValue(const std::string& AttributeName, core::Value& Value) const;
00138 
00139     /**
00140      * @brief Sets the value of an attribute of this PolygonEdge.
00141      * @details Takes the ownership of Value.
00142      *
00143      * @param AttributeName The name of the attribute to set.
00144      * @param Value The core::Value assign to the attribute value.
00145      * @return True if the attribute exists, false otherwise.
00146      */
00147     bool setAttributeValue(const std::string& AttributeName, const core::Value* Value);
00148 
00149     /**
00150      * @brief Removes an attribute of this PolygonEdge.
00151      *
00152      * @param AttributeName The name of the attribute to set.
00153      */
00154     void removeAttribute(const std::string& AttributeName);
00155 
00156     /**
00157      * @brief Returns true if this PolygonEdge is coincident with an other PolygonEdge.
00158      *
00159      * @param Edge The PolygonEdge to test the coincidence.
00160      * @return True if the two PolygonEdge are coincidents, false otherwise.
00161      */
00162     bool isCoincident(PolygonEdge *Edge);
00163 
00164 };
00165 
00166 } // namespace landr
00167 } /* namespace openfluid */
00168 #endif /* POLYGONEDGE_HPP_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines