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  : public Transform
35 {
36 public:
39 
40  ~AffineTransform() override;
41 
42  explicit AffineTransform(unsigned int dimensions);
43 
45 
46  explicit AffineTransform( const Transform & );
47 
48  AffineTransform( const std::vector< double> &matrix,
49  const std::vector< double> &translation,
50  const std::vector< double> &fixedCenter=std::vector< double >(3, 0.0));
51 
52 
53  AffineTransform &operator=( const AffineTransform & );
54 
56  std::string GetName() const override { return std::string ("AffineTransform"); }
57 
59  std::vector<double> GetTranslation( ) const;
60  SITK_RETURN_SELF_TYPE_HEADER SetTranslation( const std::vector<double>& translation);
61 
62  SITK_RETURN_SELF_TYPE_HEADER SetMatrix( const std::vector<double> &matrix);
63  std::vector<double> GetMatrix() const;
64 
66  SITK_RETURN_SELF_TYPE_HEADER SetCenter(const std::vector<double> &params);
67  std::vector<double> GetCenter( ) const;
68 
70  SITK_RETURN_SELF_TYPE_HEADER Scale(const std::vector<double> & factor, bool pre=false);
71  SITK_RETURN_SELF_TYPE_HEADER Scale(double factor, bool pre=false);
72 
73  SITK_RETURN_SELF_TYPE_HEADER Shear(int axis1, int axis2, double coef, bool pre=false);
74 
75  SITK_RETURN_SELF_TYPE_HEADER Translate(const std::vector<double> &offset, bool pre=false);
76 
77  SITK_RETURN_SELF_TYPE_HEADER Rotate(int axis1, int axis2, double angle, bool pre=false);
78 
79 protected:
80 
81  void SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform ) override;
82 
83 private:
84 
85  struct MyVisitor
86  {
89  template< typename TransformType >
90  void operator() ( ) const
91  {
92  TransformType *t = dynamic_cast<TransformType*>(transform);
93  if (t && (typeid(*t) == typeid(TransformType)))
94  {
95  that->InternalInitialization<TransformType>(t);
96  }
97  }
98  };
99 
100  void InternalInitialization(itk::TransformBase *transform);
101 
102  template <typename TransformType>
103  void InternalInitialization(TransformType *transform);
104 
105 
106  std::function<void(const std::vector<double>&)> m_pfSetCenter;
107  std::function<std::vector<double>()> m_pfGetCenter;
108  std::function<void(const std::vector<double>&)> m_pfSetMatrix;
109  std::function<std::vector<double>()> m_pfGetMatrix;
110  std::function<void(const std::vector<double>&)> m_pfSetTranslation;
111  std::function<std::vector<double>()> m_pfGetTranslation;
112 
113  std::function<void(const std::vector<double> &, bool)> m_pfScale1;
114  std::function<void(double, bool)> m_pfScale2;
115  std::function<void(int, int, double, bool)> m_pfShear;
116  std::function<void(const std::vector<double> &, bool)> m_pfTranslate;
117  std::function<void(int, int, double, bool)> m_pfRotate;
118 
119 };
120 
121 }
122 
123 #endif // sitkAffineTransform_h
itk::simple::AffineTransform::m_pfGetMatrix
std::function< std::vector< double >)> m_pfGetMatrix
Definition: sitkAffineTransform.h:109
itk::simple::Transform
A simplified wrapper around a variety of ITK transforms.
Definition: sitkTransform.h:81
itk::simple::AffineTransform::m_pfGetCenter
std::function< std::vector< double >)> m_pfGetCenter
Definition: sitkAffineTransform.h:107
itk::simple::AffineTransform::m_pfRotate
std::function< void(int, int, double, bool)> m_pfRotate
Definition: sitkAffineTransform.h:117
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:115
itk::simple::AffineTransform::m_pfSetMatrix
std::function< void(const std::vector< double > &)> m_pfSetMatrix
Definition: sitkAffineTransform.h:108
itk::simple::AffineTransform::m_pfTranslate
std::function< void(const std::vector< double > &, bool)> m_pfTranslate
Definition: sitkAffineTransform.h:116
itk::simple::AffineTransform::MyVisitor::that
AffineTransform * that
Definition: sitkAffineTransform.h:88
SITKCommon_EXPORT
#define SITKCommon_EXPORT
Definition: sitkCommon.h:41
itk::simple::AffineTransform::MyVisitor::transform
itk::TransformBase * transform
Definition: sitkAffineTransform.h:87
itk::simple::AffineTransform::m_pfScale1
std::function< void(const std::vector< double > &, bool)> m_pfScale1
Definition: sitkAffineTransform.h:113
itk::simple::AffineTransform::m_pfScale2
std::function< void(double, bool)> m_pfScale2
Definition: sitkAffineTransform.h:114
itk::simple::AffineTransform::m_pfSetCenter
std::function< void(const std::vector< double > &)> m_pfSetCenter
Definition: sitkAffineTransform.h:106
sitkTransform.h
itk::simple::AffineTransform::m_pfSetTranslation
std::function< void(const std::vector< double > &)> m_pfSetTranslation
Definition: sitkAffineTransform.h:110
itk::simple::AffineTransform::MyVisitor
Definition: sitkAffineTransform.h:85
itk::simple::AffineTransform::GetName
std::string GetName() const override
Definition: sitkAffineTransform.h:56
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:111
itk::TransformBaseTemplate
Definition: sitkTransform.h:30