ITK  6.0.0
Insight Toolkit
itkTransformBase.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * https://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkTransformBase_h
19 #define itkTransformBase_h
20 
21 #include "ITKTransformExport.h"
22 
23 #include "itkObject.h"
24 #include "itkPoint.h"
25 #include "itkCovariantVector.h"
26 #include "vnl/vnl_vector_fixed.h"
27 #include "itkArray2D.h"
28 #include "itkOptimizerParameters.h"
29 
30 #include "itkObjectFactory.h"
31 #include "itkIntTypes.h"
32 
33 namespace itk
34 {
40 {
41 public:
45  enum class TransformCategory : uint8_t
46  {
48  Linear = 1,
49  BSpline = 2,
50  Spline = 3,
52  VelocityField = 5
53  };
54 };
55 // Define how to print enumeration
56 extern ITKTransform_EXPORT std::ostream &
57  operator<<(std::ostream & out, const TransformBaseTemplateEnums::TransformCategory value);
58 
63  enum class TransformCategory : uint8_t
64  {
66  Linear = 1,
67  BSpline = 2,
68  Spline = 3,
70  VelocityField = 5
71  };
72 };
73 // Define how to print enumeration
74 extern ITKTransform_EXPORT std::ostream &
75  operator<<(std::ostream & out, const TransformBaseTemplateEnums::TransformCategory value);
76  *
77  * This class is an abstract class to represent a spatial transform.
78  *
79  * This class is templated over the scalar type used to store the transform's
80  * parameters.
81  *
82  * \ingroup ITKTransform
83  */
84 template <typename TParametersValueType>
85 class TransformBaseTemplate : public Object
86 {
87 public:
88  ITK_DISALLOW_COPY_AND_MOVE(TransformBaseTemplate);
93  using Superclass = Object;
94  using Pointer = SmartPointer<Self>;
95  using ConstPointer = SmartPointer<const Self>;
96 
99  using ParametersValueType = TParametersValueType;
100  using ParametersType = OptimizerParameters<ParametersValueType>;
101  using FixedParametersValueType = double;
102  using FixedParametersType = OptimizerParameters<FixedParametersValueType>;
103 
106 
110 
111  /* For storing the name of InputSpace */
112  itkSetMacro(InputSpaceName, std::string);
113  itkGetConstReferenceMacro(InputSpaceName, std::string);
114 
121  itkSetMacro(OutputSpaceName, std::string);
122  itkGetConstReferenceMacro(OutputSpaceName, std::string);
123 
125  virtual NumberOfParametersType
126  GetNumberOfParameters() const = 0;
127 
129  virtual const ParametersType &
130  GetParameters() const = 0;
131 
133  virtual unsigned int
134  GetInputSpaceDimension() const = 0;
135 
137  virtual unsigned int
138  GetOutputSpaceDimension() const = 0;
139 
141  virtual void
142  SetParameters(const ParametersType &) = 0;
143 
151  virtual void
152  SetParametersByValue(const ParametersType & p) = 0;
153 
155  virtual void
157 
162  virtual void
163  CopyInParameters(const ParametersValueType * const begin, const ParametersValueType * const end) = 0;
164 
169  virtual void
170  CopyInFixedParameters(const FixedParametersValueType * const begin, const FixedParametersValueType * const end) = 0;
171 
173  virtual const FixedParametersType &
174  GetFixedParameters() const = 0;
175 
177  virtual std::string
178  GetTransformTypeAsString() const = 0;
179 
181 #if !defined(ITK_LEGACY_REMOVE)
182  // We need to expose the enum values at the class level
183  // for backwards compatibility
184  static constexpr TransformCategoryEnum UnknownTransformCategory = TransformCategoryEnum::UnknownTransformCategory;
185  static constexpr TransformCategoryEnum Linear = TransformCategoryEnum::Linear;
186  static constexpr TransformCategoryEnum BSpline = TransformCategoryEnum::BSpline;
187  static constexpr TransformCategoryEnum Spline = TransformCategoryEnum::Spline;
188  static constexpr TransformCategoryEnum DisplacementField = TransformCategoryEnum::DisplacementField;
189  static constexpr TransformCategoryEnum VelocityField = TransformCategoryEnum::VelocityField;
190 
191  // Preserve old type name for backwards compatibility
193 #endif
194 
196  virtual TransformCategoryEnum
197  GetTransformCategory() const = 0;
198 
199 protected:
200  TransformBaseTemplate() = default;
201  ~TransformBaseTemplate() override = default;
202 
203 private:
204  std::string m_InputSpaceName{};
205  std::string m_OutputSpaceName{};
206 };
207 
210 } // end namespace itk
211 
212 #endif
213 
TransformBaseTemplate
Definition: itkTransformBase.h:85
TransformBaseTemplate::ParametersValueType
TParametersValueType ParametersValueType
Definition: itkTransformBase.h:99
itk::VariableLengthVectorExpression::operator<<
std::ostream & operator<<(std::ostream &os, VariableLengthVectorExpression< TExpr1, TExpr2, TBinaryOp > const &v)
Definition: itkVariableLengthVector.h:1350
itkObjectFactory.h
TransformBaseTemplate::Linear
static constexpr TransformCategoryEnum Linear
Definition: itkTransformBase.h:185
itkCovariantVector.h
IdentifierType
unsigned long IdentifierType
Definition: itkQuadEdgeMeshEulerOperatorsTestHelper.h:24
TransformBaseTemplate::ParametersType
OptimizerParameters< ParametersValueType > ParametersType
Definition: itkTransformBase.h:100
TransformBaseTemplate::itkGetConstReferenceMacro
itkGetConstReferenceMacro(InputSpaceName, std::string)
itkPoint.h
TransformBaseTemplate::GetParameters
virtual const ParametersType & GetParameters() const =0
itk::TransformCategory::BSpline
TransformBaseTemplate::BSpline
static constexpr TransformCategoryEnum BSpline
Definition: itkTransformBase.h:186
itk::operator<<
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, typename AnatomicalOrientation::CoordinateEnum value)
itk::TransformBaseTemplateEnums::TransformCategory
TransformCategory
Definition: itkTransformBase.h:45
TransformBaseTemplate::GetTransformCategory
virtual TransformCategoryEnum GetTransformCategory() const =0
TransformBaseTemplate::FixedParametersValueType
double FixedParametersValueType
Definition: itkTransformBase.h:101
TransformBaseTemplate::itkSetMacro
itkSetMacro(InputSpaceName, std::string)
itk::TransformCategory::Spline
TransformBaseTemplate::SetParametersByValue
virtual void SetParametersByValue(const ParametersType &p)=0
itk::TransformCategory::UnknownTransformCategory
TransformBaseTemplate::Pointer
SmartPointer< Self > Pointer
Definition: itkTransformBase.h:94
itkOptimizerParameters.h
TransformBaseTemplate::FixedParametersType
OptimizerParameters< FixedParametersValueType > FixedParametersType
Definition: itkTransformBase.h:102
TransformBaseTemplate::UnknownTransformCategory
static constexpr TransformCategoryEnum UnknownTransformCategory
Definition: itkTransformBase.h:184
TransformBaseTemplate::GetFixedParameters
virtual const FixedParametersType & GetFixedParameters() const =0
itk::TransformBaseTemplateEnums::TransformCategory::Spline
TransformBaseTemplate::Superclass
Object Superclass
Definition: itkTransformBase.h:93
TransformBaseTemplate::TransformCategoryType
TransformCategoryEnum TransformCategoryType
Definition: itkTransformBase.h:192
TransformBaseTemplate::TransformCategoryEnum
TransformBaseTemplateEnums::TransformCategory TransformCategoryEnum
Definition: itkTransformBase.h:180
TransformBaseTemplate::GetTransformTypeAsString
virtual std::string GetTransformTypeAsString() const =0
itkIntTypes.h
itk::TransformCategory
TransformCategory
Definition: itkTransformBase.h:63
itk::TransformBaseTemplateEnums::TransformCategory::BSpline
itkObject.h
itk::TransformBaseTemplateEnums
Contains all enum classes used by TransformBaseTemplate class.
Definition: itkTransformBase.h:39
TransformBaseTemplate::NumberOfParametersType
IdentifierType NumberOfParametersType
Definition: itkTransformBase.h:109
TransformBaseTemplate::DisplacementField
static constexpr TransformCategoryEnum DisplacementField
Definition: itkTransformBase.h:188
itk::TransformBaseTemplateEnums::TransformCategory::UnknownTransformCategory
itkArray2D.h
TransformBaseTemplate::SetParameters
virtual void SetParameters(const ParametersType &)=0
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::TransformBaseTemplateEnums::TransformCategory::Linear
TransformBaseTemplate::itkOverrideGetNameOfClassMacro
itkOverrideGetNameOfClassMacro(TransformBaseTemplate)
itk::TransformCategory::VelocityField
TransformBaseTemplate::m_OutputSpaceName
std::string m_OutputSpaceName
Definition: itkTransformBase.h:205
itk::TransformCategory::Linear
TransformBaseTemplate::CopyInFixedParameters
virtual void CopyInFixedParameters(const FixedParametersValueType *const begin, const FixedParametersValueType *const end)=0
TransformBaseTemplate::VelocityField
static constexpr TransformCategoryEnum VelocityField
Definition: itkTransformBase.h:189
itk::TransformBaseTemplateEnums::TransformCategory::VelocityField
TransformBaseTemplate::ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkTransformBase.h:95
TransformBaseTemplate::GetInputSpaceDimension
virtual unsigned int GetInputSpaceDimension() const =0
TransformBaseTemplate::m_InputSpaceName
std::string m_InputSpaceName
Definition: itkTransformBase.h:204
TransformBaseTemplate::SetFixedParameters
virtual void SetFixedParameters(const FixedParametersType &)=0
TransformBaseTemplate::GetNumberOfParameters
virtual NumberOfParametersType GetNumberOfParameters() const =0
itk::TransformCategory::DisplacementField
TransformBaseTemplate::CopyInParameters
virtual void CopyInParameters(const ParametersValueType *const begin, const ParametersValueType *const end)=0
TransformBaseTemplate::Spline
static constexpr TransformCategoryEnum Spline
Definition: itkTransformBase.h:187
TransformBaseTemplate::GetOutputSpaceDimension
virtual unsigned int GetOutputSpaceDimension() const =0
itk::TransformBaseTemplateEnums::TransformCategory::DisplacementField