ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkMultiTransform.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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
63 <typename TParametersValueType=double, unsigned int NDimensions=3, unsigned int NSubDimensions=NDimensions>
64 class ITK_TEMPLATE_EXPORT MultiTransform :
65  public Transform<TParametersValueType, NDimensions, NSubDimensions>
66 {
67 public:
68  ITK_DISALLOW_COPY_AND_ASSIGN(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 TransformCategoryType = typename Superclass::TransformCategoryType;
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 AddTransform( TransformType *t )
160  {
161  this->PushBackTransform( t );
162  }
163 
165  virtual void AppendTransform( TransformType *t )
166  {
167  this->AddTransform( t );
168  }
169 
171  virtual void PrependTransform( TransformType *t )
172  {
173  this->PushFrontTransform( t );
174  }
175 
177  virtual void RemoveTransform()
178  {
179  this->PopBackTransform();
180  }
181 
183  virtual const
185  {
186  return this->m_TransformQueue.front().GetPointer();
187  }
188 
189  virtual const
191  {
192  return this->m_TransformQueue.back().GetPointer();
193  }
194 
195  virtual const
197  {
198  //NOTE: By returning a smart pointer type, the use of this function can
199  // be a significant bottleneck in multithreaded applications.
200  return this->m_TransformQueue[n];
201  }
202 
205  virtual
207  {
208  return this->m_TransformQueue[n].GetPointer();
209  }
210 
211  virtual const
213  {
214  return this->m_TransformQueue[n].GetPointer();
215  }
216 
218  virtual const TransformQueueType & GetTransformQueue() const
219  {
220  return this->m_TransformQueue;
221  }
222 
224  virtual bool IsTransformQueueEmpty() const
225  {
226  return this->m_TransformQueue.empty();
227  }
228 
231  {
232  return static_cast<SizeValueType>(this->m_TransformQueue.size());
233  }
234 
236  virtual void ClearTransformQueue()
237  {
238  this->m_TransformQueue.clear();
239  this->Modified();
240  }
242 
244  bool IsLinear() const override;
245 
248  TransformCategoryType GetTransformCategory() const override;
249 
257  const ParametersType & GetParameters() const override;
258 
259  /* SetParameters for all sub-transforms.
260  * See GetParameters() for parameter ordering. */
261  void SetParameters(const ParametersType & p) override;
262 
263  /* GetFixedParameters for all sub-transforms.
264  * See GetParameters() for parameter ordering. */
265  const FixedParametersType & GetFixedParameters() const override;
266 
267  /* SetFixedParameters for all sub-transforms.
268  * See GetParameters() for parameter ordering. */
269  void SetFixedParameters(const FixedParametersType & fixedParameters) override;
270 
271  /* Get total number of parameters. Sum of all sub-transforms. */
272  NumberOfParametersType GetNumberOfParameters() const override;
273 
274  /* Get total number of local parameters, the sum of all sub-transforms. */
275  NumberOfParametersType GetNumberOfLocalParameters() const override;
276 
277  /* Get total number of fixed parameters, the sum of all sub-transforms. */
278  NumberOfParametersType GetNumberOfFixedParameters() const override;
279 
282  void UpdateTransformParameters( const DerivativeType & update, ScalarType factor = 1.0 ) override;
283 
289  bool GetInverse( Self *inverse ) const;
290 
292 //TODO - what do we need here?
293 // virtual void FlattenTransformQueue();
294 
295 protected:
296  MultiTransform();
297  ~MultiTransform() override = default;
298  void PrintSelf( std::ostream& os, Indent indent ) const override;
299 
301  {
302  this->m_TransformQueue.push_front( t );
303  this->Modified();
304  }
305 
307  {
308  this->m_TransformQueue.push_back( t );
309  this->Modified();
310  }
311 
312  virtual void PopFrontTransform()
313  {
314  this->m_TransformQueue.pop_front();
315  this->Modified();
316  }
317 
318  virtual void PopBackTransform()
319  {
320  this->m_TransformQueue.pop_back();
321  this->Modified();
322  }
323 
326 
330 };
331 
332 } // end namespace itk
333 
334 #ifndef ITK_MANUAL_INSTANTIATION
335 #include "itkMultiTransform.hxx"
336 #endif
337 
338 #endif // itkMultiTransform_h
ModifiedTimeType m_LocalParametersUpdateTime
Light weight base class for most itk classes.
virtual TransformType * GetNthTransformModifiablePointer(const SizeValueType n) const
unsigned long SizeValueType
Definition: itkIntTypes.h:83
virtual bool IsTransformQueueEmpty() const
typename Superclass::InputCovariantVectorType InputCovariantVectorType
virtual void PrependTransform(TransformType *t)
virtual void PushFrontTransform(TransformTypePointer t)
virtual void RemoveTransform()
typename TransformType::InverseTransformBasePointer SubTransformInverseTransformBasePointer
virtual const TransformQueueType & GetTransformQueue() const
virtual const TransformType * GetBackTransform() const
typename Superclass::InverseTransformBasePointer InverseTransformBasePointer
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:83
Class to hold and manage different parameter types used during optimization.
virtual void ClearTransformQueue()
typename InverseTransformBaseType::Pointer InverseTransformBasePointer
Definition: itkTransform.h:169
TransformQueueType m_TransformQueue
virtual const TransformType * GetNthTransformConstPointer(const SizeValueType n) const
unsigned long ModifiedTimeType
Definition: itkIntTypes.h:104
virtual void AppendTransform(TransformType *t)
virtual const TransformTypePointer GetNthTransform(SizeValueType n) const
virtual const TransformType * GetFrontTransform() const
NumberOfParametersType m_NumberOfLocalParameters
This abstract class contains a list of transforms and provides basic methods.
typename Superclass::InputDiffusionTensor3DType InputDiffusionTensor3DType
typename Superclass::InverseJacobianPositionType InverseJacobianPositionType
IdentifierType NumberOfParametersType
typename Superclass::OutputDiffusionTensor3DType OutputDiffusionTensor3DType
virtual SizeValueType GetNumberOfTransforms() const
Control indentation during Print() invocation.
Definition: itkIndent.h:49
virtual void PopFrontTransform()
typename Superclass::InputSymmetricSecondRankTensorType InputSymmetricSecondRankTensorType
typename Superclass::OutputCovariantVectorType OutputCovariantVectorType
virtual void AddTransform(TransformType *t)
typename Superclass::OutputSymmetricSecondRankTensorType OutputSymmetricSecondRankTensorType
virtual void PushBackTransform(TransformTypePointer t)
virtual void PopBackTransform()
TParametersValueType ParametersValueType