OTB  9.0.0
Orfeo Toolbox
otbTransform.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 otbTransform_h
22 #define otbTransform_h
23 
24 #include "itkTransform.h"
25 #include "vnl/vnl_vector_fixed.h"
26 
27 
28 namespace otb
29 {
31 
37 template <class TScalarType, unsigned int NInputDimensions = 3,
38  unsigned int NOutputDimensions = 3>
39 class ITK_EXPORT Transform : public itk::Transform<TScalarType, // Data type for scalars
40  NInputDimensions, // Number of dimensions in the input space
41  NOutputDimensions> // Number of dimensions in the output space
42 {
43 public:
45  typedef Transform Self;
46  typedef itk::Transform<TScalarType, NInputDimensions, NOutputDimensions> Superclass;
47  typedef itk::SmartPointer<Self> Pointer;
48  typedef itk::SmartPointer<const Self> ConstPointer;
49 
51  itkTypeMacro(Transform, itk::Transform);
52 
54  itkStaticConstMacro(InputSpaceDimension, unsigned int, NInputDimensions);
55  itkStaticConstMacro(OutputSpaceDimension, unsigned int, NOutputDimensions);
57 
59  unsigned int GetInputSpaceDimension(void) const override
60  {
61  return NInputDimensions;
62  }
63 
65  unsigned int GetOutputSpaceDimension(void) const override
66  {
67  return NOutputDimensions;
68  }
69 
71  typedef TScalarType ScalarType;
72 
74  typedef typename Superclass::ParametersType ParametersType;
75  typedef typename Superclass::ParametersValueType ParametersValueType;
76  typedef typename Superclass::NumberOfParametersType NumberOfParametersType;
77 
79  typedef itk::Array2D<double> JacobianType;
80 
82  typedef itk::Vector<TScalarType, NInputDimensions> InputVectorType;
83  typedef itk::Vector<TScalarType, NOutputDimensions> OutputVectorType;
84 
86  typedef itk::CovariantVector<TScalarType, NInputDimensions> InputCovariantVectorType;
87  typedef itk::CovariantVector<TScalarType, NOutputDimensions> OutputCovariantVectorType;
88 
90  typedef vnl_vector_fixed<TScalarType, NInputDimensions> InputVnlVectorType;
91  typedef vnl_vector_fixed<TScalarType, NOutputDimensions> OutputVnlVectorType;
92 
94  typedef itk::Point<TScalarType, NInputDimensions> InputPointType;
95  typedef itk::Point<TScalarType, NOutputDimensions> OutputPointType;
96 
99  typedef typename Superclass::InverseTransformBaseType InverseTransformBaseType;
100 
101  typedef typename Superclass::InverseTransformBasePointer InverseTransformBasePointer;
102 
106  {
107  return OutputPointType();
108  }
109 
110  using Superclass::TransformVector;
113  {
114  return OutputVectorType();
115  }
116 
119  {
120  return OutputVnlVectorType();
121  }
122 
123  using Superclass::TransformCovariantVector;
126  {
127  return OutputCovariantVectorType();
128  }
129 
130 
138  void SetParameters(const ParametersType&) override
139  {
140  itkExceptionMacro(<< "Subclasses should override this method (SetParameters)")
141  }
142 
144  {
145  itkExceptionMacro(<< "Subclasses should override this method (ComputeJacobianWithRespectToParameters)");
146  }
147 
155  void SetParametersByValue(const ParametersType& p) override
156  {
157  this->SetParameters(p);
158  }
159 
161  const ParametersType& GetParameters(void) const override
162  {
163  return m_Parameters;
164  }
165 
167  void SetFixedParameters(const ParametersType&) override
168  {
169  itkExceptionMacro(<< "Subclasses should override this method (SetFixedParameters)")
170  }
171 
173  const ParametersType& GetFixedParameters(void) const override
174  {
175  itkExceptionMacro(<< "Subclasses should override this method (GetFixedParameters)");
176  // Next line is needed to avoid errors due to:
177  // "function must return a value".
178  return this->m_FixedParameters;
179  }
181 
209 #ifdef ITKV3_COMPATIBILITY
210  const JacobianType& GetJacobian(const InputPointType&) const override
211 #else
212  virtual const JacobianType& GetJacobian(const InputPointType&) const
213 #endif
214  {
215  itkExceptionMacro(<< "Subclass should override this method (GetJacobian)");
216  // Next line is needed to avoid errors due to:
217  // "function must return a value" .
218  return this->m_Jacobian;
219  }
221 
224  {
225  return this->m_Parameters.Size();
226  }
227 
228 protected:
230  {
231  }
232 
233  Transform(NumberOfParametersType numberOfParameters) : Superclass::Transform(numberOfParameters)
234  {
235  }
236 
237  ~Transform() override
238  {
239  }
240 
241  void PrintSelf(std::ostream& os, itk::Indent indent) const override
242  {
243  Superclass::PrintSelf(os, indent);
244 #if 0
245  os << indent << "Parameters : " << m_Parameters << std::endl;
246  os << indent << "FixedParameters : " << m_FixedParameters << std::endl;
247  os << indent << "Jacobian : " << m_Jacobian << std::endl;
248 #endif
249  }
250 
251 
254 
256 
257 private:
258  Transform(const Self&) = delete;
259  void operator=(const Self&) = delete;
260 };
261 } // end namespace otb
262 
263 #endif
otb::Transform::InputVectorType
itk::Vector< TScalarType, NInputDimensions > InputVectorType
Definition: otbTransform.h:82
otb::TransformDirection
TransformDirection
Definition: otbTransform.h:30
otb::Transform::GetJacobian
virtual const JacobianType & GetJacobian(const InputPointType &) const
Definition: otbTransform.h:212
otb::Transform::GetInputSpaceDimension
unsigned int GetInputSpaceDimension(void) const override
Definition: otbTransform.h:59
otb::Transform::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbTransform.h:47
otb::Transform::SetParameters
void SetParameters(const ParametersType &) override
Definition: otbTransform.h:138
otb::Transform::m_Parameters
ParametersType m_Parameters
Definition: otbTransform.h:252
otb::Transform::OutputPointType
itk::Point< TScalarType, NOutputDimensions > OutputPointType
Definition: otbTransform.h:95
otb::Transform::ScalarType
TScalarType ScalarType
Definition: otbTransform.h:71
otb::Transform::GetOutputSpaceDimension
unsigned int GetOutputSpaceDimension(void) const override
Definition: otbTransform.h:65
otb::Transform::GetFixedParameters
const ParametersType & GetFixedParameters(void) const override
Definition: otbTransform.h:173
otb::Transform::SetParametersByValue
void SetParametersByValue(const ParametersType &p) override
Definition: otbTransform.h:155
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Transform::Transform
Transform()
Definition: otbTransform.h:229
otb::Transform::InverseTransformBasePointer
Superclass::InverseTransformBasePointer InverseTransformBasePointer
Definition: otbTransform.h:101
otb::Transform::InputPointType
itk::Point< TScalarType, NInputDimensions > InputPointType
Definition: otbTransform.h:94
otb::Transform::NumberOfParametersType
Superclass::NumberOfParametersType NumberOfParametersType
Definition: otbTransform.h:76
otb::Transform::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbTransform.h:48
otb::Transform::JacobianType
itk::Array2D< double > JacobianType
Definition: otbTransform.h:79
otb::Transform::ParametersValueType
Superclass::ParametersValueType ParametersValueType
Definition: otbTransform.h:75
otb::Transform::Superclass
itk::Transform< TScalarType, NInputDimensions, NOutputDimensions > Superclass
Definition: otbTransform.h:46
otb::Transform::OutputVectorType
itk::Vector< TScalarType, NOutputDimensions > OutputVectorType
Definition: otbTransform.h:83
otb::Transform::InverseTransformBaseType
Superclass::InverseTransformBaseType InverseTransformBaseType
Definition: otbTransform.h:99
otb::Transform::SetFixedParameters
void SetFixedParameters(const ParametersType &) override
Definition: otbTransform.h:167
otb::Transform::TransformVector
OutputVnlVectorType TransformVector(const InputVnlVectorType &) const override
Definition: otbTransform.h:118
otb::Transform
Class to overload method passed to virtual pure in ITK V4.
Definition: otbTransform.h:39
otb::Transform::TransformPoint
OutputPointType TransformPoint(const InputPointType &) const override
Definition: otbTransform.h:105
otb::TransformDirection::INVERSE
@ INVERSE
otb::TransformDirection::FORWARD
@ FORWARD
otb::Transform::Self
Transform Self
Definition: otbTransform.h:45
otb::Transform::OutputCovariantVectorType
itk::CovariantVector< TScalarType, NOutputDimensions > OutputCovariantVectorType
Definition: otbTransform.h:87
otb::Transform::GetParameters
const ParametersType & GetParameters(void) const override
Definition: otbTransform.h:161
otb::Transform::m_FixedParameters
ParametersType m_FixedParameters
Definition: otbTransform.h:253
otb::Transform::ComputeJacobianWithRespectToParameters
void ComputeJacobianWithRespectToParameters(const InputPointType &, JacobianType &) const override
Definition: otbTransform.h:143
otb::Transform::TransformVector
OutputVectorType TransformVector(const InputVectorType &) const override
Definition: otbTransform.h:112
otb::Transform::OutputVnlVectorType
vnl_vector_fixed< TScalarType, NOutputDimensions > OutputVnlVectorType
Definition: otbTransform.h:91
otb::Transform::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbTransform.h:241
otb::Transform::~Transform
~Transform() override
Definition: otbTransform.h:237
otb::Transform::Transform
Transform(NumberOfParametersType numberOfParameters)
Definition: otbTransform.h:233
otb::Transform::ParametersType
Superclass::ParametersType ParametersType
Definition: otbTransform.h:74
otb::Transform::InputCovariantVectorType
itk::CovariantVector< TScalarType, NInputDimensions > InputCovariantVectorType
Definition: otbTransform.h:86
otb::Transform::InputVnlVectorType
vnl_vector_fixed< TScalarType, NInputDimensions > InputVnlVectorType
Definition: otbTransform.h:90
otb::Transform::m_Jacobian
JacobianType m_Jacobian
Definition: otbTransform.h:255
otb::Transform::GetNumberOfParameters
NumberOfParametersType GetNumberOfParameters(void) const override
Definition: otbTransform.h:223
otb::Transform::TransformCovariantVector
OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const override
Definition: otbTransform.h:125