ITK  5.2.0
Insight Toolkit
itkMultiTransform.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 itkMultiTransform_h
19 #define itkMultiTransform_h
20 
21 #include "itkTransform.h"
22 
23 #include <deque>
24 
25 namespace itk
26 {
27 
62 template <typename TParametersValueType = double,
63  unsigned int NDimensions = 3,
64  unsigned int NSubDimensions = NDimensions>
65 class ITK_TEMPLATE_EXPORT MultiTransform : public Transform<TParametersValueType, NDimensions, NSubDimensions>
66 {
67 public:
68  ITK_DISALLOW_COPY_AND_MOVE(MultiTransform);
69 
75 
77  itkTypeMacro(MultiTransform, Transform);
78 
82 
83  /* Types common to both container and sub transforms */
84 
86  using ParametersType = typename Superclass::ParametersType;
87  using ParametersValueType = typename Superclass::ParametersValueType;
88  using FixedParametersType = typename Superclass::FixedParametersType;
89  using FixedParametersValueType = typename Superclass::FixedParametersValueType;
91 
93  using DerivativeType = typename Superclass::DerivativeType;
94 
96  using JacobianType = typename Superclass::JacobianType;
97  using JacobianPositionType = typename Superclass::JacobianPositionType;
98  using InverseJacobianPositionType = typename Superclass::InverseJacobianPositionType;
99 
101  using TransformCategoryEnum = typename Superclass::TransformCategoryEnum;
102 
103  /* Types relative to the container transform. */
104 
106  using InverseTransformBasePointer = typename Superclass::InverseTransformBasePointer;
107 
109  using InputPointType = typename Superclass::InputPointType;
110  using OutputPointType = typename Superclass::OutputPointType;
111 
113  using InputVectorType = typename Superclass::InputVectorType;
114  using OutputVectorType = typename Superclass::OutputVectorType;
115 
117  using InputCovariantVectorType = typename Superclass::InputCovariantVectorType;
118  using OutputCovariantVectorType = typename Superclass::OutputCovariantVectorType;
119 
121  using InputVnlVectorType = typename Superclass::InputVnlVectorType;
122  using OutputVnlVectorType = typename Superclass::OutputVnlVectorType;
123 
125  using InputVectorPixelType = typename Superclass::InputVectorPixelType;
126  using OutputVectorPixelType = typename Superclass::OutputVectorPixelType;
127 
129  using InputDiffusionTensor3DType = typename Superclass::InputDiffusionTensor3DType;
130  using OutputDiffusionTensor3DType = typename Superclass::OutputDiffusionTensor3DType;
131 
133  using InputSymmetricSecondRankTensorType = typename Superclass::InputSymmetricSecondRankTensorType;
134  using OutputSymmetricSecondRankTensorType = typename Superclass::OutputSymmetricSecondRankTensorType;
135 
136  /* Types relative to the sub transform type. */
137 
140 
142  using TransformQueueType = std::deque<TransformTypePointer>;
143 
145  using NumberOfParametersType = typename Superclass::NumberOfParametersType;
146 
148  static constexpr unsigned int InputDimension = NDimensions;
149  static constexpr unsigned int OutputDimension = NDimensions;
150 
151  static constexpr unsigned int SubInputDimension = NSubDimensions;
152  static constexpr unsigned int SubOutputDimension = NSubDimensions;
153 
159  virtual void
161  {
162  this->PushBackTransform(t);
163  }
164 
166  virtual void
168  {
169  this->AddTransform(t);
170  }
171 
173  virtual void
175  {
176  this->PushFrontTransform(t);
177  }
178 
180  virtual void
182  {
183  this->PopBackTransform();
184  }
185 
187  virtual const TransformType *
189  {
190  return this->m_TransformQueue.front().GetPointer();
191  }
192 
193  virtual const TransformType *
195  {
196  return this->m_TransformQueue.back().GetPointer();
197  }
198 
199  virtual const TransformTypePointer
201  {
202  // NOTE: By returning a smart pointer type, the use of this function can
203  // be a significant bottleneck in multithreaded applications.
204  return this->m_TransformQueue[n];
205  }
206 
209  virtual TransformType *
211  {
212  return this->m_TransformQueue[n].GetPointer();
213  }
214 
215  virtual const TransformType *
217  {
218  return this->m_TransformQueue[n].GetPointer();
219  }
220 
222  virtual const TransformQueueType &
224  {
225  return this->m_TransformQueue;
226  }
227 
229  virtual bool
231  {
232  return this->m_TransformQueue.empty();
233  }
234 
236  virtual SizeValueType
238  {
239  return static_cast<SizeValueType>(this->m_TransformQueue.size());
240  }
241 
243  virtual void
245  {
246  this->m_TransformQueue.clear();
247  this->Modified();
248  }
250 
252  bool
253  IsLinear() const override;
254 
257  TransformCategoryEnum
258  GetTransformCategory() const override;
259 
267  const ParametersType &
268  GetParameters() const override;
269 
270  /* SetParameters for all sub-transforms.
271  * See GetParameters() for parameter ordering. */
272  void
273  SetParameters(const ParametersType & p) override;
274 
275  /* GetFixedParameters for all sub-transforms.
276  * See GetParameters() for parameter ordering. */
277  const FixedParametersType &
278  GetFixedParameters() const override;
279 
280  /* SetFixedParameters for all sub-transforms.
281  * See GetParameters() for parameter ordering. */
282  void
283  SetFixedParameters(const FixedParametersType & fixedParameters) override;
284 
285  /* Get total number of parameters. Sum of all sub-transforms. */
286  NumberOfParametersType
287  GetNumberOfParameters() const override;
288 
289  /* Get total number of local parameters, the sum of all sub-transforms. */
290  NumberOfParametersType
291  GetNumberOfLocalParameters() const override;
292 
293  /* Get total number of fixed parameters, the sum of all sub-transforms. */
294  NumberOfParametersType
295  GetNumberOfFixedParameters() const override;
296 
299  void
300  UpdateTransformParameters(const DerivativeType & update, ScalarType factor = 1.0) override;
301 
307  bool
308  GetInverse(Self * inverse) const;
309 
311  // TODO - what do we need here?
312  // virtual void FlattenTransformQueue();
313 
314 protected:
315  MultiTransform();
316  ~MultiTransform() override = default;
317  void
318  PrintSelf(std::ostream & os, Indent indent) const override;
319 
320  virtual void
322  {
323  this->m_TransformQueue.push_front(t);
324  this->Modified();
325  }
326 
327  virtual void
329  {
330  this->m_TransformQueue.push_back(t);
331  this->Modified();
332  }
333 
334  virtual void
336  {
337  this->m_TransformQueue.pop_front();
338  this->Modified();
339  }
340 
341  virtual void
343  {
344  this->m_TransformQueue.pop_back();
345  this->Modified();
346  }
347 
350 
354 };
355 
356 } // end namespace itk
357 
358 #ifndef ITK_MANUAL_INSTANTIATION
359 # include "itkMultiTransform.hxx"
360 #endif
361 
362 #endif // itkMultiTransform_h
itk::MultiTransform::RemoveTransform
virtual void RemoveTransform()
Definition: itkMultiTransform.h:181
itk::MultiTransform::PushFrontTransform
virtual void PushFrontTransform(TransformTypePointer t)
Definition: itkMultiTransform.h:321
itk::MultiTransform::m_NumberOfLocalParameters
NumberOfParametersType m_NumberOfLocalParameters
Definition: itkMultiTransform.h:352
itk::MultiTransform::AppendTransform
virtual void AppendTransform(TransformType *t)
Definition: itkMultiTransform.h:167
itk::OptimizerParameters
Class to hold and manage different parameter types used during optimization.
Definition: itkOptimizerParameters.h:34
itk::MultiTransform< TParametersValueType, NDimensions, NDimensions >::ScalarType
ParametersValueType ScalarType
Definition: itkMultiTransform.h:90
itk::MultiTransform::GetNthTransform
virtual const TransformTypePointer GetNthTransform(SizeValueType n) const
Definition: itkMultiTransform.h:200
itk::ModifiedTimeType
SizeValueType ModifiedTimeType
Definition: itkIntTypes.h:102
itk::MultiTransform::IsTransformQueueEmpty
virtual bool IsTransformQueueEmpty() const
Definition: itkMultiTransform.h:230
itk::MultiTransform::GetNumberOfTransforms
virtual SizeValueType GetNumberOfTransforms() const
Definition: itkMultiTransform.h:237
itk::MultiTransform< TParametersValueType, NDimensions, NDimensions >::DerivativeType
typename Superclass::DerivativeType DerivativeType
Definition: itkMultiTransform.h:93
itk::MultiTransform< TParametersValueType, NDimensions, NDimensions >::InverseJacobianPositionType
typename Superclass::InverseJacobianPositionType InverseJacobianPositionType
Definition: itkMultiTransform.h:98
itk::MultiTransform< TParametersValueType, NDimensions, NDimensions >::InputSymmetricSecondRankTensorType
typename Superclass::InputSymmetricSecondRankTensorType InputSymmetricSecondRankTensorType
Definition: itkMultiTransform.h:133
itk::MultiTransform::GetBackTransform
virtual const TransformType * GetBackTransform() const
Definition: itkMultiTransform.h:194
itk::MultiTransform::PushBackTransform
virtual void PushBackTransform(TransformTypePointer t)
Definition: itkMultiTransform.h:328
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::MultiTransform< TParametersValueType, NDimensions, NDimensions >::JacobianPositionType
typename Superclass::JacobianPositionType JacobianPositionType
Definition: itkMultiTransform.h:97
itk::MultiTransform::m_TransformQueue
TransformQueueType m_TransformQueue
Definition: itkMultiTransform.h:349
itk::MultiTransform
This abstract class contains a list of transforms and provides basic methods.
Definition: itkMultiTransform.h:65
itk::MultiTransform< TParametersValueType, NDimensions, NDimensions >::InputVectorPixelType
typename Superclass::InputVectorPixelType InputVectorPixelType
Definition: itkMultiTransform.h:125
itk::MultiTransform::PopFrontTransform
virtual void PopFrontTransform()
Definition: itkMultiTransform.h:335
itk::MultiTransform::PrependTransform
virtual void PrependTransform(TransformType *t)
Definition: itkMultiTransform.h:174
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::MultiTransform::m_LocalParametersUpdateTime
ModifiedTimeType m_LocalParametersUpdateTime
Definition: itkMultiTransform.h:353
itk::MultiTransform::GetNthTransformModifiablePointer
virtual TransformType * GetNthTransformModifiablePointer(const SizeValueType n) const
Definition: itkMultiTransform.h:210
itk::MultiTransform::GetFrontTransform
virtual const TransformType * GetFrontTransform() const
Definition: itkMultiTransform.h:188
itk::MultiTransform< TParametersValueType, NDimensions, NDimensions >::InputVectorType
typename Superclass::InputVectorType InputVectorType
Definition: itkMultiTransform.h:113
itk::MultiTransform< TParametersValueType, NDimensions, NDimensions >::InputVnlVectorType
typename Superclass::InputVnlVectorType InputVnlVectorType
Definition: itkMultiTransform.h:121
itk::MultiTransform::GetNthTransformConstPointer
virtual const TransformType * GetNthTransformConstPointer(const SizeValueType n) const
Definition: itkMultiTransform.h:216
itk::MultiTransform::ClearTransformQueue
virtual void ClearTransformQueue()
Definition: itkMultiTransform.h:244
itk::MultiTransform< TParametersValueType, NDimensions, NDimensions >::InputCovariantVectorType
typename Superclass::InputCovariantVectorType InputCovariantVectorType
Definition: itkMultiTransform.h:117
itk::TransformBaseTemplateEnums::TransformCategory
TransformCategory
Definition: itkTransformBase.h:45
itk::TransformBaseTemplate::FixedParametersValueType
double FixedParametersValueType
Definition: itkTransformBase.h:83
itk::MultiTransform::AddTransform
virtual void AddTransform(TransformType *t)
Definition: itkMultiTransform.h:160
itk::MultiTransform< TParametersValueType, NDimensions, NDimensions >::InverseTransformBasePointer
typename Superclass::InverseTransformBasePointer InverseTransformBasePointer
Definition: itkMultiTransform.h:106
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::MultiTransform< TParametersValueType, NDimensions, NDimensions >::TransformQueueType
std::deque< TransformTypePointer > TransformQueueType
Definition: itkMultiTransform.h:142
itk::MultiTransform::GetTransformQueue
virtual const TransformQueueType & GetTransformQueue() const
Definition: itkMultiTransform.h:223
itk::MultiTransform< TParametersValueType, NDimensions, NDimensions >::InputDiffusionTensor3DType
typename Superclass::InputDiffusionTensor3DType InputDiffusionTensor3DType
Definition: itkMultiTransform.h:129
itk::MultiTransform< TParametersValueType, NDimensions, NDimensions >::OutputCovariantVectorType
typename Superclass::OutputCovariantVectorType OutputCovariantVectorType
Definition: itkMultiTransform.h:118
itk::MultiTransform< TParametersValueType, NDimensions, NDimensions >::OutputVectorType
typename Superclass::OutputVectorType OutputVectorType
Definition: itkMultiTransform.h:114
itk::MultiTransform< TParametersValueType, NDimensions, NDimensions >::OutputSymmetricSecondRankTensorType
typename Superclass::OutputSymmetricSecondRankTensorType OutputSymmetricSecondRankTensorType
Definition: itkMultiTransform.h:134
itk::TransformBaseTemplate::ParametersValueType
TParametersValueType ParametersValueType
Definition: itkTransformBase.h:81
itk::MultiTransform< TParametersValueType, NDimensions, NDimensions >::InputPointType
typename Superclass::InputPointType InputPointType
Definition: itkMultiTransform.h:109
itk::MultiTransform< TParametersValueType, NDimensions, NDimensions >::OutputVnlVectorType
typename Superclass::OutputVnlVectorType OutputVnlVectorType
Definition: itkMultiTransform.h:122
itk::MultiTransform< TParametersValueType, NDimensions, NDimensions >::OutputDiffusionTensor3DType
typename Superclass::OutputDiffusionTensor3DType OutputDiffusionTensor3DType
Definition: itkMultiTransform.h:130
itk::TransformBaseTemplate::NumberOfParametersType
IdentifierType NumberOfParametersType
Definition: itkTransformBase.h:91
itk::Transform
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:82
itkTransform.h
itk::MultiTransform< TParametersValueType, NDimensions, NDimensions >::JacobianType
typename Superclass::JacobianType JacobianType
Definition: itkMultiTransform.h:96
itk::Transform::InverseTransformBasePointer
typename InverseTransformBaseType::Pointer InverseTransformBasePointer
Definition: itkTransform.h:166
itk::MultiTransform< TParametersValueType, NDimensions, NDimensions >::OutputPointType
typename Superclass::OutputPointType OutputPointType
Definition: itkMultiTransform.h:110
itk::MultiTransform::PopBackTransform
virtual void PopBackTransform()
Definition: itkMultiTransform.h:342
itk::MultiTransform< TParametersValueType, NDimensions, NDimensions >::OutputVectorPixelType
typename Superclass::OutputVectorPixelType OutputVectorPixelType
Definition: itkMultiTransform.h:126
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::MultiTransform< TParametersValueType, NDimensions, NDimensions >::SubTransformInverseTransformBasePointer
typename TransformType::InverseTransformBasePointer SubTransformInverseTransformBasePointer
Definition: itkMultiTransform.h:139
itk::MultiTransform< TParametersValueType, NDimensions, NDimensions >::TransformTypePointer
typename TransformType::Pointer TransformTypePointer
Definition: itkMultiTransform.h:81