OTB  9.0.0
Orfeo Toolbox
otbClosePathFunctor.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbClosePathFunctor_h
22 #define otbClosePathFunctor_h
23 
24 #include "otbMath.h"
25 
26 namespace otb
27 {
28 
40 template <class TInput, class TOutput>
42 {
43 public:
44  typedef typename TInput::VertexListType::ConstIterator VertexListConstIteratorType;
45  typedef typename TInput::VertexListType::ConstPointer VertexListConstPointerType;
46  typedef TOutput OutputPathType;
47  typedef typename OutputPathType::Pointer OutputPathPointerType;
48 
50  {
51  }
53  {
54  }
55 
56  inline OutputPathPointerType operator()(const TInput* input)
57  {
58  OutputPathPointerType newPath = OutputPathType::New();
59  newPath->Initialize();
60  typename TInput::VertexType lastVertex;
61 
62  if (input->GetVertexList()->Size() > 0)
63  {
64  // Initialization of lastVertex to GetVertexList
65  lastVertex = input->GetVertexList()->Begin().Value();
66 
67  for (VertexListConstIteratorType vertexIt = input->GetVertexList()->Begin(); vertexIt != input->GetVertexList()->End(); ++vertexIt)
68  {
69  newPath->AddVertex(vertexIt.Value());
70  lastVertex = vertexIt.Value();
71  }
72  if (lastVertex != input->GetVertexList()->Begin().Value())
73  {
74  newPath->AddVertex(input->GetVertexList()->Begin().Value());
75  }
76  }
77 
78  newPath->SetMetaDataDictionary(input->GetMetaDataDictionary());
79  return newPath;
80  }
81 };
82 }
83 
84 #endif
otbMath.h
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::ClosePathFunctor::OutputPathPointerType
OutputPathType::Pointer OutputPathPointerType
Definition: otbClosePathFunctor.h:47
otb::ClosePathFunctor::ClosePathFunctor
ClosePathFunctor()
Definition: otbClosePathFunctor.h:49
otb::ClosePathFunctor::operator()
OutputPathPointerType operator()(const TInput *input)
Definition: otbClosePathFunctor.h:56
otb::ClosePathFunctor::VertexListConstPointerType
TInput::VertexListType::ConstPointer VertexListConstPointerType
Definition: otbClosePathFunctor.h:45
otb::ClosePathFunctor
This filter close the input path, making the last point equal to the first one.
Definition: otbClosePathFunctor.h:41
otb::ClosePathFunctor::~ClosePathFunctor
virtual ~ClosePathFunctor()
Definition: otbClosePathFunctor.h:52
otb::ClosePathFunctor::OutputPathType
TOutput OutputPathType
Definition: otbClosePathFunctor.h:46
otb::ClosePathFunctor::VertexListConstIteratorType
TInput::VertexListType::ConstIterator VertexListConstIteratorType
Definition: otbClosePathFunctor.h:44