SimpleITK  1.0.1
sitkAffineTransform.h
Go to the documentation of this file.
1 /*=========================================================================
2 *
3 * Copyright Insight Software Consortium
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 
35  : public Transform
36 {
37 public:
40  explicit AffineTransform(unsigned int dimensions);
41 
43 
44  explicit AffineTransform( const Transform & );
45 
46  AffineTransform( const std::vector< double> &matrix,
47  const std::vector< double> &translation,
48  const std::vector< double> &fixedCenter=std::vector< double >(3, 0.0));
49 
50 
51  AffineTransform &operator=( const AffineTransform & );
52 
54  std::string GetName() const { return std::string ("AffineTransform"); }
55 
57  std::vector<double> GetTranslation( ) const;
58  SITK_RETURN_SELF_TYPE_HEADER SetTranslation( const std::vector<double>& translation);
59 
60  SITK_RETURN_SELF_TYPE_HEADER SetMatrix( const std::vector<double> &matrix);
61  std::vector<double> GetMatrix() const;
62 
64  SITK_RETURN_SELF_TYPE_HEADER SetCenter(const std::vector<double> &params);
65  std::vector<double> GetCenter( ) const;
66 
68  SITK_RETURN_SELF_TYPE_HEADER Scale(const std::vector<double> & factor, bool pre=false);
69  SITK_RETURN_SELF_TYPE_HEADER Scale(double factor, bool pre=false);
70 
71  SITK_RETURN_SELF_TYPE_HEADER Shear(int axis1, int axis2, double coef, bool pre=false);
72 
73  SITK_RETURN_SELF_TYPE_HEADER Translate(const std::vector<double> &offset, bool pre=false);
74 
75  SITK_RETURN_SELF_TYPE_HEADER Rotate(int axis1, int axis2, double angle, bool pre=false);
76 
77 protected:
78 
79  virtual void SetPimpleTransform( PimpleTransformBase *pimpleTransform );
80 
81 private:
82 
83  using Superclass::AddTransform;
84 
85  struct MyVisitor
86  {
89  template< typename TransformType >
90  void operator() ( void ) 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  nsstd::function<void(const std::vector<double>&)> m_pfSetCenter;
107  nsstd::function<std::vector<double>()> m_pfGetCenter;
108  nsstd::function<void(const std::vector<double>&)> m_pfSetMatrix;
109  nsstd::function<std::vector<double>()> m_pfGetMatrix;
110  nsstd::function<void(const std::vector<double>&)> m_pfSetTranslation;
111  nsstd::function<std::vector<double>()> m_pfGetTranslation;
112 
113  nsstd::function<void(const std::vector<double> &, bool)> m_pfScale1;
114  nsstd::function<void(double, bool)> m_pfScale2;
115  nsstd::function<void(int, int, double, bool)> m_pfShear;
116  nsstd::function<void(const std::vector<double> &, bool)> m_pfTranslate;
117  nsstd::function<void(int, int, double, bool)> m_pfRotate;
118 
119 };
120 
121 }
122 }
123 
124 #endif // sitkAffineTransform_h
nsstd::function< void(int, int, double, bool)> m_pfShear
An affine transformation about a fixed center with translation for a 2D or 3D coordinate.
nsstd::function< void(double, bool)> m_pfScale2
A simplified wrapper around a variety of ITK transforms.
Definition: sitkTransform.h:83
nsstd::function< void(int, int, double, bool)> m_pfRotate
#define SITKCommon_EXPORT
Definition: sitkCommon.h:41
void InternalInitialization(itk::TransformBase *transform)