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 
26 namespace itk
27 {
28 
29 
30 template <typename TParametersValueType, unsigned int NInputDimensions, unsigned int NOutputDimensions>
31 class Transform;
32 
33 namespace simple
34 {
35 
59 {
60 public:
63 
69  explicit CompositeTransform(unsigned int dimensions);
70 
79 
86 
96  explicit CompositeTransform(const std::vector<itk::simple::Transform> &);
97 
98  ~CompositeTransform() override;
99 
101  operator=(const CompositeTransform &);
102 
104  std::string
105  GetName() const override
106  {
107  return std::string("CompositeTransform");
108  }
109 
110 
120  SITK_RETURN_SELF_TYPE_HEADER
121  FlattenTransform();
122 
129  SITK_RETURN_SELF_TYPE_HEADER
130  AddTransform(Transform t);
131 
133  unsigned int
134  GetNumberOfTransforms() const;
135 
137  void
138  ClearTransforms();
139 
144  void
145  RemoveTransform();
146 
151  Transform
152  GetBackTransform();
153 
159  Transform
160  GetNthTransform(unsigned int n);
161 
162 protected:
163  void
164  SetPimpleTransform(std::unique_ptr<PimpleTransformBase> &&) override;
165 
166 private:
167  struct MyVisitor
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
186  InternalInitialization(itk::TransformBase * transform);
187 
188  template <unsigned int NDimension>
189  void
190  InternalInitialization(itk::CompositeTransform<double, NDimension> *);
191 
192  template <unsigned int NDimensions>
193  void
194  InternalInitialization(itk::Transform<double, NDimensions, NDimensions> *);
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
itk::simple::CompositeTransform::m_pfGetNumberOfTransforms
std::function< unsigned int()> m_pfGetNumberOfTransforms
Definition: sitkCompositeTransform.h:201
itk::CompositeTransform
Definition: sitkTransform.h:37
itk::simple::CompositeTransform::m_pfFlattenTransform
std::function< void()> m_pfFlattenTransform
Definition: sitkCompositeTransform.h:196
itk::simple::CompositeTransform::m_pfBackTransform
std::function< Transform()> m_pfBackTransform
Definition: sitkCompositeTransform.h:199
itk::simple::Transform
A simplified wrapper around a variety of ITK transforms.
Definition: sitkTransform.h:86
sitkCommon.h
itk::simple::CompositeTransform::MyVisitor
Definition: sitkCompositeTransform.h:167
itk::simple::CompositeTransform::MyVisitor::that
CompositeTransform * that
Definition: sitkCompositeTransform.h:170
itk::simple::CompositeTransform::m_pfAddTransform
std::function< void(Transform &)> m_pfAddTransform
Definition: sitkCompositeTransform.h:197
itk::simple::CompositeTransform::m_pfGetNthTransform
std::function< Transform(unsigned int)> m_pfGetNthTransform
Definition: sitkCompositeTransform.h:200
SITKCommon_EXPORT
#define SITKCommon_EXPORT
Definition: sitkCommon.h:41
itk::simple::CompositeTransform::m_pfRemoveTransform
std::function< void()> m_pfRemoveTransform
Definition: sitkCompositeTransform.h:198
itk::simple::CompositeTransform::MyVisitor::operator()
void operator()()
Definition: sitkCompositeTransform.h:173
itk::simple::CompositeTransform::GetName
std::string GetName() const override
Definition: sitkCompositeTransform.h:105
itk::simple::CompositeTransform
This class contains a stack of transforms and concatenates them by composition.
Definition: sitkCompositeTransform.h:58
sitkTransform.h
itk
itk::Transform
Definition: sitkCompositeTransform.h:31
itk::simple::CompositeTransform::m_pfClearTransformQueue
std::function< void()> m_pfClearTransformQueue
Definition: sitkCompositeTransform.h:202
itk::TransformBaseTemplate
Definition: sitkTransform.h:32
itk::simple::CompositeTransform::InternalInitialization
void InternalInitialization(itk::TransformBase *transform)
itk::simple::CompositeTransform::MyVisitor::transform
itk::TransformBase * transform
Definition: sitkCompositeTransform.h:169