OTB  10.0.0
Orfeo Toolbox
otbVectorDataToLabelMapWithAttributesFilter.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 otbVectorDataToLabelMapWithAttributesFilter_h
23 #define otbVectorDataToLabelMapWithAttributesFilter_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"
34 
35 #include <vector>
36 #include <map>
37 
39 // #include "itkImageToImageFilter.h"
40 
41 namespace otb
42 {
43 
64 template <class TVectorData, class TLabelMap>
65 class ITK_EXPORT VectorDataToLabelMapWithAttributesFilter : public LabelMapSource<TLabelMap>
66 
67 {
68 public:
74 
76  typedef TVectorData InputVectorDataType;
77  typedef TLabelMap OutputLabelMapType;
78  typedef typename InputVectorDataType::Pointer InputVectorDataPointer;
79  typedef typename InputVectorDataType::ConstPointer InputVectorDataConstPointer;
80 
81  typedef typename OutputLabelMapType::Pointer OutputLabelMapPointer;
82  typedef typename OutputLabelMapType::ConstPointer OutputLabelMapConstPointer;
83 
84  typedef typename InputVectorDataType::ChildrenListType ChildrenListType;
85  typedef typename InputVectorDataType::DataNodeType DataNodeType;
86  typedef typename DataNodeType::Pointer DataNodePointerType;
87  typedef typename DataNodeType::PolygonType PolygonType;
88  typedef typename PolygonType::Pointer PolygonPointerType;
89  typedef typename OutputLabelMapType::LabelType LabelType;
90 
91  typedef typename OutputLabelMapType::IndexType IndexType;
92  typedef typename OutputLabelMapType::PixelType OutputLabelMapPixelType;
93  typedef typename OutputLabelMapType::PointType OriginType;
94  typedef typename OutputLabelMapType::SpacingType SpacingType;
95  typedef typename OutputLabelMapType::DirectionType DirectionType;
96  typedef typename OutputLabelMapType::RegionType RegionType;
97  typedef typename OutputLabelMapType::LabelObjectType LabelObjectType;
98  typedef typename LabelObjectType::AttributesValueType AttributesValueType;
99 
101 
104 
106  itkStaticConstMacro(VectorDataDimension, unsigned int, TVectorData::Dimension);
107 
109  typedef itk::Size<itkGetStaticConstMacro(VectorDataDimension)> SizeType;
110 
111  typedef typename InputVectorDataType::PointType PointType;
112 
116  typedef itk::SmartPointer<Self> Pointer;
117  typedef itk::SmartPointer<const Self> ConstPointer;
118 
122  itkTypeMacro(VectorDataToLabelMapWithAttributesFilter, ImageToImageFilter);
123  ;
125 
129  itkNewMacro(Self);
130  ;
131 
136  itkSetMacro(BackgroundValue, OutputLabelMapPixelType);
137  ;
138  itkGetConstMacro(BackgroundValue, OutputLabelMapPixelType);
139  ;
141 
143  itkSetMacro(Size, SizeType);
144  ;
145 
147  itkGetConstReferenceMacro(Size, SizeType);
148  ;
149 
152  itkSetMacro(Origin, OriginType);
153  ;
154  virtual void SetOrigin(const double origin[2]);
155  virtual void SetOrigin(const float origin[2]);
157 
158  itkGetConstReferenceMacro(Origin, OriginType);
159  ;
160 
162  itkGetConstReferenceMacro(StartIndex, IndexType);
163  ;
164  itkSetMacro(StartIndex, IndexType);
165  ;
166 
169  virtual void SetSpacing(const SpacingType& spacing);
170  virtual void SetSpacing(const double spacing[2]);
171  virtual void SetSpacing(const float spacing[2]);
173 
174  itkGetConstReferenceMacro(Spacing, SpacingType);
175  ;
176 
178  using Superclass::SetInput;
179  virtual void SetInput(const InputVectorDataType* input);
180  virtual void SetInput(unsigned int idx, const InputVectorDataType* input);
181  const InputVectorDataType* GetInput(void);
182  const InputVectorDataType* GetInput(unsigned int idx);
184 
186  itkSetMacro(AutomaticSizeComputation, bool);
187  ;
188  itkGetMacro(AutomaticSizeComputation, bool);
189  ;
191 
193  itkSetMacro(InitialLabel, LabelType);
194  ;
195  itkGetMacro(InitialLabel, LabelType);
196  ;
198 
199  void GenerateOutputInformation() override;
200 
201 protected:
204  {
205  }
206  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
207 
212  void GenerateData() override;
213 
217  // void GenerateInputRequestedRegion();
218 
223  // void EnlargeOutputRequestedRegion(itk::DataObject *itkNotUsed(output));
224 
225 private:
227  void operator=(const Self&) = delete;
228 
229  void ProcessNode(InputVectorDataConstPointer inputVdata, DataNodePointerType source);
230 
233 
236 
237  // TODO don't need this attributes now compute with VectorDataProperties
238 
239  SpacingType m_Spacing{0.0};
240  OriginType m_Origin{0.0};
241  SizeType m_Size{0,0};
244 
247 
250 };
251 
252 } // end namespace itk
253 
254 #ifndef OTB_MANUAL_INSTANTIATION
256 #endif
257 
258 #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.
Compute public properties of the vectordata.
itk::SmartPointer< Self > Pointer
itk::Size< itkGetStaticConstMacro(VectorDataDimension)> SizeType
VectorDataProperties< InputVectorDataType > VectorDataPropertiesType
VectorDataToLabelMapWithAttributesFilter(const Self &)=delete
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.