SimpleITK  1.2.4
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 
36  : public Transform
37 {
38 public:
41 
42  virtual ~AffineTransform();
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 { 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  virtual void SetPimpleTransform( PimpleTransformBase *pimpleTransform );
84 
85 private:
86 
87  using Superclass::AddTransform;
88 
89  struct MyVisitor
90  {
93  template< typename TransformType >
94  void operator() ( void ) const
95  {
96  TransformType *t = dynamic_cast<TransformType*>(transform);
97  if (t && (typeid(*t) == typeid(TransformType)))
98  {
99  that->InternalInitialization<TransformType>(t);
100  }
101  }
102  };
103 
104  void InternalInitialization(itk::TransformBase *transform);
105 
106  template <typename TransformType>
107  void InternalInitialization(TransformType *transform);
108 
109 
110  nsstd::function<void(const std::vector<double>&)> m_pfSetCenter;
111  nsstd::function<std::vector<double>()> m_pfGetCenter;
112  nsstd::function<void(const std::vector<double>&)> m_pfSetMatrix;
113  nsstd::function<std::vector<double>()> m_pfGetMatrix;
114  nsstd::function<void(const std::vector<double>&)> m_pfSetTranslation;
115  nsstd::function<std::vector<double>()> m_pfGetTranslation;
116 
117  nsstd::function<void(const std::vector<double> &, bool)> m_pfScale1;
118  nsstd::function<void(double, bool)> m_pfScale2;
119  nsstd::function<void(int, int, double, bool)> m_pfShear;
120  nsstd::function<void(const std::vector<double> &, bool)> m_pfTranslate;
121  nsstd::function<void(int, int, double, bool)> m_pfRotate;
122 
123 };
124 
125 }
126 }
127 
128 #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:84
nsstd::function< void(int, int, double, bool)> m_pfRotate
#define SITKCommon_EXPORT
Definition: sitkCommon.h:41
void InternalInitialization(itk::TransformBase *transform)