ITK  4.13.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:
73 
75  itkTypeMacro( MultiTransform, Transform );
76 
80 
81  /* Types common to both container and sub transforms */
82 
84  typedef typename Superclass::ParametersType ParametersType;
85  typedef typename Superclass::ParametersValueType ParametersValueType;
86  typedef typename Superclass::FixedParametersType FixedParametersType;
87  typedef typename Superclass::FixedParametersValueType FixedParametersValueType;
89 
91  typedef typename Superclass::DerivativeType DerivativeType;
92 
94  typedef typename Superclass::JacobianType JacobianType;
95 
97  typedef typename Superclass::TransformCategoryType TransformCategoryType;
98 
99  /* Types relative to the container transform. */
100 
102  typedef typename Superclass::InverseTransformBasePointer InverseTransformBasePointer;
103 
105  typedef typename Superclass::InputPointType InputPointType;
106  typedef typename Superclass::OutputPointType OutputPointType;
107 
109  typedef typename Superclass::InputVectorType InputVectorType;
110  typedef typename Superclass::OutputVectorType OutputVectorType;
111 
113  typedef typename Superclass::InputCovariantVectorType InputCovariantVectorType;
114  typedef typename Superclass::OutputCovariantVectorType OutputCovariantVectorType;
115 
117  typedef typename Superclass::InputVnlVectorType InputVnlVectorType;
118  typedef typename Superclass::OutputVnlVectorType OutputVnlVectorType;
119 
121  typedef typename Superclass::InputVectorPixelType InputVectorPixelType;
122  typedef typename Superclass::OutputVectorPixelType OutputVectorPixelType;
123 
125  typedef typename Superclass::InputDiffusionTensor3DType InputDiffusionTensor3DType;
126  typedef typename Superclass::OutputDiffusionTensor3DType OutputDiffusionTensor3DType;
127 
129  typedef typename Superclass::InputSymmetricSecondRankTensorType InputSymmetricSecondRankTensorType;
130  typedef typename Superclass::OutputSymmetricSecondRankTensorType OutputSymmetricSecondRankTensorType;
131 
132  /* Types relative to the sub transform type. */
133 
136 
138  typedef std::deque<TransformTypePointer> TransformQueueType;
139 
141  typedef typename Superclass::NumberOfParametersType NumberOfParametersType;
142 
144  itkStaticConstMacro( InputDimension, unsigned int, NDimensions );
145  itkStaticConstMacro( OutputDimension, unsigned int, NDimensions );
147 
148  itkStaticConstMacro( SubInputDimension, unsigned int, NSubDimensions );
149  itkStaticConstMacro( SubOutputDimension, unsigned int, NSubDimensions );
150 
156  virtual void AddTransform( TransformType *t )
157  {
158  this->PushBackTransform( t );
159  }
160 
162  virtual void AppendTransform( TransformType *t )
163  {
164  this->AddTransform( t );
165  }
166 
168  virtual void PrependTransform( TransformType *t )
169  {
170  this->PushFrontTransform( t );
171  }
172 
174  virtual void RemoveTransform()
175  {
176  this->PopBackTransform();
177  }
178 
180  virtual const
182  {
183  return this->m_TransformQueue.front().GetPointer();
184  }
185 
186  virtual const
188  {
189  return this->m_TransformQueue.back().GetPointer();
190  }
191 
192  virtual const
194  {
195  //NOTE: By returning a smart pointer type, the use of this function can
196  // be a significant bottleneck in multithreaded applications.
197  return this->m_TransformQueue[n];
198  }
199 
202  virtual
204  {
205  return this->m_TransformQueue[n].GetPointer();
206  }
207 
208  virtual const
210  {
211  return this->m_TransformQueue[n].GetPointer();
212  }
213 
215  virtual const TransformQueueType & GetTransformQueue() const
216  {
217  return this->m_TransformQueue;
218  }
219 
221  virtual bool IsTransformQueueEmpty() const
222  {
223  return this->m_TransformQueue.empty();
224  }
225 
228  {
229  return static_cast<SizeValueType>(this->m_TransformQueue.size());
230  }
231 
233  virtual void ClearTransformQueue()
234  {
235  this->m_TransformQueue.clear();
236  this->Modified();
237  }
239 
241  virtual bool IsLinear() const ITK_OVERRIDE;
242 
245  virtual TransformCategoryType GetTransformCategory() const ITK_OVERRIDE;
246 
254  virtual const ParametersType & GetParameters() const ITK_OVERRIDE;
255 
256  /* SetParameters for all sub-transforms.
257  * See GetParameters() for parameter ordering. */
258  virtual void SetParameters(const ParametersType & p) ITK_OVERRIDE;
259 
260  /* GetFixedParameters for all sub-transforms.
261  * See GetParameters() for parameter ordering. */
262  virtual const FixedParametersType & GetFixedParameters() const ITK_OVERRIDE;
263 
264  /* SetFixedParameters for all sub-transforms.
265  * See GetParameters() for parameter ordering. */
266  virtual void SetFixedParameters(const FixedParametersType & fixedParameters) ITK_OVERRIDE;
267 
268  /* Get total number of parameters. Sum of all sub-transforms. */
269  virtual NumberOfParametersType GetNumberOfParameters() const ITK_OVERRIDE;
270 
271  /* Get total number of local parameters, the sum of all sub-transforms. */
272  virtual NumberOfParametersType GetNumberOfLocalParameters() const ITK_OVERRIDE;
273 
274  /* Get total number of fixed parameters, the sum of all sub-transforms. */
275  virtual NumberOfParametersType GetNumberOfFixedParameters() const ITK_OVERRIDE;
276 
279  virtual void UpdateTransformParameters( const DerivativeType & update, ScalarType factor = 1.0 ) ITK_OVERRIDE;
280 
286  bool GetInverse( Self *inverse ) const;
287 
289 //TODO - what do we need here?
290 // virtual void FlattenTransformQueue();
291 
292 protected:
293  MultiTransform();
294  virtual ~MultiTransform() ITK_OVERRIDE;
295  virtual void PrintSelf( std::ostream& os, Indent indent ) const ITK_OVERRIDE;
296 
297  virtual void PushFrontTransform( TransformTypePointer t )
298  {
299  this->m_TransformQueue.push_front( t );
300  this->Modified();
301  }
302 
304  {
305  this->m_TransformQueue.push_back( t );
306  this->Modified();
307  }
308 
309  virtual void PopFrontTransform()
310  {
311  this->m_TransformQueue.pop_front();
312  this->Modified();
313  }
314 
315  virtual void PopBackTransform()
316  {
317  this->m_TransformQueue.pop_back();
318  this->Modified();
319  }
320 
323 
327 
328 private:
329  ITK_DISALLOW_COPY_AND_ASSIGN(MultiTransform);
330 
331 };
332 
333 } // end namespace itk
334 
335 #ifndef ITK_MANUAL_INSTANTIATION
336 #include "itkMultiTransform.hxx"
337 #endif
338 
339 #endif // itkMultiTransform_h
ModifiedTimeType m_LocalParametersUpdateTime
Superclass::OutputVectorType OutputVectorType
Superclass::JacobianType JacobianType
Superclass::InputPointType InputPointType
virtual TransformType * GetNthTransformModifiablePointer(const SizeValueType n) const
IdentifierType NumberOfParametersType
TransformType::Pointer TransformTypePointer
Superclass::ParametersValueType ParametersValueType
Superclass::OutputVnlVectorType OutputVnlVectorType
virtual bool IsTransformQueueEmpty() const
Superclass::FixedParametersType FixedParametersType
TParametersValueType ParametersValueType
unsigned long ModifiedTimeType
Definition: itkIntTypes.h:164
virtual void PrependTransform(TransformType *t)
Superclass::OutputPointType OutputPointType
SmartPointer< Self > Pointer
Superclass::OutputSymmetricSecondRankTensorType OutputSymmetricSecondRankTensorType
Superclass::FixedParametersValueType FixedParametersValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:143
Superclass::OutputVectorPixelType OutputVectorPixelType
Superclass::InputCovariantVectorType InputCovariantVectorType
Superclass::InputSymmetricSecondRankTensorType InputSymmetricSecondRankTensorType
virtual void RemoveTransform()
virtual const TransformQueueType & GetTransformQueue() const
virtual const TransformType * GetBackTransform() const
Superclass::InverseTransformBasePointer InverseTransformBasePointer
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:82
Transform< TParametersValueType, NDimensions, NSubDimensions > Superclass
ParametersValueType ScalarType
virtual void ClearTransformQueue()
TransformQueueType m_TransformQueue
Superclass::InputVectorType InputVectorType
virtual const TransformType * GetNthTransformConstPointer(const SizeValueType n) const
Superclass::InputVectorPixelType InputVectorPixelType
virtual void AppendTransform(TransformType *t)
Superclass::InputDiffusionTensor3DType InputDiffusionTensor3DType
virtual const TransformTypePointer GetNthTransform(SizeValueType n) const
Superclass::InputVnlVectorType InputVnlVectorType
Superclass::DerivativeType DerivativeType
virtual const TransformType * GetFrontTransform() const
NumberOfParametersType m_NumberOfLocalParameters
Superclass::ParametersType ParametersType
This abstract class contains a list of transforms and provides basic methods.
Superclass::TransformCategoryType TransformCategoryType
Transform< TParametersValueType, NSubDimensions, NSubDimensions > TransformType
Superclass::OutputDiffusionTensor3DType OutputDiffusionTensor3DType
virtual SizeValueType GetNumberOfTransforms() const
Control indentation during Print() invocation.
Definition: itkIndent.h:49
SmartPointer< const Self > ConstPointer
virtual void PopFrontTransform()
Superclass::OutputCovariantVectorType OutputCovariantVectorType
std::deque< TransformTypePointer > TransformQueueType
Superclass::NumberOfParametersType NumberOfParametersType
virtual void AddTransform(TransformType *t)
TransformType::InverseTransformBasePointer SubTransformInverseTransformBasePointer
virtual void PushBackTransform(TransformTypePointer t)
virtual void PopBackTransform()