OTB  10.0.0
Orfeo Toolbox
otbVectorDataToLabelMapFilter.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 
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::ChildrenListType ChildrenListType;
78  typedef typename InputVectorDataType::DataNodeType DataNodeType;
79  typedef typename DataNodeType::Pointer DataNodePointerType;
80  typedef typename DataNodeType::PolygonType PolygonType;
81  typedef typename PolygonType::Pointer PolygonPointerType;
82  typedef typename OutputLabelMapType::LabelType LabelType;
83 
84  typedef typename OutputLabelMapType::IndexType IndexType;
85  typedef typename OutputLabelMapType::PixelType OutputLabelMapPixelType;
86  typedef typename OutputLabelMapType::PointType OriginType;
87  typedef typename OutputLabelMapType::SpacingType SpacingType;
88  typedef typename OutputLabelMapType::DirectionType DirectionType;
89 
92 
94  itkStaticConstMacro(VectorDataDimension, unsigned int, TVectorData::Dimension);
95 
97  typedef itk::Size<itkGetStaticConstMacro(VectorDataDimension)> SizeType;
98 
99  typedef typename InputVectorDataType::PointType PointType;
100 
104  typedef itk::SmartPointer<Self> Pointer;
105  typedef itk::SmartPointer<const Self> ConstPointer;
106 
108  // itkSetMacro( Size, SizeType );
109 
111  // itkSetMacro( StartIndex, IndexType );
112 
116  itkTypeMacro(VectorDataToLabelMapFilter, ImageToImageFilter);
117 
121  itkNewMacro(Self);
122 
127  itkSetMacro(BackgroundValue, OutputLabelMapPixelType);
128  itkGetConstMacro(BackgroundValue, OutputLabelMapPixelType);
130 
132  itkSetMacro(Size, SizeType);
133 
135  itkGetConstReferenceMacro(Size, SizeType);
136 
139  itkSetMacro(Origin, OriginType);
140  virtual void SetOrigin(const double origin[2]);
141  virtual void SetOrigin(const float origin[2]);
143 
144  itkGetConstReferenceMacro(Origin, OriginType);
145 
147  itkGetConstReferenceMacro(StartIndex, IndexType);
148  itkSetMacro(StartIndex, IndexType);
149 
152  virtual void SetSpacing(const SpacingType& spacing);
153  virtual void SetSpacing(const double spacing[2]);
154  virtual void SetSpacing(const float spacing[2]);
156 
157  itkGetConstReferenceMacro(Spacing, SpacingType);
158 
160  using Superclass::SetInput;
161  virtual void SetInput(const InputVectorDataType* input);
162  virtual void SetInput(unsigned int idx, const InputVectorDataType* input);
163  const InputVectorDataType* GetInput(void);
164  const InputVectorDataType* GetInput(unsigned int idx);
166 
167  void GenerateOutputInformation() override;
168 
169 protected:
172  {
173  }
174  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
175 
180  void GenerateData() override;
181 
185  // void GenerateInputRequestedRegion();
186 
191  // void EnlargeOutputRequestedRegion(itk::DataObject *itkNotUsed(output));
192 
193 private:
195  void operator=(const Self&) = delete;
196 
197  void ProcessNode(InputVectorDataConstPointer inputVdata,DataNodePointerType source);
198 
201 
202  // TODO donc need this attribute now compute with VectorDataProperties
203  SpacingType m_Spacing{0.0};
204  OriginType m_Origin{0.0};
205  SizeType m_Size{0,0};
208 
211 };
212 
213 } // end namespace itk
214 
215 #ifndef OTB_MANUAL_INSTANTIATION
217 #endif
218 
219 #endif
This filter simplify and close the input polygon, making the last point equal to the first one.
Base class for filter that output LabelMap.
Convert a vector data and produce a collection of label objects for each node.
OutputLabelMapType::ConstPointer OutputLabelMapConstPointer
OutputLabelMapType::DirectionType DirectionType
VectorDataToLabelMapFilter(const Self &)=delete
InputVectorDataType::Pointer InputVectorDataPointer
InputVectorDataType::ConstPointer InputVectorDataConstPointer
OutputLabelMapType::Pointer OutputLabelMapPointer
itk::SmartPointer< const Self > ConstPointer
OutputLabelMapType::PixelType OutputLabelMapPixelType
OutputLabelMapType::SpacingType SpacingType
itk::Size< itkGetStaticConstMacro(VectorDataDimension)> SizeType
OutputLabelMapType::PointType OriginType
void operator=(const Self &)=delete
InputVectorDataType::PointType PointType
OutputLabelMapType::IndexType IndexType
otb::CorrectPolygonFunctor< PolygonType > CorrectFunctorType
OutputLabelMapType::LabelType LabelType
InputVectorDataType::DataNodeType DataNodeType
InputVectorDataType::ChildrenListType ChildrenListType
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.