OTB  6.1.0
Orfeo Toolbox
otbLabelMapToVectorDataFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2017 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 
56 template<class TLabelMap, class TVectorData,
57  class TFieldsFunctor = Functor::LabelObjectFieldsFunctor<typename TLabelMap::LabelObjectType> >
58 class ITK_EXPORT LabelMapToVectorDataFilter :
59  public VectorDataSource<TVectorData>
60 {
61 public:
68 
70  typedef TLabelMap InputLabelMapType;
71  typedef TVectorData OutputVectorDataType;
72  typedef TFieldsFunctor FieldsFunctorType;
73 
74  typedef typename OutputVectorDataType::Pointer OutputVectorDataPointer;
75  typedef typename OutputVectorDataType::ConstPointer OutputVectorDataConstPointer;
76 
77  typedef typename InputLabelMapType::LabelObjectType LabelObjectType;
78 
79  typedef typename InputLabelMapType::ConstIterator ConstIteratorType;
80  typedef typename OutputVectorDataType::DataNodeType DataNodeType;
81  typedef typename DataNodeType::Pointer DataNodePointerType;
82  typedef typename DataNodeType::PolygonType PolygonType;
83  typedef typename PolygonType::Pointer PolygonPointerType;
84 
88 
90  itkNewMacro(Self);
91 
93  itkTypeMacro(LabelMapToVectorDataFilter,
95 
97  using Superclass::SetInput;
98  virtual void SetInput(const InputLabelMapType *input);
99  virtual void SetInput(unsigned int idx, const InputLabelMapType *input);
100  const InputLabelMapType * GetInput(void);
101  const InputLabelMapType * GetInput(unsigned int idx);
103 
104  /* Set the functor used to provide additional OGR fields */
105  void SetFieldsFunctor(const FieldsFunctorType& functor)
106  {
107  m_FieldsFunctor = functor;
108  this->Modified();
109  }
110 
111  /* Get the functor used to provide additional OGR fields */
113  {
114  return m_FieldsFunctor;
115  }
116 
117 protected:
119  ~LabelMapToVectorDataFilter() ITK_OVERRIDE {}
120  void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE;
121  void GenerateData() ITK_OVERRIDE;
122 
123 private:
124  LabelMapToVectorDataFilter(const Self &); //purposely not implemented
125  void operator =(const Self&); //purposely not implemented
126 
127  FieldsFunctorType m_FieldsFunctor;
128 }; // end of class
129 
130 } // end namespace itk
131 
132 #ifndef OTB_MANUAL_INSTANTIATION
134 #endif
135 
136 #endif
OutputVectorDataType::Pointer OutputVectorDataPointer
This class vectorizes a LabelObject to a Polygon.
This class vectorizes a LabelObject to a VectorData.
Filter hierarchy for generating VectorData.
itk::SmartPointer< const Self > ConstPointer
otb::Functor::LabelObjectToPolygonFunctor< LabelObjectType, PolygonType > FunctorType
InputLabelMapType::LabelObjectType LabelObjectType
VectorDataSource< TVectorData > Superclass
OutputVectorDataType::ConstPointer OutputVectorDataConstPointer
This filter simplify and close the input polygon, making the last point equal to the first one...
OutputVectorDataType::DataNodeType DataNodeType
InputLabelMapType::ConstIterator ConstIteratorType
void SetFieldsFunctor(const FieldsFunctorType &functor)
otb::CorrectPolygonFunctor< PolygonType > CorrectFunctorType