SimpleITK  2.1.0.dev245
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  : public Transform {
60 public:
63 
69  explicit CompositeTransform(unsigned int dimensions);
70 
78  CompositeTransform( const Transform & );
79 
86 
96  explicit CompositeTransform(const std::vector<itk::simple::Transform> &);
97 
98  ~CompositeTransform() override;
99 
100  CompositeTransform &operator=( const CompositeTransform &);
101 
103  std::string GetName( ) const override { return std::string("CompositeTransform");}
104 
105 
115  SITK_RETURN_SELF_TYPE_HEADER FlattenTransform();
116 
123  SITK_RETURN_SELF_TYPE_HEADER AddTransform( Transform t );
124 
126  unsigned int GetNumberOfTransforms() const;
127 
129  void ClearTransforms();
130 
135  void RemoveTransform();
136 
141  Transform GetBackTransform();
142 
148  Transform GetNthTransform(unsigned int n);
149 
150 protected:
151 
152  void SetPimpleTransform( PimpleTransformBase * ) override;
153 
154 private:
155 
156 
157  struct MyVisitor
158  {
161  template< typename TransformType >
162  void operator() ( )
163  {
164  TransformType *t = dynamic_cast<TransformType*>(transform);
165  if (t)
166  {
167  that->InternalInitialization(t);
168  // set to null to stop trying dynamic_cast
169  transform = nullptr;
170  }
171  }
172  };
173 
174  void InternalInitialization(itk::TransformBase *transform);
175 
176  template<unsigned int NDimension>
177  void InternalInitialization(itk::CompositeTransform< double, NDimension > *);
178 
179  template <unsigned int NDimensions>
180  void InternalInitialization(itk::Transform<double, NDimensions, NDimensions> *);
181 
182  std::function<void ()> m_pfFlattenTransform;
183  std::function<void ( Transform & )> m_pfAddTransform;
184  std::function<void ()> m_pfRemoveTransform;
185  std::function<Transform ()> m_pfBackTransform;
186  std::function<Transform (unsigned int)> m_pfGetNthTransform;
187  std::function<unsigned int ()> m_pfGetNumberOfTransforms;
188  std::function<void ()> m_pfClearTransformQueue;
189 };
190 
191 }
192 }
193 
194 #endif // sitkCompositeTransform_h
itk::CompositeTransform
Definition: sitkTransform.h:34
itk::simple::CompositeTransform::m_pfAddTransform
std::function< void(Transform &)> m_pfAddTransform
Definition: sitkCompositeTransform.h:183
itk::simple::Transform
A simplified wrapper around a variety of ITK transforms.
Definition: sitkTransform.h:81
itk::simple::CompositeTransform::m_pfGetNumberOfTransforms
std::function< unsigned int()> m_pfGetNumberOfTransforms
Definition: sitkCompositeTransform.h:187
sitkCommon.h
itk::simple::CompositeTransform::m_pfGetNthTransform
std::function< Transform(unsigned int)> m_pfGetNthTransform
Definition: sitkCompositeTransform.h:186
itk::simple::CompositeTransform::MyVisitor
Definition: sitkCompositeTransform.h:157
itk::simple::CompositeTransform::MyVisitor::that
CompositeTransform * that
Definition: sitkCompositeTransform.h:160
SITKCommon_EXPORT
#define SITKCommon_EXPORT
Definition: sitkCommon.h:41
itk::simple::CompositeTransform::m_pfClearTransformQueue
std::function< void()> m_pfClearTransformQueue
Definition: sitkCompositeTransform.h:188
itk::simple::CompositeTransform::GetName
std::string GetName() const override
Definition: sitkCompositeTransform.h:103
itk::simple::CompositeTransform
This class contains a stack of transforms and concatenates them by composition.
Definition: sitkCompositeTransform.h:58
sitkTransform.h
itk
itk::simple::CompositeTransform::m_pfFlattenTransform
std::function< void()> m_pfFlattenTransform
Definition: sitkCompositeTransform.h:182
itk::Transform
Definition: sitkCompositeTransform.h:31
itk::simple::CompositeTransform::m_pfRemoveTransform
std::function< void()> m_pfRemoveTransform
Definition: sitkCompositeTransform.h:184
itk::simple::CompositeTransform::m_pfBackTransform
std::function< Transform()> m_pfBackTransform
Definition: sitkCompositeTransform.h:185
itk::TransformBaseTemplate
Definition: sitkTransform.h:30
itk::simple::CompositeTransform::InternalInitialization
void InternalInitialization(itk::TransformBase *transform)
itk::simple::CompositeTransform::MyVisitor::transform
itk::TransformBase * transform
Definition: sitkCompositeTransform.h:159