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
24namespace itk::simple
25{
26
34{
35public:
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
54
56 std::string
57 GetName() const override
58 {
59 return std::string("AffineTransform");
60 }
61
63 std::vector<double>
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
94protected:
95 void
96 SetPimpleTransform(std::unique_ptr<PimpleTransformBase> && pimpleTransform) override;
97
98private:
99 struct MyVisitor
100 {
103 template <typename TransformType>
104 void
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
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
void SetPimpleTransform(std::unique_ptr< PimpleTransformBase > &&pimpleTransform) override
std::vector< double > GetMatrix() const
std::string GetName() const override
AffineTransform(unsigned int dimensions)
std::function< void(double, bool)> m_pfScale2
std::function< void(const std::vector< double > &)> m_pfSetTranslation
Self & Translate(const std::vector< double > &offset, bool pre=false)
void InternalInitialization(TransformType *transform)
AffineTransform(const Transform &)
Self & Rotate(int axis1, int axis2, double angle, bool pre=false)
AffineTransform & operator=(const AffineTransform &)
std::function< void(const std::vector< double > &, bool)> m_pfScale1
AffineTransform(const AffineTransform &)
std::vector< double > GetCenter() const
Self & Shear(int axis1, int axis2, double coef, bool pre=false)
std::function< std::vector< double >()> m_pfGetMatrix
std::function< void(const std::vector< double > &)> m_pfSetMatrix
std::function< void(int, int, double, bool)> m_pfRotate
Self & SetTranslation(const std::vector< double > &translation)
void InternalInitialization(itk::TransformBase *transform)
std::function< std::vector< double >()> m_pfGetTranslation
std::vector< double > GetTranslation() const
Self & SetMatrix(const std::vector< double > &matrix)
Self & Scale(double factor, bool pre=false)
std::function< std::vector< double >()> m_pfGetCenter
std::function< void(const std::vector< double > &)> m_pfSetCenter
std::function< void(const std::vector< double > &, bool)> m_pfTranslate
std::function< void(int, int, double, bool)> m_pfShear
Self & Scale(const std::vector< double > &factor, bool pre=false)
AffineTransform(const std::vector< double > &matrix, const std::vector< double > &translation, const std::vector< double > &fixedCenter=std::vector< double >(3, 0.0))
Self & SetCenter(const std::vector< double > &params)
Transform()
By default a 3-d identity transform is constructed.
TransformBaseTemplate< double > TransformBase
#define SITKCommon_EXPORT
Definition sitkCommon.h:41