OTB  10.0.0
Orfeo Toolbox
otbLabelMapToVectorDataFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2024 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 otbLabelMapToVectorDataFilter_h
22 #define otbLabelMapToVectorDataFilter_h
23 
24 #include "otbVectorDataSource.h"
25 #include "itkLabelMap.h"
29 #include "otbDataNode.h"
30 
31 #include <string>
32 #include <sstream>
33 
34 namespace otb
35 {
36 
57 template <class TLabelMap, class TVectorData, class TFieldsFunctor = Functor::LabelObjectFieldsFunctor<typename TLabelMap::LabelObjectType>>
58 class ITK_EXPORT LabelMapToVectorDataFilter : public VectorDataSource<TVectorData>
59 {
60 public:
64  typedef itk::SmartPointer<Self> Pointer;
65  typedef itk::SmartPointer<const Self> ConstPointer;
66 
68  typedef TLabelMap InputLabelMapType;
69  typedef TVectorData OutputVectorDataType;
70  typedef TFieldsFunctor FieldsFunctorType;
71 
72  typedef typename OutputVectorDataType::Pointer OutputVectorDataPointer;
73  typedef typename OutputVectorDataType::ConstPointer OutputVectorDataConstPointer;
74 
75  typedef typename InputLabelMapType::LabelObjectType LabelObjectType;
76 
77  typedef typename InputLabelMapType::ConstIterator ConstIteratorType;
78  typedef typename OutputVectorDataType::DataNodeType DataNodeType;
79  typedef typename DataNodeType::Pointer DataNodePointerType;
80  typedef typename DataNodeType::PolygonType PolygonType;
81  typedef typename PolygonType::Pointer PolygonPointerType;
82 
86 
88  itkNewMacro(Self);
89 
92 
94  using Superclass::SetInput;
95  virtual void SetInput(const InputLabelMapType* input);
96  virtual void SetInput(unsigned int idx, const InputLabelMapType* input);
97  const InputLabelMapType* GetInput(void);
98  const InputLabelMapType* GetInput(unsigned int idx);
100 
101  /* Set the functor used to provide additional OGR fields */
102  void SetFieldsFunctor(const FieldsFunctorType& functor)
103  {
104  m_FieldsFunctor = functor;
105  this->Modified();
106  }
107 
108  /* Get the functor used to provide additional OGR fields */
110  {
111  return m_FieldsFunctor;
112  }
113 
114 protected:
117  {
118  }
119  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
120  void GenerateData() override;
121 
122 private:
124  void operator=(const Self&) = delete;
125 
127 }; // end of class
128 
129 } // end namespace itk
130 
131 #ifndef OTB_MANUAL_INSTANTIATION
133 #endif
134 
135 #endif
This filter simplify and close the input polygon, making the last point equal to the first one.
This class vectorizes a LabelObject to a Polygon.
This class vectorizes a LabelObject to a VectorData.
otb::Functor::LabelObjectToPolygonFunctor< LabelObjectType, PolygonType > FunctorType
OutputVectorDataType::DataNodeType DataNodeType
VectorDataSource< TVectorData > Superclass
OutputVectorDataType::Pointer OutputVectorDataPointer
InputLabelMapType::LabelObjectType LabelObjectType
itk::SmartPointer< const Self > ConstPointer
LabelMapToVectorDataFilter(const Self &)=delete
void operator=(const Self &)=delete
otb::CorrectPolygonFunctor< PolygonType > CorrectFunctorType
void SetFieldsFunctor(const FieldsFunctorType &functor)
InputLabelMapType::ConstIterator ConstIteratorType
OutputVectorDataType::ConstPointer OutputVectorDataConstPointer
Filter hierarchy for generating VectorData.
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.