ITK  5.4.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  * https://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, unsigned int VDimension = 3, unsigned int VSubDimensions = VDimension>
63 class ITK_TEMPLATE_EXPORT MultiTransform : public Transform<TParametersValueType, VDimension, VSubDimensions>
64 {
65 public:
66  ITK_DISALLOW_COPY_AND_MOVE(MultiTransform);
67 
73 
76 
80 
81  /* Types common to both container and sub transforms */
82 
84  using typename Superclass::ParametersType;
85  using typename Superclass::ParametersValueType;
86  using typename Superclass::FixedParametersType;
87  using typename Superclass::FixedParametersValueType;
89 
91  using typename Superclass::DerivativeType;
92 
94  using typename Superclass::JacobianType;
95  using typename Superclass::JacobianPositionType;
96  using typename Superclass::InverseJacobianPositionType;
97 
99  using typename Superclass::TransformCategoryEnum;
100 
101  /* Types relative to the container transform. */
102 
104  using typename Superclass::InverseTransformBasePointer;
105 
107  using typename Superclass::InputPointType;
108  using typename Superclass::OutputPointType;
109 
111  using typename Superclass::InputVectorType;
112  using typename Superclass::OutputVectorType;
113 
115  using typename Superclass::InputCovariantVectorType;
116  using typename Superclass::OutputCovariantVectorType;
117 
119  using typename Superclass::InputVnlVectorType;
120  using typename Superclass::OutputVnlVectorType;
121 
123  using typename Superclass::InputVectorPixelType;
124  using typename Superclass::OutputVectorPixelType;
125 
127  using typename Superclass::InputDiffusionTensor3DType;
128  using typename Superclass::OutputDiffusionTensor3DType;
129 
131  using typename Superclass::InputSymmetricSecondRankTensorType;
132  using typename Superclass::OutputSymmetricSecondRankTensorType;
133 
134  /* Types relative to the sub transform type. */
135 
138 
140  using TransformQueueType = std::deque<TransformTypePointer>;
141 
143  using typename Superclass::NumberOfParametersType;
144 
146  static constexpr unsigned int InputDimension = VDimension;
147  static constexpr unsigned int OutputDimension = VDimension;
148 
149  static constexpr unsigned int SubInputDimension = VSubDimensions;
150  static constexpr unsigned int SubOutputDimension = VSubDimensions;
151 
157  virtual void
159  {
160  this->PushBackTransform(t);
161  }
162 
164  virtual void
166  {
167  this->AddTransform(t);
168  }
169 
171  virtual void
173  {
174  this->PushFrontTransform(t);
175  }
176 
178  virtual void
180  {
181  this->PopBackTransform();
182  }
183 
185  virtual const TransformType *
187  {
188  return this->m_TransformQueue.front().GetPointer();
189  }
190 
191  virtual const TransformType *
193  {
194  return this->m_TransformQueue.back().GetPointer();
195  }
196 
197  virtual const TransformTypePointer
199  {
200  // NOTE: By returning a smart pointer type, the use of this function can
201  // be a significant bottleneck in multithreaded applications.
202  return this->m_TransformQueue[n];
203  }
204 
207  virtual TransformType *
209  {
210  return this->m_TransformQueue[n].GetPointer();
211  }
212 
213  virtual const TransformType *
215  {
216  return this->m_TransformQueue[n].GetPointer();
217  }
218 
220  virtual const TransformQueueType &
222  {
223  return this->m_TransformQueue;
224  }
225 
227  virtual bool
229  {
230  return this->m_TransformQueue.empty();
231  }
232 
234  virtual SizeValueType
236  {
237  return static_cast<SizeValueType>(this->m_TransformQueue.size());
238  }
239 
241  virtual void
243  {
244  this->m_TransformQueue.clear();
245  this->Modified();
246  }
250  bool
251  IsLinear() const override;
252 
255  TransformCategoryEnum
256  GetTransformCategory() const override;
257 
265  const ParametersType &
266  GetParameters() const override;
267 
268  /* SetParameters for all sub-transforms.
269  * See GetParameters() for parameter ordering. */
270  void
271  SetParameters(const ParametersType & inputParameters) override;
272 
273  /* GetFixedParameters for all sub-transforms.
274  * See GetParameters() for parameter ordering. */
275  const FixedParametersType &
276  GetFixedParameters() const override;
277 
278  /* SetFixedParameters for all sub-transforms.
279  * See GetParameters() for parameter ordering. */
280  void
281  SetFixedParameters(const FixedParametersType & inputParameters) override;
282 
283  /* Get total number of parameters. Sum of all sub-transforms. */
284  NumberOfParametersType
285  GetNumberOfParameters() const override;
286 
287  /* Get total number of local parameters, the sum of all sub-transforms. */
288  NumberOfParametersType
289  GetNumberOfLocalParameters() const override;
290 
291  /* Get total number of fixed parameters, the sum of all sub-transforms. */
292  NumberOfParametersType
293  GetNumberOfFixedParameters() const override;
294 
297  void
298  UpdateTransformParameters(const DerivativeType & update, ScalarType factor = 1.0) override;
299 
305  bool
306  GetInverse(Self * inverse) const;
307 
309  // TODO - what do we need here?
310  // virtual void FlattenTransformQueue();
311 
312 protected:
313  MultiTransform() = default;
314  ~MultiTransform() override = default;
315  void
316  PrintSelf(std::ostream & os, Indent indent) const override;
317 
318  virtual void
320  {
321  this->m_TransformQueue.push_front(t);
322  this->Modified();
323  }
324 
325  virtual void
327  {
328  this->m_TransformQueue.push_back(t);
329  this->Modified();
330  }
331 
332  virtual void
334  {
335  this->m_TransformQueue.pop_front();
336  this->Modified();
337  }
338 
339  virtual void
341  {
342  this->m_TransformQueue.pop_back();
343  this->Modified();
344  }
345 
347  mutable TransformQueueType m_TransformQueue{};
348 
350  mutable NumberOfParametersType m_NumberOfLocalParameters{};
351  mutable ModifiedTimeType m_LocalParametersUpdateTime{};
352 };
353 
354 } // end namespace itk
355 
356 #ifndef ITK_MANUAL_INSTANTIATION
357 # include "itkMultiTransform.hxx"
358 #endif
359 
360 #endif // itkMultiTransform_h
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::MultiTransform::PopFrontTransform
virtual void PopFrontTransform()
Definition: itkMultiTransform.h:333
itk::ModifiedTimeType
SizeValueType ModifiedTimeType
Definition: itkIntTypes.h:102
itk::MultiTransform::GetTransformQueue
virtual const TransformQueueType & GetTransformQueue() const
Definition: itkMultiTransform.h:221
itk::MultiTransform::PushFrontTransform
virtual void PushFrontTransform(TransformTypePointer t)
Definition: itkMultiTransform.h:319
itk::Transform::InverseTransformBasePointer
typename InverseTransformBaseType::Pointer InverseTransformBasePointer
Definition: itkTransform.h:181
itk::MultiTransform::GetNumberOfTransforms
virtual SizeValueType GetNumberOfTransforms() const
Definition: itkMultiTransform.h:235
itk::MultiTransform::GetFrontTransform
virtual const TransformType * GetFrontTransform() const
Definition: itkMultiTransform.h:186
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::MultiTransform::GetNthTransform
virtual const TransformTypePointer GetNthTransform(SizeValueType n) const
Definition: itkMultiTransform.h:198
itk::MultiTransform::GetBackTransform
virtual const TransformType * GetBackTransform() const
Definition: itkMultiTransform.h:192
itk::MultiTransform::AddTransform
virtual void AddTransform(TransformType *t)
Definition: itkMultiTransform.h:158
itk::MultiTransform::ClearTransformQueue
virtual void ClearTransformQueue()
Definition: itkMultiTransform.h:242
itk::MultiTransform
This abstract class contains a list of transforms and provides basic methods.
Definition: itkMultiTransform.h:63
itk::MultiTransform::GetNthTransformModifiablePointer
virtual TransformType * GetNthTransformModifiablePointer(const SizeValueType n) const
Definition: itkMultiTransform.h:208
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::MultiTransform< TParametersValueType, VDimension, VDimension >::TransformTypePointer
typename TransformType::Pointer TransformTypePointer
Definition: itkMultiTransform.h:79
itk::MultiTransform::PopBackTransform
virtual void PopBackTransform()
Definition: itkMultiTransform.h:340
itkOverrideGetNameOfClassMacro
itkOverrideGetNameOfClassMacro(AddImageFilter)
itk::MultiTransform::RemoveTransform
virtual void RemoveTransform()
Definition: itkMultiTransform.h:179
itk::MultiTransform::PrependTransform
virtual void PrependTransform(TransformType *t)
Definition: itkMultiTransform.h:172
itk::MultiTransform< TParametersValueType, VDimension, VDimension >::TransformQueueType
std::deque< TransformTypePointer > TransformQueueType
Definition: itkMultiTransform.h:140
itk::MultiTransform::IsTransformQueueEmpty
virtual bool IsTransformQueueEmpty() const
Definition: itkMultiTransform.h:228
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::MultiTransform< TParametersValueType, VDimension, VDimension >::ScalarType
ParametersValueType ScalarType
Definition: itkMultiTransform.h:88
itk::MultiTransform::PushBackTransform
virtual void PushBackTransform(TransformTypePointer t)
Definition: itkMultiTransform.h:326
itk::TransformBaseTemplate::ParametersValueType
TParametersValueType ParametersValueType
Definition: itkTransformBase.h:81
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:83
AddImageFilter
Definition: itkAddImageFilter.h:81
itk::MultiTransform< TParametersValueType, VDimension, VDimension >::SubTransformInverseTransformBasePointer
typename TransformType::InverseTransformBasePointer SubTransformInverseTransformBasePointer
Definition: itkMultiTransform.h:137
itkTransform.h
itk::MultiTransform::GetNthTransformConstPointer
virtual const TransformType * GetNthTransformConstPointer(const SizeValueType n) const
Definition: itkMultiTransform.h:214
itk::MultiTransform::AppendTransform
virtual void AppendTransform(TransformType *t)
Definition: itkMultiTransform.h:165
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83