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