From 453f9d72ee266873f9fa33a9729980747f096d40 Mon Sep 17 00:00:00 2001 From: Emmanuel Christophe <emmanuel.christophe@orfeo-toolbox.org> Date: Tue, 13 Jan 2009 17:00:11 +0800 Subject: [PATCH] ENH: adding const to relevant methods --- .../otbPolyLineParametricPathWithValue.h | 6 +++--- .../otbPolyLineParametricPathWithValue.txx | 2 +- Code/Common/otbPolygon.h | 18 +++++++++--------- Code/Common/otbPolygon.txx | 17 +++++++++-------- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/Code/Common/otbPolyLineParametricPathWithValue.h b/Code/Common/otbPolyLineParametricPathWithValue.h index 182c642301..f507305f97 100644 --- a/Code/Common/otbPolyLineParametricPathWithValue.h +++ b/Code/Common/otbPolyLineParametricPathWithValue.h @@ -65,10 +65,10 @@ class ITK_EXPORT PolyLineParametricPathWithValue itk::EncapsulateMetaData<ValueType>(dict,m_Key,value); } - ValueType GetValue(void) + ValueType GetValue(void) const { ValueType resp = itk::NumericTraits<ValueType>::Zero; - itk::MetaDataDictionary & dict = this->GetMetaDataDictionary(); + const itk::MetaDataDictionary & dict = this->GetMetaDataDictionary(); if(dict.HasKey(m_Key)) { itk::ExposeMetaData<ValueType>(dict,m_Key,resp); @@ -84,7 +84,7 @@ class ITK_EXPORT PolyLineParametricPathWithValue * Return the path length (perimeter). * \return The length. */ - virtual double GetLength(); + virtual double GetLength() const; protected: /** Constructor */ diff --git a/Code/Common/otbPolyLineParametricPathWithValue.txx b/Code/Common/otbPolyLineParametricPathWithValue.txx index d2c397e3fa..f63b986add 100644 --- a/Code/Common/otbPolyLineParametricPathWithValue.txx +++ b/Code/Common/otbPolyLineParametricPathWithValue.txx @@ -36,7 +36,7 @@ namespace otb template < class TValue,unsigned int VDimension> double PolyLineParametricPathWithValue<TValue,VDimension> - ::GetLength() + ::GetLength() const { double length = 0.0; VertexListConstIteratorType it = this->GetVertexList()->Begin(); diff --git a/Code/Common/otbPolygon.h b/Code/Common/otbPolygon.h index f6af07a656..6429f47d05 100644 --- a/Code/Common/otbPolygon.h +++ b/Code/Common/otbPolygon.h @@ -71,14 +71,14 @@ class ITK_EXPORT Polygon * \param point The point to check. * \return True if the point is inside the polygon. */ - bool IsInside(VertexType point); + bool IsInside(VertexType point) const; /** * Check wether point is strictly on the edge of the polygon. * \param point The point to check. * \return True if the point is on the edge of the polygon. */ - bool IsOnEdge(VertexType point); + bool IsOnEdge(VertexType point) const; /** * Returns the number of crossings of the polygon with a given segment. @@ -86,7 +86,7 @@ class ITK_EXPORT Polygon * \param b Second point of the segment, * \return the number of strict crossings of segment [ab] with the polygon. */ - unsigned int NbCrossing(VertexType a, VertexType b); + unsigned int NbCrossing(VertexType a, VertexType b) const; /** * Returns the number of touchings without crossing of the polygon with a given segment. @@ -94,7 +94,7 @@ class ITK_EXPORT Polygon * \param b Second point of the segment, * \return the number of touchings without crossing of segment [ab] with the polygon. */ - unsigned int NbTouching(VertexType a, VertexType b); + unsigned int NbTouching(VertexType a, VertexType b) const; /** * Check wether two segments [a1a2] and [b1b2] are strictly crossing. @@ -104,7 +104,7 @@ class ITK_EXPORT Polygon * \param a1 Second point of the second segment. * \return True if the two segments are strictly crossing. */ - bool IsCrossing(VertexType a1, VertexType a2, VertexType b1, VertexType b2); + bool IsCrossing(VertexType a1, VertexType a2, VertexType b1, VertexType b2) const; /** * Check wether two segments[a1a2] and [b1b2] are touching without crossing. @@ -114,7 +114,7 @@ class ITK_EXPORT Polygon * \param a1 Second point of the second segment. * \return True if the two segments are touching without crossing. */ - bool IsTouching(VertexType a1, VertexType a2, VertexType b1, VertexType b2); + bool IsTouching(VertexType a1, VertexType a2, VertexType b1, VertexType b2) const; /** * Compute the polygon bounding region. @@ -126,13 +126,13 @@ class ITK_EXPORT Polygon * Return the polygon surface. * \return The surface. */ - double GetSurface(); + double GetSurface() const; /** * Return the polygon length (perimeter). * \return The length. */ - virtual double GetLength(); + virtual double GetLength() const; protected: /** Constructor */ @@ -153,7 +153,7 @@ private: void operator=(const Self&); //purposely not implemented double m_Epsilon; - double m_Surface; + }; }// End namespace otb diff --git a/Code/Common/otbPolygon.txx b/Code/Common/otbPolygon.txx index c5e620a733..0b9c548b66 100644 --- a/Code/Common/otbPolygon.txx +++ b/Code/Common/otbPolygon.txx @@ -31,7 +31,7 @@ namespace otb template<class TValue> bool Polygon<TValue> -::IsInside(VertexType point) +::IsInside(VertexType point) const { double x = point[0]; double y = point[1]; @@ -110,7 +110,7 @@ Polygon<TValue> template<class TValue> bool Polygon<TValue> -::IsOnEdge(VertexType point) +::IsOnEdge(VertexType point) const { //std::cout<<"Checking point "<<point<<std::endl; bool resp = false; @@ -198,7 +198,7 @@ Polygon<TValue> template<class TValue> unsigned int Polygon<TValue> -::NbCrossing(VertexType a, VertexType b) +::NbCrossing(VertexType a, VertexType b) const { unsigned int resp = 0; VertexListConstIteratorType it = this->GetVertexList()->Begin(); @@ -232,7 +232,7 @@ Polygon<TValue> template<class TValue> unsigned int Polygon<TValue> -::NbTouching(VertexType a, VertexType b) +::NbTouching(VertexType a, VertexType b) const { unsigned int resp = 0; VertexListConstIteratorType it = this->GetVertexList()->Begin(); @@ -268,7 +268,7 @@ Polygon<TValue> template<class TValue> bool Polygon<TValue> -::IsCrossing(VertexType a1, VertexType a2, VertexType b1, VertexType b2) +::IsCrossing(VertexType a1, VertexType a2, VertexType b1, VertexType b2) const { bool resp = false; double xbmin = std::min(b1[0],b2[0]); @@ -325,7 +325,7 @@ Polygon<TValue> template<class TValue> bool Polygon<TValue> -::IsTouching(VertexType a1, VertexType a2, VertexType b1, VertexType b2) +::IsTouching(VertexType a1, VertexType a2, VertexType b1, VertexType b2) const { bool resp = false; double xbmin = std::min(b1[0],b2[0]); @@ -480,8 +480,9 @@ Polygon<TValue> template<class TValue> double Polygon<TValue> - ::GetSurface() + ::GetSurface() const { + double m_Surface; m_Surface = 0.0; VertexListConstIteratorType it = this->GetVertexList()->Begin(); @@ -522,7 +523,7 @@ template<class TValue> */ template < class TValue> double Polygon<TValue> - ::GetLength() + ::GetLength() const { double length = 0.0; VertexListConstIteratorType it = this->GetVertexList()->Begin(); -- GitLab