21 #ifndef otbPathMeanDistanceFunctor_h
22 #define otbPathMeanDistanceFunctor_h
42 template <
class TInput1>
66 double meanDistance = 0.0;
67 typedef typename TInput1::ObjectType::VertexListType::ConstIterator VertexListConstIteratorType;
68 typedef typename TInput1::ObjectType::VertexType VertexType;
69 VertexListConstIteratorType beginIt = input->GetVertexList()->Begin();
71 VertexType v1 = beginIt.Value();
72 VertexType v2 = beginIt.Value();
74 while (beginIt != input->GetVertexList()->End())
78 meanDistance += std::sqrt(std::pow(v1[0] - v2[0], 2) + std::pow(v1[1] - v2[1], 2));
82 double nbVertices =
static_cast<double>(input->GetVertexList()->Size());
85 meanDistance = meanDistance / (nbVertices - 1);
89 itkGenericExceptionMacro(<<
"Object with only one vertex!");