OTB  9.0.0
Orfeo Toolbox
otbVectorDataToLabelMapFilter.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 
22 #ifndef otbVectorDataToLabelMapFilter_h
23 #define otbVectorDataToLabelMapFilter_h
24 
25 #include "itkLabelObject.h"
26 #include "itkProgressReporter.h"
27 #include "itkBarrier.h"
28 #include "itkConceptChecking.h"
29 #include "itkContinuousIndex.h"
30 //#include "itkDataObject.h"
31 
32 #include "otbLabelMapSource.h"
33 #include "otbVectorData.h"
35 
36 #include <vector>
37 #include <map>
38 
39 // #include "itkImageToImageFilter.h"
40 
41 namespace otb
42 {
43 
57 template <class TVectorData, class TLabelMap>
58 class ITK_EXPORT VectorDataToLabelMapFilter : public LabelMapSource<TLabelMap>
59 
60 {
61 public:
67 
69  typedef TVectorData InputVectorDataType;
70  typedef TLabelMap OutputLabelMapType;
71  typedef typename InputVectorDataType::Pointer InputVectorDataPointer;
72  typedef typename InputVectorDataType::ConstPointer InputVectorDataConstPointer;
73 
74  typedef typename OutputLabelMapType::Pointer OutputLabelMapPointer;
75  typedef typename OutputLabelMapType::ConstPointer OutputLabelMapConstPointer;
76 
77  typedef typename InputVectorDataType::DataTreeType::TreeNodeType InternalTreeNodeType;
78  typedef typename InternalTreeNodeType::ChildrenListType ChildrenListType;
79  typedef typename InputVectorDataType::DataNodeType DataNodeType;
80  typedef typename DataNodeType::Pointer DataNodePointerType;
81  typedef typename DataNodeType::PolygonType PolygonType;
82  typedef typename PolygonType::Pointer PolygonPointerType;
83  typedef typename OutputLabelMapType::LabelType LabelType;
84 
85  typedef typename OutputLabelMapType::IndexType IndexType;
86  typedef typename OutputLabelMapType::PixelType OutputLabelMapPixelType;
87  typedef typename OutputLabelMapType::PointType OriginType;
88  typedef typename OutputLabelMapType::SpacingType SpacingType;
89  typedef typename OutputLabelMapType::DirectionType DirectionType;
90 
93 
95  itkStaticConstMacro(VectorDataDimension, unsigned int, TVectorData::Dimension);
96 
98  typedef itk::Size<itkGetStaticConstMacro(VectorDataDimension)> SizeType;
99 
100  typedef typename InputVectorDataType::PointType PointType;
101 
105  typedef itk::SmartPointer<Self> Pointer;
106  typedef itk::SmartPointer<const Self> ConstPointer;
107 
109  // itkSetMacro( Size, SizeType );
110 
112  // itkSetMacro( StartIndex, IndexType );
113 
117  itkTypeMacro(VectorDataToLabelMapFilter, ImageToImageFilter);
118 
122  itkNewMacro(Self);
123 
128  itkSetMacro(BackgroundValue, OutputLabelMapPixelType);
129  itkGetConstMacro(BackgroundValue, OutputLabelMapPixelType);
131 
133  itkSetMacro(Size, SizeType);
134 
136  itkGetConstReferenceMacro(Size, SizeType);
137 
140  itkSetMacro(Origin, OriginType);
141  virtual void SetOrigin(const double origin[2]);
142  virtual void SetOrigin(const float origin[2]);
144 
145  itkGetConstReferenceMacro(Origin, OriginType);
146 
148  itkGetConstReferenceMacro(StartIndex, IndexType);
149  itkSetMacro(StartIndex, IndexType);
150 
153  virtual void SetSpacing(const SpacingType& spacing);
154  virtual void SetSpacing(const double spacing[2]);
155  virtual void SetSpacing(const float spacing[2]);
157 
158  itkGetConstReferenceMacro(Spacing, SpacingType);
159 
161  using Superclass::SetInput;
162  virtual void SetInput(const InputVectorDataType* input);
163  virtual void SetInput(unsigned int idx, const InputVectorDataType* input);
164  const InputVectorDataType* GetInput(void);
165  const InputVectorDataType* GetInput(unsigned int idx);
167 
168  void GenerateOutputInformation() override;
169 
170 protected:
173  {
174  }
175  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
176 
181  void GenerateData() override;
182 
186  // void GenerateInputRequestedRegion();
187 
192  // void EnlargeOutputRequestedRegion(itk::DataObject *itkNotUsed(output));
193 
194 private:
195  VectorDataToLabelMapFilter(const Self&) = delete;
196  void operator=(const Self&) = delete;
197 
198  void ProcessNode(InternalTreeNodeType* source);
199 
202 
203  // TODO donc need this attribute now compute with VectorDataProperties
204  SpacingType m_Spacing{0.0};
205  OriginType m_Origin{0.0};
206  SizeType m_Size{0,0};
209 
212 };
213 
214 } // end namespace itk
215 
216 #ifndef OTB_MANUAL_INSTANTIATION
218 #endif
219 
220 #endif
otb::VectorDataToLabelMapFilter::m_Direction
DirectionType m_Direction
Definition: otbVectorDataToLabelMapFilter.h:208
otb::VectorDataToLabelMapFilter::PolygonPointerType
PolygonType::Pointer PolygonPointerType
Definition: otbVectorDataToLabelMapFilter.h:82
otb::VectorDataToLabelMapFilter::InputVectorDataPointer
InputVectorDataType::Pointer InputVectorDataPointer
Definition: otbVectorDataToLabelMapFilter.h:71
otb::VectorDataToLabelMapFilter::PolygonType
DataNodeType::PolygonType PolygonType
Definition: otbVectorDataToLabelMapFilter.h:81
otb::VectorDataToLabelMapFilter::OriginType
OutputLabelMapType::PointType OriginType
Definition: otbVectorDataToLabelMapFilter.h:87
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otbVectorDataToLabelMapFilter.hxx
otb::VectorDataToLabelMapFilter::LabelType
OutputLabelMapType::LabelType LabelType
Definition: otbVectorDataToLabelMapFilter.h:83
otb::VectorDataToLabelMapFilter::IndexType
OutputLabelMapType::IndexType IndexType
Definition: otbVectorDataToLabelMapFilter.h:85
otb::VectorDataToLabelMapFilter::m_lab
LabelType m_lab
Definition: otbVectorDataToLabelMapFilter.h:201
otb::VectorDataToLabelMapFilter::OutputLabelMapConstPointer
OutputLabelMapType::ConstPointer OutputLabelMapConstPointer
Definition: otbVectorDataToLabelMapFilter.h:75
otb::VectorDataToLabelMapFilter::m_BackgroundValue
OutputLabelMapPixelType m_BackgroundValue
Definition: otbVectorDataToLabelMapFilter.h:211
otb::VectorDataToLabelMapFilter::m_StartIndex
IndexType m_StartIndex
Definition: otbVectorDataToLabelMapFilter.h:207
otb::VectorDataToLabelMapFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbVectorDataToLabelMapFilter.h:106
otb::VectorDataToLabelMapFilter::Superclass
LabelMapSource< TLabelMap > Superclass
Definition: otbVectorDataToLabelMapFilter.h:66
otb::VectorDataToLabelMapFilter::OutputLabelMapPixelType
OutputLabelMapType::PixelType OutputLabelMapPixelType
Definition: otbVectorDataToLabelMapFilter.h:86
otb::VectorDataToLabelMapFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbVectorDataToLabelMapFilter.h:105
otb::VectorDataToLabelMapFilter::DirectionType
OutputLabelMapType::DirectionType DirectionType
Definition: otbVectorDataToLabelMapFilter.h:89
otb::VectorDataToLabelMapFilter::DataNodePointerType
DataNodeType::Pointer DataNodePointerType
Definition: otbVectorDataToLabelMapFilter.h:80
otb::VectorDataToLabelMapFilter::SpacingType
OutputLabelMapType::SpacingType SpacingType
Definition: otbVectorDataToLabelMapFilter.h:88
otb::VectorDataToLabelMapFilter
Convert a vector data and produce a collection of label objects for each node.
Definition: otbVectorDataToLabelMapFilter.h:58
otb::CorrectPolygonFunctor
This filter simplify and close the input polygon, making the last point equal to the first one.
Definition: otbCorrectPolygonFunctor.h:42
otb::LabelMapSource
Base class for filter that output LabelMap.
Definition: otbLabelMapSource.h:41
otbVectorData.h
otb::VectorDataToLabelMapFilter::~VectorDataToLabelMapFilter
~VectorDataToLabelMapFilter() override
Definition: otbVectorDataToLabelMapFilter.h:172
otbCorrectPolygonFunctor.h
otb::VectorDataToLabelMapFilter::InternalTreeNodeType
InputVectorDataType::DataTreeType::TreeNodeType InternalTreeNodeType
Definition: otbVectorDataToLabelMapFilter.h:77
otb::VectorDataToLabelMapFilter::OutputLabelMapType
TLabelMap OutputLabelMapType
Definition: otbVectorDataToLabelMapFilter.h:70
otb::VectorDataToLabelMapFilter::ChildrenListType
InternalTreeNodeType::ChildrenListType ChildrenListType
Definition: otbVectorDataToLabelMapFilter.h:78
otb::VectorDataToLabelMapFilter::PointType
InputVectorDataType::PointType PointType
Definition: otbVectorDataToLabelMapFilter.h:100
otb::VectorDataToLabelMapFilter::Self
VectorDataToLabelMapFilter Self
Definition: otbVectorDataToLabelMapFilter.h:65
otb::VectorDataToLabelMapFilter::CorrectFunctorType
otb::CorrectPolygonFunctor< PolygonType > CorrectFunctorType
Definition: otbVectorDataToLabelMapFilter.h:92
otb::VectorDataToLabelMapFilter::DataNodeType
InputVectorDataType::DataNodeType DataNodeType
Definition: otbVectorDataToLabelMapFilter.h:79
otb::VectorDataToLabelMapFilter::SizeType
itk::Size< itkGetStaticConstMacro(VectorDataDimension)> SizeType
Definition: otbVectorDataToLabelMapFilter.h:98
otb::VectorDataToLabelMapFilter::OutputLabelMapPointer
OutputLabelMapType::Pointer OutputLabelMapPointer
Definition: otbVectorDataToLabelMapFilter.h:74
otbLabelMapSource.h
otb::VectorDataToLabelMapFilter::InputVectorDataType
TVectorData InputVectorDataType
Definition: otbVectorDataToLabelMapFilter.h:69
otb::VectorDataToLabelMapFilter::InputVectorDataConstPointer
InputVectorDataType::ConstPointer InputVectorDataConstPointer
Definition: otbVectorDataToLabelMapFilter.h:72