OTB  6.7.0
Orfeo Toolbox
otbVectorDataToLabelMapWithAttributesFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 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>
66  public LabelMapSource <TLabelMap>
67 
68 {
69 public:
75 
77  typedef TVectorData InputVectorDataType;
78  typedef TLabelMap OutputLabelMapType;
79  typedef typename InputVectorDataType::Pointer InputVectorDataPointer;
80  typedef typename InputVectorDataType::ConstPointer InputVectorDataConstPointer;
81 
82  typedef typename OutputLabelMapType::Pointer OutputLabelMapPointer;
83  typedef typename OutputLabelMapType::ConstPointer OutputLabelMapConstPointer;
84 
85  typedef typename InputVectorDataType::DataTreeType::TreeNodeType InternalTreeNodeType;
86  typedef typename InternalTreeNodeType::ChildrenListType ChildrenListType;
87  typedef typename InputVectorDataType::DataNodeType DataNodeType;
88  typedef typename DataNodeType::Pointer DataNodePointerType;
89  typedef typename DataNodeType::PolygonType PolygonType;
90  typedef typename PolygonType::Pointer PolygonPointerType;
91  typedef typename OutputLabelMapType::LabelType LabelType;
92 
94  typedef typename OutputLabelMapType::PixelType OutputLabelMapPixelType;
97  typedef typename OutputLabelMapType::DirectionType DirectionType;
98  typedef typename OutputLabelMapType::RegionType RegionType;
99  typedef typename OutputLabelMapType::LabelObjectType LabelObjectType;
100  typedef typename LabelObjectType::AttributesValueType AttributesValueType;
101 
103 
106 
108  itkStaticConstMacro(VectorDataDimension, unsigned int,
109  TVectorData::Dimension);
110 
113 
115 
121 
125  itkTypeMacro(VectorDataToLabelMapWithAttributesFilter, ImageToImageFilter);
126 ;
128 
132  itkNewMacro(Self);
133 ;
134 
139  itkSetMacro(BackgroundValue, OutputLabelMapPixelType);
140 ; itkGetConstMacro(BackgroundValue, OutputLabelMapPixelType);
141 ;
143 
145  itkSetMacro(Size, SizeType);
146 ;
147 
149  itkGetConstReferenceMacro(Size, SizeType);
150 ;
151 
154  itkSetMacro(Origin, OriginType);
155 ;
156  virtual void SetOrigin(const double origin[2]);
157  virtual void SetOrigin(const float origin[2]);
159 
160  itkGetConstReferenceMacro(Origin, OriginType);
161 ;
162 
164  itkGetConstReferenceMacro(StartIndex, IndexType);
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 ; itkGetMacro(AutomaticSizeComputation, bool);
189 ;
191 
193  itkSetMacro(InitialLabel, LabelType);
194 ; itkGetMacro(InitialLabel, LabelType);
195 ;
197 
198  void GenerateOutputInformation() override;
199 
200 protected:
203  {
204  }
205  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
206 
211  void GenerateData() override;
212 
216  // void GenerateInputRequestedRegion();
217 
222  // void EnlargeOutputRequestedRegion(itk::DataObject *itkNotUsed(output));
223 
224 private:
225  VectorDataToLabelMapWithAttributesFilter(const Self &) = delete;
226  void operator =(const Self&) = delete;
227 
228  void ProcessNode(InternalTreeNodeType * source);
229 
232 
235 
236  //TODO don't need this attributes now compute with VectorDataProperties
237 
243 
246 
249 };
250 
251 } // end namespace itk
252 
253 #ifndef OTB_MANUAL_INSTANTIATION
255 #endif
256 
257 #endif
Compute public properties of the vectordata.
VectorDataProperties< InputVectorDataType > VectorDataPropertiesType
itk::Index< Monteverdi_DIMENSION > IndexType
Definition: mvdTypes.h:133
Base class for filter that output LabelMap.
itk::Size< itkGetStaticConstMacro(VectorDataDimension)> SizeType
This filter simplify and close the input polygon, making the last point equal to the first one...
InputVectorDataType::DataTreeType::TreeNodeType InternalTreeNodeType
VectorImageType::SpacingType SpacingType
Definition: mvdTypes.h:181
VectorImageType::PointType PointType
Definition: mvdTypes.h:189