21 #ifndef otbSimplifyPathFunctor_h 22 #define otbSimplifyPathFunctor_h 53 template <
class TInput,
class TOutput>
79 inline OutputPathPointerType
operator()(
const TInput* input)
82 OutputPathPointerType newPath = OutputPathType::New();
83 newPath->Initialize();
85 VertexListConstPointerType vertexList = input->GetVertexList();
86 if (vertexList->Size() > 0)
88 VertexListConstIteratorType beginIt = vertexList->Begin();
89 VertexListConstIteratorType beforeTheEndIt = --(vertexList->End());
92 newPath->AddVertex(beginIt.Value());
94 while (beginIt != beforeTheEndIt)
96 VertexListConstIteratorType endIt = beforeTheEndIt;
103 newPath->AddVertex(endIt.Value());
108 newPath->SetMetaDataDictionary(input->GetMetaDataDictionary());
117 VertexListConstIteratorType segmentIt = begin;
120 while (segmentIt != end)
122 double crossProduct = (end.Value()[0] - begin.Value()[0]) * (segmentIt.Value()[1] - begin.Value()[1]) -
123 (end.Value()[1] - begin.Value()[1]) * (segmentIt.Value()[0] - begin.Value()[0]);
125 (end.Value()[0] - begin.Value()[0]) * (end.Value()[0] - begin.Value()[0]) + (end.Value()[1] - begin.Value()[1]) * (end.Value()[1] - begin.Value()[1]);
128 double distsq = crossProduct * crossProduct / lengthSeg;
129 if (distsq > static_cast<double>(m_Tolerance))
void SetTolerance(double Tolerance)
TInput::VertexListType::ConstPointer VertexListConstPointerType
OutputPathType::Pointer OutputPathPointerType
double GetTolerance(void) const
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
TInput::VertexListType::ConstIterator VertexListConstIteratorType
This filter performs a simplification of the input path.
OutputPathPointerType operator()(const TInput *input)
bool TestPathConsistency(VertexListConstIteratorType begin, VertexListConstIteratorType end) const