Skip to content
Snippets Groups Projects
Commit 73fa878f authored by Emmanuel Christophe's avatar Emmanuel Christophe
Browse files

ENH: Interface change for otb::Polygon (GetSurface -> GetArea)

parent e868a451
No related branches found
No related tags found
No related merge requests found
......@@ -61,7 +61,7 @@ public:
inline bool operator()(const TInput1 & input)
{
double circularityRatio = 4*M_PI*input->GetSurface()
double circularityRatio = 4*M_PI*input->GetArea()
/ M_SQUARE(input->GetLength());
if (circularityRatio > m_Threshold)
......
......@@ -126,7 +126,7 @@ public:
* Return the polygon surface.
* \return The surface.
*/
double GetSurface() const;
double GetArea() const;
/**
* Return the polygon length (perimeter).
......@@ -142,8 +142,8 @@ protected:
Polygon()
{
m_Epsilon = 0.000001;
m_Surface = -1.0;
surfaceValid = false;
m_Area = -1.0;
m_AreaIsValid = false;
};
/** Destructor */
......@@ -152,15 +152,15 @@ protected:
/**PrintSelf method */
virtual void PrintSelf(std::ostream& os, itk::Indent indent) const;
virtual void ComputeSurface() const;
virtual void ComputeArea() const;
private:
Polygon(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
double m_Epsilon;
mutable double m_Surface;
mutable bool surfaceValid;
mutable double m_Area;
mutable bool m_AreaIsValid;
};
}// End namespace otb
......
......@@ -29,7 +29,7 @@ Polygon<TValue>
::AddVertex(const ContinuousIndexType &vertex)
{
Superclass::AddVertex(vertex);
surfaceValid=false;
m_AreaIsValid=false;
}
/**
......@@ -485,12 +485,12 @@ Polygon<TValue>
/**
* Surface computation (for non convex polygons as well)
* Area computation (for non convex polygons as well)
*/
template<class TValue>
void
Polygon<TValue>
::ComputeSurface() const
::ComputeArea() const
{
VertexListConstIteratorType it = this->GetVertexList()->Begin();
......@@ -511,19 +511,19 @@ Polygon<TValue>
double vector2x = pt2[0] - origin[0];
double vector2y = pt2[1] - origin[1];
double crossProdduct = vector1x*vector2y - vector2x*vector1y;
m_Surface += crossProdduct;
m_Area += crossProdduct;
it++;
}
m_Surface = fabs(m_Surface/2.0);
m_Area = fabs(m_Area/2.0);
}
else //if there is strictly less than 3 points, surface is 0
{
m_Surface = 0.0;
m_Area = 0.0;
}
surfaceValid = true;
m_AreaIsValid = true;
}
/**
......@@ -532,13 +532,13 @@ Polygon<TValue>
template<class TValue>
double
Polygon<TValue>
::GetSurface() const
::GetArea() const
{
if (!surfaceValid)
if (!m_AreaIsValid)
{
ComputeSurface();
ComputeArea();
}
return m_Surface;
return m_Area;
}
......
......@@ -132,8 +132,8 @@ int otbPolygon(int argc, char * argv[])
file<<std::endl<<std::endl;
file<<"Surface computation : "<<std::endl;
file<<"Surface 1 :" << (double) polygon1->GetSurface() << std::endl;
file<<"Surface 2 :" << polygon2->GetSurface() << std::endl;
file<<"Surface 1 :" << (double) polygon1->GetArea() << std::endl;
file<<"Surface 2 :" << polygon2->GetArea() << std::endl;
file<<std::endl<<std::endl;
file<<"Length computation : "<<std::endl;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment