SimpleITK  
sitkCompositeTransform.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
19
20#ifndef sitkCompositeTransform_h
21#define sitkCompositeTransform_h
22
23#include "sitkCommon.h"
24#include "sitkTransform.h"
25
26namespace itk
27{
28
29
30template <typename TParametersValueType, unsigned int NInputDimensions, unsigned int NOutputDimensions>
31class Transform;
32
33namespace simple
34{
35
59{
60public:
63
69 explicit CompositeTransform(unsigned int dimensions);
70
79
86
96 explicit CompositeTransform(const std::vector<itk::simple::Transform> &);
97
99
102
104 std::string
105 GetName() const override
106 {
107 return std::string("CompositeTransform");
108 }
109
110
120 SITK_RETURN_SELF_TYPE_HEADER
122
129 SITK_RETURN_SELF_TYPE_HEADER
131
133 unsigned int
135
137 void
139
144 void
146
153
160 GetNthTransform(unsigned int n);
161
162protected:
163 void
164 SetPimpleTransform(std::unique_ptr<PimpleTransformBase> &&) override;
165
166private:
168 {
171 template <typename TransformType>
172 void
174 {
175 TransformType * t = dynamic_cast<TransformType *>(transform);
176 if (t)
177 {
178 that->InternalInitialization(t);
179 // set to null to stop trying dynamic_cast
180 transform = nullptr;
181 }
182 }
183 };
184
185 void
187
188 template <unsigned int NDimension>
189 void
191
192 template <unsigned int NDimensions>
193 void
195
196 std::function<void()> m_pfFlattenTransform;
197 std::function<void(Transform &)> m_pfAddTransform;
198 std::function<void()> m_pfRemoveTransform;
199 std::function<Transform()> m_pfBackTransform;
200 std::function<Transform(unsigned int)> m_pfGetNthTransform;
201 std::function<unsigned int()> m_pfGetNumberOfTransforms;
202 std::function<void()> m_pfClearTransformQueue;
203};
204
205} // namespace simple
206} // namespace itk
207
208#endif // sitkCompositeTransform_h
void ClearTransforms()
Remove all transforms from the stack.
std::function< void(Transform &)> m_pfAddTransform
Self & AddTransform(Transform t)
Add a transform to the back of the stack.
CompositeTransform(unsigned int dimensions)
Construct an empty CompositeTransform.
unsigned int GetNumberOfTransforms() const
The number of transforms in the stack.
std::function< Transform(unsigned int)> m_pfGetNthTransform
void InternalInitialization(itk::Transform< double, NDimensions, NDimensions > *)
CompositeTransform(const std::vector< itk::simple::Transform > &)
Create a composite from a vector of Transform.
CompositeTransform(const Transform &)
Create CompositeTransform converted or holding the transform argument.
Transform GetBackTransform()
Get a copy of the back transform.
Transform GetNthTransform(unsigned int n)
Get a copy of a transform in the stack.
Self & FlattenTransform()
Removes nested composite transforms.
void SetPimpleTransform(std::unique_ptr< PimpleTransformBase > &&) override
std::function< void()> m_pfFlattenTransform
void InternalInitialization(itk::CompositeTransform< double, NDimension > *)
std::function< Transform()> m_pfBackTransform
std::function< void()> m_pfClearTransformQueue
void InternalInitialization(itk::TransformBase *transform)
CompositeTransform & operator=(const CompositeTransform &)
void RemoveTransform()
Remove the active transform at the back.
std::function< unsigned int()> m_pfGetNumberOfTransforms
std::string GetName() const override
CompositeTransform(const CompositeTransform &)
A lazy copy constructor.
Transform()
By default a 3-d identity transform is constructed.
TransformBaseTemplate< double > TransformBase
#define SITKCommon_EXPORT
Definition sitkCommon.h:41