SimpleITK  
sitkAffineTransform.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  * http://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 sitkAffineTransform_h
19 #define sitkAffineTransform_h
20 
21 #include "sitkCommon.h"
22 #include "sitkTransform.h"
23 
24 namespace itk::simple
25 {
26 
34 {
35 public:
38 
39  ~AffineTransform() override;
40 
41  explicit AffineTransform(unsigned int dimensions);
42 
44 
45  explicit AffineTransform(const Transform &);
46 
47  AffineTransform(const std::vector<double> & matrix,
48  const std::vector<double> & translation,
49  const std::vector<double> & fixedCenter = std::vector<double>(3, 0.0));
50 
51 
53  operator=(const AffineTransform &);
54 
56  std::string
57  GetName() const override
58  {
59  return std::string("AffineTransform");
60  }
61 
63  std::vector<double>
64  GetTranslation() const;
65  SITK_RETURN_SELF_TYPE_HEADER
66  SetTranslation(const std::vector<double> & translation);
67 
68  SITK_RETURN_SELF_TYPE_HEADER
69  SetMatrix(const std::vector<double> & matrix);
70  std::vector<double>
71  GetMatrix() const;
72 
74  SITK_RETURN_SELF_TYPE_HEADER
75  SetCenter(const std::vector<double> & params);
76  std::vector<double>
77  GetCenter() const;
78 
80  SITK_RETURN_SELF_TYPE_HEADER
81  Scale(const std::vector<double> & factor, bool pre = false);
82  SITK_RETURN_SELF_TYPE_HEADER
83  Scale(double factor, bool pre = false);
84 
85  SITK_RETURN_SELF_TYPE_HEADER
86  Shear(int axis1, int axis2, double coef, bool pre = false);
87 
88  SITK_RETURN_SELF_TYPE_HEADER
89  Translate(const std::vector<double> & offset, bool pre = false);
90 
91  SITK_RETURN_SELF_TYPE_HEADER
92  Rotate(int axis1, int axis2, double angle, bool pre = false);
93 
94 protected:
95  void
96  SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform) override;
97 
98 private:
99  struct MyVisitor
100  {
103  template <typename TransformType>
104  void
105  operator()() const
106  {
107  TransformType * t = dynamic_cast<TransformType *>(transform);
108  if (t && (typeid(*t) == typeid(TransformType)))
109  {
110  that->InternalInitialization<TransformType>(t);
111  }
112  }
113  };
114 
115  void
116  InternalInitialization(itk::TransformBase * transform);
117 
118  template <typename TransformType>
119  void
120  InternalInitialization(TransformType * transform);
121 
122 
123  std::function<void(const std::vector<double> &)> m_pfSetCenter;
124  std::function<std::vector<double>()> m_pfGetCenter;
125  std::function<void(const std::vector<double> &)> m_pfSetMatrix;
126  std::function<std::vector<double>()> m_pfGetMatrix;
127  std::function<void(const std::vector<double> &)> m_pfSetTranslation;
128  std::function<std::vector<double>()> m_pfGetTranslation;
129 
130  std::function<void(const std::vector<double> &, bool)> m_pfScale1;
131  std::function<void(double, bool)> m_pfScale2;
132  std::function<void(int, int, double, bool)> m_pfShear;
133  std::function<void(const std::vector<double> &, bool)> m_pfTranslate;
134  std::function<void(int, int, double, bool)> m_pfRotate;
135 };
136 
137 } // namespace itk::simple
138 
139 #endif // sitkAffineTransform_h
itk::simple::AffineTransform::m_pfGetMatrix
std::function< std::vector< double >)> m_pfGetMatrix
Definition: sitkAffineTransform.h:126
itk::simple::Transform
A simplified wrapper around a variety of ITK transforms.
Definition: sitkTransform.h:86
itk::simple::AffineTransform::m_pfGetCenter
std::function< std::vector< double >)> m_pfGetCenter
Definition: sitkAffineTransform.h:124
itk::simple::AffineTransform::m_pfRotate
std::function< void(int, int, double, bool)> m_pfRotate
Definition: sitkAffineTransform.h:134
sitkCommon.h
itk::simple::AffineTransform::InternalInitialization
void InternalInitialization(itk::TransformBase *transform)
itk::simple::AffineTransform::m_pfShear
std::function< void(int, int, double, bool)> m_pfShear
Definition: sitkAffineTransform.h:132
itk::simple::AffineTransform::m_pfTranslate
std::function< void(const std::vector< double > &, bool)> m_pfTranslate
Definition: sitkAffineTransform.h:133
itk::simple::AffineTransform::MyVisitor::that
AffineTransform * that
Definition: sitkAffineTransform.h:102
SITKCommon_EXPORT
#define SITKCommon_EXPORT
Definition: sitkCommon.h:41
itk::simple::AffineTransform::MyVisitor::transform
itk::TransformBase * transform
Definition: sitkAffineTransform.h:101
itk::simple::AffineTransform::m_pfSetCenter
std::function< void(const std::vector< double > &)> m_pfSetCenter
Definition: sitkAffineTransform.h:123
itk::simple::AffineTransform::m_pfSetMatrix
std::function< void(const std::vector< double > &)> m_pfSetMatrix
Definition: sitkAffineTransform.h:125
itk::simple::AffineTransform::m_pfScale1
std::function< void(const std::vector< double > &, bool)> m_pfScale1
Definition: sitkAffineTransform.h:130
itk::simple::AffineTransform::m_pfScale2
std::function< void(double, bool)> m_pfScale2
Definition: sitkAffineTransform.h:131
sitkTransform.h
itk::simple::AffineTransform::MyVisitor
Definition: sitkAffineTransform.h:99
itk::simple::AffineTransform::GetName
std::string GetName() const override
Definition: sitkAffineTransform.h:57
itk::simple::AffineTransform::MyVisitor::operator()
void operator()() const
Definition: sitkAffineTransform.h:105
itk::simple::AffineTransform
An affine transformation about a fixed center with translation for a 2D or 3D coordinate.
Definition: sitkAffineTransform.h:33
itk::simple
Definition: sitkAdditionalProcedures.h:28
itk::simple::AffineTransform::m_pfGetTranslation
std::function< std::vector< double >)> m_pfGetTranslation
Definition: sitkAffineTransform.h:128
itk::simple::AffineTransform::m_pfSetTranslation
std::function< void(const std::vector< double > &)> m_pfSetTranslation
Definition: sitkAffineTransform.h:127
itk::TransformBaseTemplate
Definition: sitkTransform.h:32