OTB  6.1.0
Orfeo Toolbox
otbVectorDataToLabelMapFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2017 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 :
59  public LabelMapSource <TLabelMap>
60 
61 {
62 public:
68 
70  typedef TVectorData InputVectorDataType;
71  typedef TLabelMap OutputLabelMapType;
72  typedef typename InputVectorDataType::Pointer InputVectorDataPointer;
73  typedef typename InputVectorDataType::ConstPointer InputVectorDataConstPointer;
74 
75  typedef typename OutputLabelMapType::Pointer OutputLabelMapPointer;
76  typedef typename OutputLabelMapType::ConstPointer OutputLabelMapConstPointer;
77 
78  typedef typename InputVectorDataType::DataTreeType::TreeNodeType InternalTreeNodeType;
79  typedef typename InternalTreeNodeType::ChildrenListType ChildrenListType;
80  typedef typename InputVectorDataType::DataNodeType DataNodeType;
81  typedef typename DataNodeType::Pointer DataNodePointerType;
82  typedef typename DataNodeType::PolygonType PolygonType;
83  typedef typename PolygonType::Pointer PolygonPointerType;
84  typedef typename OutputLabelMapType::LabelType LabelType;
85 
87  typedef typename OutputLabelMapType::PixelType OutputLabelMapPixelType;
90  typedef typename OutputLabelMapType::DirectionType DirectionType;
91 
94 
96  itkStaticConstMacro(VectorDataDimension, unsigned int,
97  TVectorData::Dimension);
98 
101 
103 
109 
111 // itkSetMacro( Size, SizeType );
112 
114 // itkSetMacro( StartIndex, IndexType );
115 
119  itkTypeMacro(VectorDataToLabelMapFilter, ImageToImageFilter);
120 
124  itkNewMacro(Self);
125 
130  itkSetMacro(BackgroundValue, OutputLabelMapPixelType);
131  itkGetConstMacro(BackgroundValue, OutputLabelMapPixelType);
133 
135  itkSetMacro(Size, SizeType);
136 
138  itkGetConstReferenceMacro(Size, SizeType);
139 
142  itkSetMacro(Origin, OriginType);
143  virtual void SetOrigin(const double origin[2]);
144  virtual void SetOrigin(const float origin[2]);
146 
147  itkGetConstReferenceMacro(Origin, OriginType);
148 
150  itkGetConstReferenceMacro(StartIndex, IndexType);
151  itkSetMacro(StartIndex, IndexType);
152 
155  virtual void SetSpacing(const SpacingType& spacing);
156  virtual void SetSpacing(const double spacing[2]);
157  virtual void SetSpacing(const float spacing[2]);
159 
160  itkGetConstReferenceMacro(Spacing, SpacingType);
161 
163  using Superclass::SetInput;
164  virtual void SetInput(const InputVectorDataType *input);
165  virtual void SetInput(unsigned int idx, const InputVectorDataType *input);
166  const InputVectorDataType * GetInput(void);
167  const InputVectorDataType * GetInput(unsigned int idx);
169 
170  void GenerateOutputInformation() ITK_OVERRIDE;
171 
172 protected:
174  ~VectorDataToLabelMapFilter() ITK_OVERRIDE {}
175  void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE;
176 
181  void GenerateData() ITK_OVERRIDE;
182 
186 // void GenerateInputRequestedRegion();
187 
192 // void EnlargeOutputRequestedRegion(itk::DataObject *itkNotUsed(output));
193 
194 private:
195  VectorDataToLabelMapFilter(const Self &); //purposely not implemented
196  void operator =(const Self&); //purposely not implemented
197 
198  void ProcessNode(InternalTreeNodeType * source);
199 
201  LabelType m_lab;
202 
203  //TODO donc need this attribute now compute with VectorDataProperties
204  SpacingType m_Spacing;
205  OriginType m_Origin;
206  SizeType m_Size;
207  IndexType m_StartIndex;
208  DirectionType m_Direction;
209 
211  OutputLabelMapPixelType m_BackgroundValue;
212 };
213 
214 } // end namespace itk
215 
216 #ifndef OTB_MANUAL_INSTANTIATION
218 #endif
219 
220 #endif
OutputLabelMapType::Pointer OutputLabelMapPointer
OutputLabelMapType::LabelType LabelType
itk::Size< itkGetStaticConstMacro(VectorDataDimension)> SizeType
Convert a vector data and produce a collection of label objects for each node.
InputVectorDataType::ConstPointer InputVectorDataConstPointer
InputVectorDataType::DataTreeType::TreeNodeType InternalTreeNodeType
InputVectorDataType::Pointer InputVectorDataPointer
InputVectorDataType::PointType PointType
OutputLabelMapType::DirectionType DirectionType
itk::Index< Monteverdi_DIMENSION > IndexType
Definition: mvdTypes.h:142
itk::SmartPointer< const Self > ConstPointer
InputVectorDataType::DataNodeType DataNodeType
otb::CorrectPolygonFunctor< PolygonType > CorrectFunctorType
Base class for filter that output LabelMap.
This filter simplify and close the input polygon, making the last point equal to the first one...
OutputLabelMapType::IndexType IndexType
InternalTreeNodeType::ChildrenListType ChildrenListType
OutputLabelMapType::ConstPointer OutputLabelMapConstPointer
OutputLabelMapType::PixelType OutputLabelMapPixelType
VectorImageType::SpacingType SpacingType
Definition: mvdTypes.h:190
OutputLabelMapType::PointType OriginType
OutputLabelMapType::SpacingType SpacingType
VectorImageType::PointType PointType
Definition: mvdTypes.h:198