OTB  9.0.0
Orfeo Toolbox
otbVariableLengthVectorConverter.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 #ifndef otbVariableLengthVectorConverter_h
22 #define otbVariableLengthVectorConverter_h
23 
24 #include "itkProcessObject.h"
25 #include "itkVariableLengthVector.h"
26 #include "itkFixedArray.h"
27 #include "itkHistogram.h"
28 #include "itkSmartPointer.h"
29 
30 
31 namespace otb
32 {
44 // Base
45 template <class TInputType, class TPrecisionType = double>
46 class ITK_EXPORT VariableLengthVectorConverter : public itk::ProcessObject
47 {
48 public:
51  typedef itk::ProcessObject Superclass;
52  typedef itk::SmartPointer<Self> Pointer;
53  typedef itk::SmartPointer<const Self> ConstPointer;
54 
56  itkTypeMacro(VariableLengthVectorConverter, ProcessObject);
57 
59  itkNewMacro(Self);
60 
61  typedef TPrecisionType OutputPrecisionType;
62  typedef typename itk::VariableLengthVector<OutputPrecisionType> OutputType;
63  typedef TInputType InputType;
64 
66  {
67  OutputType output;
68  output.SetSize(1);
69  output.SetElement(0, static_cast<OutputPrecisionType>(input));
70  return output;
71  }
72 
73 protected:
75  {
76  }
78  {
79  }
80  void PrintSelf(std::ostream& os, itk::Indent indent) const override
81  {
82  Superclass::PrintSelf(os, indent);
83  os << "Attempt to use inexistent implementation of the converter!" << std::endl;
84  }
85 
86 private:
87  VariableLengthVectorConverter(const Self&) = delete;
88  void operator=(const Self&) = delete;
89 };
90 
91 // VariableLengthVector
92 template <class TInternalInputType, class TPrecisionType>
93 class ITK_EXPORT VariableLengthVectorConverter<itk::VariableLengthVector<TInternalInputType>, TPrecisionType> : public itk::ProcessObject
94 {
95 public:
98  typedef itk::ProcessObject Superclass;
99  typedef itk::SmartPointer<Self> Pointer;
100  typedef itk::SmartPointer<const Self> ConstPointer;
101 
103  itkTypeMacro(VariableLengthVectorConverter, ProcessObject);
104 
106  itkNewMacro(Self);
107 
108  typedef TPrecisionType OutputPrecisionType;
109  typedef typename itk::VariableLengthVector<OutputPrecisionType> OutputType;
110  typedef itk::VariableLengthVector<TInternalInputType> InputType;
111 
113  {
114  return static_cast<OutputType>(input);
115  }
116 
117 protected:
119  {
120  }
122  {
123  }
124  void PrintSelf(std::ostream& os, itk::Indent indent) const override
125  {
126  Superclass::PrintSelf(os, indent);
127  os << "Attempt to use inexistent implementation of the converter!" << std::endl;
128  }
129 
130 private:
131  VariableLengthVectorConverter(const Self&) = delete;
132  void operator=(const Self&) = delete;
133 };
134 
135 
136 // Real Matrix
137 template <class TInternalInputType, class TPrecisionType>
138 class ITK_EXPORT VariableLengthVectorConverter<std::vector<std::vector<TInternalInputType>>, TPrecisionType> : public itk::ProcessObject
139 {
140 public:
143  typedef itk::ProcessObject Superclass;
144  typedef itk::SmartPointer<Self> Pointer;
145  typedef itk::SmartPointer<const Self> ConstPointer;
146 
148  itkTypeMacro(VariableLengthVectorConverter, ProcessObject);
149 
151  itkNewMacro(Self);
152 
153  typedef TPrecisionType OutputPrecisionType;
154  typedef typename itk::VariableLengthVector<OutputPrecisionType> OutputType;
155  typedef typename std::vector<std::vector<TInternalInputType>> InputType;
156 
157  OutputType Convert(InputType input);
158 
159 protected:
161  {
162  }
164  {
165  }
166  void PrintSelf(std::ostream& os, itk::Indent indent) const override
167  {
168  Superclass::PrintSelf(os, indent);
169  os << "Converter: std::vector<std::vector<RealType>> => VariableLengthVector<RealType>" << std::endl;
170  }
171 
172 private:
173  VariableLengthVectorConverter(const Self&) = delete;
174  void operator=(const Self&) = delete;
175 };
176 
177 
178 // Complex Matrix
179 template <class TInternalInputType, class TPrecisionType>
180 class ITK_EXPORT VariableLengthVectorConverter<std::vector<std::vector<std::complex<TInternalInputType>>>, TPrecisionType> : public itk::ProcessObject
181 {
182 public:
185  typedef itk::ProcessObject Superclass;
186  typedef itk::SmartPointer<Self> Pointer;
187  typedef itk::SmartPointer<const Self> ConstPointer;
188 
190  itkTypeMacro(VariableLengthVectorConverter, ProcessObject);
191 
193  itkNewMacro(Self);
194 
195  typedef TPrecisionType OutputPrecisionType;
196  typedef typename itk::VariableLengthVector<OutputPrecisionType> OutputType;
197  typedef typename std::vector<std::vector<std::complex<TInternalInputType>>> InputType;
198 
199  OutputType Convert(InputType input);
200 
201 protected:
203  {
204  }
206  {
207  }
208  void PrintSelf(std::ostream& os, itk::Indent indent) const override
209  {
210  Superclass::PrintSelf(os, indent);
211  os << "Converter: std::vector<std::vector<std::complex<RealType>>> => VariableLengthVector<RealType>" << std::endl;
212  }
213 
214 private:
215  VariableLengthVectorConverter(const Self&) = delete;
216  void operator=(const Self&) = delete;
217 };
218 
219 
220 // Fixed Array
221 template <class TInternalInputType, unsigned int VArrayDimension, class TPrecisionType>
222 class ITK_EXPORT VariableLengthVectorConverter<itk::FixedArray<TInternalInputType, VArrayDimension>, TPrecisionType> : public itk::ProcessObject
223 {
224 public:
227  typedef itk::ProcessObject Superclass;
228  typedef itk::SmartPointer<Self> Pointer;
229  typedef itk::SmartPointer<const Self> ConstPointer;
230 
232  itkTypeMacro(VariableLengthVectorConverter, ProcessObject);
233 
235  itkNewMacro(Self);
236 
237  typedef TPrecisionType OutputPrecisionType;
238  typedef typename itk::VariableLengthVector<OutputPrecisionType> OutputType;
239  typedef typename itk::FixedArray<TInternalInputType, VArrayDimension> InputType;
240 
241  OutputType Convert(InputType input);
242 
243 protected:
245  {
246  }
248  {
249  }
250  void PrintSelf(std::ostream& os, itk::Indent indent) const override
251  {
252  Superclass::PrintSelf(os, indent);
253  os << "Converter: itk::FixedArray<RealType, VArrayDimension> => VariableLengthVector<RealType>" << std::endl;
254  }
255 
256 private:
257  VariableLengthVectorConverter(const Self&) = delete;
258  void operator=(const Self&) = delete;
259 };
260 
261 // Histogram
262 template <class TPixel, class TPrecisionType>
263 class ITK_EXPORT VariableLengthVectorConverter<typename itk::SmartPointer<itk::Statistics::Histogram<TPixel>>, TPrecisionType> : public itk::ProcessObject
264 {
265 public:
268  typedef itk::ProcessObject Superclass;
269  typedef itk::SmartPointer<Self> Pointer;
270  typedef itk::SmartPointer<const Self> ConstPointer;
271 
273  itkTypeMacro(VariableLengthVectorConverter, ProcessObject);
274 
276  itkNewMacro(Self);
277 
278  typedef TPrecisionType OutputPrecisionType;
279  typedef typename itk::VariableLengthVector<OutputPrecisionType> OutputType;
280  typedef typename itk::SmartPointer<itk::Statistics::Histogram<TPixel>> InputType;
281 
282  OutputType Convert(InputType input);
283 
284 protected:
286  {
287  }
289  {
290  }
291  void PrintSelf(std::ostream& os, itk::Indent indent) const override
292  {
293  Superclass::PrintSelf(os, indent);
294  os << "Converter: itk::Statistics::Histogram<RealType, VMeasurementVectorSize, TFrequencyContainer> => VariableLengthVector<RealType>" << std::endl;
295  }
296 
297 private:
298  VariableLengthVectorConverter(const Self&) = delete;
299  void operator=(const Self&) = delete;
300 };
301 
302 } // namespace otb
303 
304 #ifndef OTB_MANUAL_INSTANTIATION
306 #endif
307 
308 #endif
otb::VariableLengthVectorConverter::Superclass
itk::ProcessObject Superclass
Definition: otbVariableLengthVectorConverter.h:51
otb::VariableLengthVectorConverter< itk::SmartPointer< itk::Statistics::Histogram< TPixel > >, TPrecisionType >::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbVariableLengthVectorConverter.h:270
otb::VariableLengthVectorConverter< itk::SmartPointer< itk::Statistics::Histogram< TPixel > >, TPrecisionType >::InputType
itk::SmartPointer< itk::Statistics::Histogram< TPixel > > InputType
Definition: otbVariableLengthVectorConverter.h:280
otb::VariableLengthVectorConverter::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbVariableLengthVectorConverter.h:80
otb::VariableLengthVectorConverter::InputType
TInputType InputType
Definition: otbVariableLengthVectorConverter.h:63
otb::VariableLengthVectorConverter::~VariableLengthVectorConverter
~VariableLengthVectorConverter() override
Definition: otbVariableLengthVectorConverter.h:77
otb::VariableLengthVectorConverter< itk::SmartPointer< itk::Statistics::Histogram< TPixel > >, TPrecisionType >::OutputType
itk::VariableLengthVector< OutputPrecisionType > OutputType
Definition: otbVariableLengthVectorConverter.h:279
otb::VariableLengthVectorConverter< itk::SmartPointer< itk::Statistics::Histogram< TPixel > >, TPrecisionType >::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbVariableLengthVectorConverter.h:291
otb::VariableLengthVectorConverter< std::vector< std::vector< TInternalInputType > >, TPrecisionType >::Superclass
itk::ProcessObject Superclass
Definition: otbVariableLengthVectorConverter.h:143
otb::VariableLengthVectorConverter< itk::FixedArray< TInternalInputType, VArrayDimension >, TPrecisionType >::Superclass
itk::ProcessObject Superclass
Definition: otbVariableLengthVectorConverter.h:227
otb::VariableLengthVectorConverter< itk::VariableLengthVector< TInternalInputType >, TPrecisionType >::~VariableLengthVectorConverter
~VariableLengthVectorConverter() override
Definition: otbVariableLengthVectorConverter.h:121
otb::VariableLengthVectorConverter< itk::VariableLengthVector< TInternalInputType >, TPrecisionType >::OutputPrecisionType
TPrecisionType OutputPrecisionType
Definition: otbVariableLengthVectorConverter.h:106
otb::VariableLengthVectorConverter< itk::VariableLengthVector< TInternalInputType >, TPrecisionType >::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbVariableLengthVectorConverter.h:124
otb::VariableLengthVectorConverter< itk::VariableLengthVector< TInternalInputType >, TPrecisionType >::Convert
OutputType Convert(InputType input)
Definition: otbVariableLengthVectorConverter.h:112
otb::VariableLengthVectorConverter
Convert any data container type into a VariableLengthVector.
Definition: otbVariableLengthVectorConverter.h:46
otb::VariableLengthVectorConverter< itk::VariableLengthVector< TInternalInputType >, TPrecisionType >::Superclass
itk::ProcessObject Superclass
Definition: otbVariableLengthVectorConverter.h:98
otb::VariableLengthVectorConverter< itk::FixedArray< TInternalInputType, VArrayDimension >, TPrecisionType >::OutputType
itk::VariableLengthVector< OutputPrecisionType > OutputType
Definition: otbVariableLengthVectorConverter.h:238
otb::VariableLengthVectorConverter< std::vector< std::vector< TInternalInputType > >, TPrecisionType >::OutputPrecisionType
TPrecisionType OutputPrecisionType
Definition: otbVariableLengthVectorConverter.h:151
otb::VariableLengthVectorConverter< std::vector< std::vector< TInternalInputType > >, TPrecisionType >::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbVariableLengthVectorConverter.h:145
otb::VariableLengthVectorConverter< std::vector< std::vector< TInternalInputType > >, TPrecisionType >::InputType
std::vector< std::vector< TInternalInputType > > InputType
Definition: otbVariableLengthVectorConverter.h:155
otb::VariableLengthVectorConverter< itk::VariableLengthVector< TInternalInputType >, TPrecisionType >::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbVariableLengthVectorConverter.h:99
otb::VariableLengthVectorConverter< std::vector< std::vector< std::complex< TInternalInputType > > >, TPrecisionType >::~VariableLengthVectorConverter
~VariableLengthVectorConverter() override
Definition: otbVariableLengthVectorConverter.h:205
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::VariableLengthVectorConverter::OutputType
itk::VariableLengthVector< OutputPrecisionType > OutputType
Definition: otbVariableLengthVectorConverter.h:62
otb::VariableLengthVectorConverter< itk::VariableLengthVector< TInternalInputType >, TPrecisionType >::InputType
itk::VariableLengthVector< TInternalInputType > InputType
Definition: otbVariableLengthVectorConverter.h:110
otb::VariableLengthVectorConverter< std::vector< std::vector< std::complex< TInternalInputType > > >, TPrecisionType >::OutputType
itk::VariableLengthVector< OutputPrecisionType > OutputType
Definition: otbVariableLengthVectorConverter.h:196
otb::VariableLengthVectorConverter< itk::VariableLengthVector< TInternalInputType >, TPrecisionType >::VariableLengthVectorConverter
VariableLengthVectorConverter()
Definition: otbVariableLengthVectorConverter.h:118
otb::VariableLengthVectorConverter< itk::VariableLengthVector< TInternalInputType >, TPrecisionType >::OutputType
itk::VariableLengthVector< OutputPrecisionType > OutputType
Definition: otbVariableLengthVectorConverter.h:109
otb::VariableLengthVectorConverter::Self
VariableLengthVectorConverter Self
Definition: otbVariableLengthVectorConverter.h:50
otb::VariableLengthVectorConverter::OutputPrecisionType
TPrecisionType OutputPrecisionType
Definition: otbVariableLengthVectorConverter.h:59
otb::VariableLengthVectorConverter< std::vector< std::vector< TInternalInputType > >, TPrecisionType >::Self
VariableLengthVectorConverter Self
Definition: otbVariableLengthVectorConverter.h:142
otb::VariableLengthVectorConverter< std::vector< std::vector< std::complex< TInternalInputType > > >, TPrecisionType >::Self
VariableLengthVectorConverter Self
Definition: otbVariableLengthVectorConverter.h:184
otb::VariableLengthVectorConverter< itk::SmartPointer< itk::Statistics::Histogram< TPixel > >, TPrecisionType >::Superclass
itk::ProcessObject Superclass
Definition: otbVariableLengthVectorConverter.h:268
otb::VariableLengthVectorConverter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbVariableLengthVectorConverter.h:52
otb::VariableLengthVectorConverter< std::vector< std::vector< std::complex< TInternalInputType > > >, TPrecisionType >::InputType
std::vector< std::vector< std::complex< TInternalInputType > > > InputType
Definition: otbVariableLengthVectorConverter.h:197
otb::VariableLengthVectorConverter< itk::FixedArray< TInternalInputType, VArrayDimension >, TPrecisionType >::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbVariableLengthVectorConverter.h:229
otb::VariableLengthVectorConverter< itk::FixedArray< TInternalInputType, VArrayDimension >, TPrecisionType >::InputType
itk::FixedArray< TInternalInputType, VArrayDimension > InputType
Definition: otbVariableLengthVectorConverter.h:239
otb::VariableLengthVectorConverter< itk::SmartPointer< itk::Statistics::Histogram< TPixel > >, TPrecisionType >::Self
VariableLengthVectorConverter Self
Definition: otbVariableLengthVectorConverter.h:267
otb::VariableLengthVectorConverter< itk::FixedArray< TInternalInputType, VArrayDimension >, TPrecisionType >::OutputPrecisionType
TPrecisionType OutputPrecisionType
Definition: otbVariableLengthVectorConverter.h:235
otb::VariableLengthVectorConverter< std::vector< std::vector< std::complex< TInternalInputType > > >, TPrecisionType >::Superclass
itk::ProcessObject Superclass
Definition: otbVariableLengthVectorConverter.h:185
otb::VariableLengthVectorConverter< itk::FixedArray< TInternalInputType, VArrayDimension >, TPrecisionType >::~VariableLengthVectorConverter
~VariableLengthVectorConverter() override
Definition: otbVariableLengthVectorConverter.h:247
otb::VariableLengthVectorConverter< std::vector< std::vector< std::complex< TInternalInputType > > >, TPrecisionType >::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbVariableLengthVectorConverter.h:208
otb::VariableLengthVectorConverter< std::vector< std::vector< TInternalInputType > >, TPrecisionType >::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbVariableLengthVectorConverter.h:166
otb::VariableLengthVectorConverter::Convert
OutputType Convert(InputType input)
Definition: otbVariableLengthVectorConverter.h:65
otb::VariableLengthVectorConverter< std::vector< std::vector< std::complex< TInternalInputType > > >, TPrecisionType >::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbVariableLengthVectorConverter.h:187
otb::VariableLengthVectorConverter< itk::FixedArray< TInternalInputType, VArrayDimension >, TPrecisionType >::VariableLengthVectorConverter
VariableLengthVectorConverter()
Definition: otbVariableLengthVectorConverter.h:244
otb::VariableLengthVectorConverter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbVariableLengthVectorConverter.h:53
otb::VariableLengthVectorConverter< std::vector< std::vector< std::complex< TInternalInputType > > >, TPrecisionType >::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbVariableLengthVectorConverter.h:186
otb::VariableLengthVectorConverter< itk::VariableLengthVector< TInternalInputType >, TPrecisionType >::Self
VariableLengthVectorConverter Self
Definition: otbVariableLengthVectorConverter.h:97
otb::VariableLengthVectorConverter< std::vector< std::vector< std::complex< TInternalInputType > > >, TPrecisionType >::OutputPrecisionType
TPrecisionType OutputPrecisionType
Definition: otbVariableLengthVectorConverter.h:193
otb::VariableLengthVectorConverter< std::vector< std::vector< TInternalInputType > >, TPrecisionType >::VariableLengthVectorConverter
VariableLengthVectorConverter()
Definition: otbVariableLengthVectorConverter.h:160
otb::VariableLengthVectorConverter< itk::FixedArray< TInternalInputType, VArrayDimension >, TPrecisionType >::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbVariableLengthVectorConverter.h:250
otb::VariableLengthVectorConverter< itk::SmartPointer< itk::Statistics::Histogram< TPixel > >, TPrecisionType >::~VariableLengthVectorConverter
~VariableLengthVectorConverter() override
Definition: otbVariableLengthVectorConverter.h:288
otb::VariableLengthVectorConverter< std::vector< std::vector< TInternalInputType > >, TPrecisionType >::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbVariableLengthVectorConverter.h:144
otb::VariableLengthVectorConverter< std::vector< std::vector< TInternalInputType > >, TPrecisionType >::OutputType
itk::VariableLengthVector< OutputPrecisionType > OutputType
Definition: otbVariableLengthVectorConverter.h:154
itk
Definition: otbNoDataHelper.h:31
otb::VariableLengthVectorConverter< itk::SmartPointer< itk::Statistics::Histogram< TPixel > >, TPrecisionType >::OutputPrecisionType
TPrecisionType OutputPrecisionType
Definition: otbVariableLengthVectorConverter.h:276
otb::VariableLengthVectorConverter< std::vector< std::vector< std::complex< TInternalInputType > > >, TPrecisionType >::VariableLengthVectorConverter
VariableLengthVectorConverter()
Definition: otbVariableLengthVectorConverter.h:202
otb::VariableLengthVectorConverter< itk::FixedArray< TInternalInputType, VArrayDimension >, TPrecisionType >::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbVariableLengthVectorConverter.h:228
otb::VariableLengthVectorConverter< itk::VariableLengthVector< TInternalInputType >, TPrecisionType >::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbVariableLengthVectorConverter.h:100
otb::VariableLengthVectorConverter< itk::SmartPointer< itk::Statistics::Histogram< TPixel > >, TPrecisionType >::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbVariableLengthVectorConverter.h:269
otbVariableLengthVectorConverter.hxx
otb::VariableLengthVectorConverter< itk::FixedArray< TInternalInputType, VArrayDimension >, TPrecisionType >::Self
VariableLengthVectorConverter Self
Definition: otbVariableLengthVectorConverter.h:226
otb::VariableLengthVectorConverter< itk::SmartPointer< itk::Statistics::Histogram< TPixel > >, TPrecisionType >::VariableLengthVectorConverter
VariableLengthVectorConverter()
Definition: otbVariableLengthVectorConverter.h:285
otb::VariableLengthVectorConverter::VariableLengthVectorConverter
VariableLengthVectorConverter()
Definition: otbVariableLengthVectorConverter.h:74
otb::VariableLengthVectorConverter< std::vector< std::vector< TInternalInputType > >, TPrecisionType >::~VariableLengthVectorConverter
~VariableLengthVectorConverter() override
Definition: otbVariableLengthVectorConverter.h:163