OTB  9.0.0
Orfeo Toolbox
otbVectorDataToLabelMapWithAttributesFilter.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 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::DataTreeType::TreeNodeType InternalTreeNodeType;
85  typedef typename InternalTreeNodeType::ChildrenListType ChildrenListType;
86  typedef typename InputVectorDataType::DataNodeType DataNodeType;
87  typedef typename DataNodeType::Pointer DataNodePointerType;
88  typedef typename DataNodeType::PolygonType PolygonType;
89  typedef typename PolygonType::Pointer PolygonPointerType;
90  typedef typename OutputLabelMapType::LabelType LabelType;
91 
92  typedef typename OutputLabelMapType::IndexType IndexType;
93  typedef typename OutputLabelMapType::PixelType OutputLabelMapPixelType;
94  typedef typename OutputLabelMapType::PointType OriginType;
95  typedef typename OutputLabelMapType::SpacingType SpacingType;
96  typedef typename OutputLabelMapType::DirectionType DirectionType;
97  typedef typename OutputLabelMapType::RegionType RegionType;
98  typedef typename OutputLabelMapType::LabelObjectType LabelObjectType;
99  typedef typename LabelObjectType::AttributesValueType AttributesValueType;
100 
102 
105 
107  itkStaticConstMacro(VectorDataDimension, unsigned int, TVectorData::Dimension);
108 
110  typedef itk::Size<itkGetStaticConstMacro(VectorDataDimension)> SizeType;
111 
112  typedef typename InputVectorDataType::PointType PointType;
113 
117  typedef itk::SmartPointer<Self> Pointer;
118  typedef itk::SmartPointer<const Self> ConstPointer;
119 
123  itkTypeMacro(VectorDataToLabelMapWithAttributesFilter, ImageToImageFilter);
124  ;
126 
130  itkNewMacro(Self);
131  ;
132 
137  itkSetMacro(BackgroundValue, OutputLabelMapPixelType);
138  ;
139  itkGetConstMacro(BackgroundValue, OutputLabelMapPixelType);
140  ;
142 
144  itkSetMacro(Size, SizeType);
145  ;
146 
148  itkGetConstReferenceMacro(Size, SizeType);
149  ;
150 
153  itkSetMacro(Origin, OriginType);
154  ;
155  virtual void SetOrigin(const double origin[2]);
156  virtual void SetOrigin(const float origin[2]);
158 
159  itkGetConstReferenceMacro(Origin, OriginType);
160  ;
161 
163  itkGetConstReferenceMacro(StartIndex, IndexType);
164  ;
165  itkSetMacro(StartIndex, IndexType);
166  ;
167 
170  virtual void SetSpacing(const SpacingType& spacing);
171  virtual void SetSpacing(const double spacing[2]);
172  virtual void SetSpacing(const float spacing[2]);
174 
175  itkGetConstReferenceMacro(Spacing, SpacingType);
176  ;
177 
179  using Superclass::SetInput;
180  virtual void SetInput(const InputVectorDataType* input);
181  virtual void SetInput(unsigned int idx, const InputVectorDataType* input);
182  const InputVectorDataType* GetInput(void);
183  const InputVectorDataType* GetInput(unsigned int idx);
185 
187  itkSetMacro(AutomaticSizeComputation, bool);
188  ;
189  itkGetMacro(AutomaticSizeComputation, bool);
190  ;
192 
194  itkSetMacro(InitialLabel, LabelType);
195  ;
196  itkGetMacro(InitialLabel, LabelType);
197  ;
199 
200  void GenerateOutputInformation() override;
201 
202 protected:
205  {
206  }
207  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
208 
213  void GenerateData() override;
214 
218  // void GenerateInputRequestedRegion();
219 
224  // void EnlargeOutputRequestedRegion(itk::DataObject *itkNotUsed(output));
225 
226 private:
227  VectorDataToLabelMapWithAttributesFilter(const Self&) = delete;
228  void operator=(const Self&) = delete;
229 
230  void ProcessNode(InternalTreeNodeType* source);
231 
234 
237 
238  // TODO don't need this attributes now compute with VectorDataProperties
239 
240  SpacingType m_Spacing{0.0};
241  OriginType m_Origin{0.0};
242  SizeType m_Size{0,0};
245 
248 
251 };
252 
253 } // end namespace itk
254 
255 #ifndef OTB_MANUAL_INSTANTIATION
257 #endif
258 
259 #endif
otb::VectorDataToLabelMapWithAttributesFilter::RegionType
OutputLabelMapType::RegionType RegionType
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:97
otb::VectorDataToLabelMapWithAttributesFilter::PointType
InputVectorDataType::PointType PointType
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:112
otb::VectorDataToLabelMapWithAttributesFilter::m_InitialLabel
LabelType m_InitialLabel
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:236
otb::VectorDataToLabelMapWithAttributesFilter::InputVectorDataConstPointer
InputVectorDataType::ConstPointer InputVectorDataConstPointer
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:79
otb::VectorDataToLabelMapWithAttributesFilter::~VectorDataToLabelMapWithAttributesFilter
~VectorDataToLabelMapWithAttributesFilter() override
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:204
otb::VectorDataToLabelMapWithAttributesFilter::PolygonPointerType
PolygonType::Pointer PolygonPointerType
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:89
otb::VectorDataToLabelMapWithAttributesFilter::m_VectorDataProperties
VectorDataPropertiesType::Pointer m_VectorDataProperties
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:250
otb::VectorDataToLabelMapWithAttributesFilter::InternalTreeNodeType
InputVectorDataType::DataTreeType::TreeNodeType InternalTreeNodeType
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:84
otb::VectorDataToLabelMapWithAttributesFilter::m_AutomaticSizeComputation
bool m_AutomaticSizeComputation
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:249
otbVectorDataProperties.h
otb::VectorDataToLabelMapWithAttributesFilter::m_Direction
DirectionType m_Direction
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:244
otb::VectorDataToLabelMapWithAttributesFilter::DataNodeType
InputVectorDataType::DataNodeType DataNodeType
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:86
otb::VectorDataToLabelMapWithAttributesFilter::OutputLabelMapType
TLabelMap OutputLabelMapType
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:77
otb::VectorDataToLabelMapWithAttributesFilter::Self
VectorDataToLabelMapWithAttributesFilter Self
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:72
otbVectorDataToLabelMapWithAttributesFilter.hxx
otb::VectorDataToLabelMapWithAttributesFilter::LabelObjectType
OutputLabelMapType::LabelObjectType LabelObjectType
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:98
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::VectorDataToLabelMapWithAttributesFilter::m_StartIndex
IndexType m_StartIndex
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:243
otb::VectorDataToLabelMapWithAttributesFilter::DirectionType
OutputLabelMapType::DirectionType DirectionType
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:96
otb::VectorDataToLabelMapWithAttributesFilter::OriginType
OutputLabelMapType::PointType OriginType
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:94
otb::VectorDataToLabelMapWithAttributesFilter::CorrectFunctorType
otb::CorrectPolygonFunctor< PolygonType > CorrectFunctorType
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:104
otb::VectorDataToLabelMapWithAttributesFilter::IndexType
OutputLabelMapType::IndexType IndexType
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:92
otb::VectorDataToLabelMapWithAttributesFilter::AttributesValueType
LabelObjectType::AttributesValueType AttributesValueType
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:99
otb::VectorDataToLabelMapWithAttributesFilter::InputVectorDataPointer
InputVectorDataType::Pointer InputVectorDataPointer
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:78
otb::VectorDataProperties::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbVectorDataProperties.h:47
otb::VectorDataToLabelMapWithAttributesFilter::Superclass
LabelMapSource< TLabelMap > Superclass
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:73
otb::VectorDataToLabelMapWithAttributesFilter::PolygonType
DataNodeType::PolygonType PolygonType
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:88
otb::VectorDataToLabelMapWithAttributesFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:118
otb::CorrectPolygonFunctor
This filter simplify and close the input polygon, making the last point equal to the first one.
Definition: otbCorrectPolygonFunctor.h:42
otb::VectorDataToLabelMapWithAttributesFilter
Converts a vector data into a LabelMap.
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:65
otb::LabelMapSource
Base class for filter that output LabelMap.
Definition: otbLabelMapSource.h:41
otb::VectorDataToLabelMapWithAttributesFilter::LabelType
OutputLabelMapType::LabelType LabelType
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:90
otb::VectorDataToLabelMapWithAttributesFilter::InputVectorDataType
TVectorData InputVectorDataType
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:76
otb::VectorDataToLabelMapWithAttributesFilter::SpacingType
OutputLabelMapType::SpacingType SpacingType
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:95
otb::VectorDataToLabelMapWithAttributesFilter::VectorDataPropertiesType
VectorDataProperties< InputVectorDataType > VectorDataPropertiesType
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:101
otbCorrectPolygonFunctor.h
otb::VectorDataToLabelMapWithAttributesFilter::OutputLabelMapPointer
OutputLabelMapType::Pointer OutputLabelMapPointer
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:81
otb::VectorDataToLabelMapWithAttributesFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:117
otb::VectorDataToLabelMapWithAttributesFilter::DataNodePointerType
DataNodeType::Pointer DataNodePointerType
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:87
otb::VectorDataToLabelMapWithAttributesFilter::SizeType
itk::Size< itkGetStaticConstMacro(VectorDataDimension)> SizeType
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:110
otb::VectorDataProperties
Compute public properties of the vectordata.
Definition: otbVectorDataProperties.h:41
otb::VectorDataToLabelMapWithAttributesFilter::ChildrenListType
InternalTreeNodeType::ChildrenListType ChildrenListType
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:85
otb::VectorDataToLabelMapWithAttributesFilter::m_lab
LabelType m_lab
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:233
otb::VectorDataToLabelMapWithAttributesFilter::OutputLabelMapConstPointer
OutputLabelMapType::ConstPointer OutputLabelMapConstPointer
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:82
otb::VectorDataToLabelMapWithAttributesFilter::OutputLabelMapPixelType
OutputLabelMapType::PixelType OutputLabelMapPixelType
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:93
otb::VectorDataToLabelMapWithAttributesFilter::m_BackgroundValue
OutputLabelMapPixelType m_BackgroundValue
Definition: otbVectorDataToLabelMapWithAttributesFilter.h:247
otbLabelMapSource.h