ITK  4.3.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 <class TScalar = double, unsigned int NDimensions = 3, unsigned int NSubDimensions = NDimensions>
64 class ITK_EXPORT MultiTransform :
65  public Transform<TScalar, NDimensions, NDimensions>
66 {
67 public:
73 
75  itkTypeMacro( MultiTransform, Transform );
76 
80 
81  /* Types common to both container and sub transforms */
82 
84  typedef typename Superclass::ScalarType ScalarType;
85 
87  typedef typename Superclass::ParametersType ParametersType;
88  typedef typename Superclass::ParametersValueType ParametersValueType;
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
181  TransformTypePointer GetFrontTransform()
182  {
183  return this->m_TransformQueue.front();
184  }
185 
186  virtual const
187  TransformTypePointer GetBackTransform()
188  {
189  return this->m_TransformQueue.back();
190  }
191 
194  virtual const
195  TransformTypePointer GetNthTransform( SizeValueType n ) const
196  {
197  return this->m_TransformQueue[n];
198  }
199 
201  virtual const TransformQueueType & GetTransformQueue() const
202  {
203  return this->m_TransformQueue;
204  }
205 
207  virtual bool IsTransformQueueEmpty() const
208  {
209  return this->m_TransformQueue.empty();
210  }
211 
213  virtual SizeValueType GetNumberOfTransforms() const
214  {
215  return this->m_TransformQueue.size();
216  }
217 
219  virtual void ClearTransformQueue()
220  {
221  this->m_TransformQueue.clear();
222  this->Modified();
223  }
225 
227  virtual bool IsLinear() const;
228 
231  virtual TransformCategoryType GetTransformCategory() const;
232 
240  virtual const ParametersType & GetParameters(void) const;
241 
242  /* SetParameters for all sub-transforms.
243  * See GetParameters() for parameter ordering. */
244  virtual void SetParameters(const ParametersType & p);
245 
246  /* GetFixedParameters for all sub-transforms.
247  * See GetParameters() for parameter ordering. */
248  virtual const ParametersType & GetFixedParameters(void) const;
249 
250  /* SetFixedParameters for all sub-transforms.
251  * See GetParameters() for parameter ordering. */
252  virtual void SetFixedParameters(const ParametersType & fixedParameters);
253 
254  /* Get total number of parameters. Sum of all sub-transforms. */
255  virtual NumberOfParametersType GetNumberOfParameters(void) const;
256 
257  /* Get total number of local parameters, the sum of all sub-transforms. */
258  virtual NumberOfParametersType GetNumberOfLocalParameters(void) const;
259 
260  /* Get total number of fixed parameters, the sum of all sub-transforms. */
261  virtual NumberOfParametersType GetNumberOfFixedParameters(void) const;
262 
265  virtual void UpdateTransformParameters( const DerivativeType & update, ScalarType factor = 1.0 );
266 
272  bool GetInverse( Self *inverse ) const;
273 
275 //TODO - what do we need here?
276 // virtual void FlattenTransformQueue();
277 
278 protected:
279  MultiTransform();
280  virtual ~MultiTransform();
281  void PrintSelf( std::ostream& os, Indent indent ) const;
282 
283  virtual void PushFrontTransform( TransformTypePointer t )
284  {
285  this->m_TransformQueue.push_front( t );
286  this->Modified();
287  }
288 
289  virtual void PushBackTransform( TransformTypePointer t )
290  {
291  this->m_TransformQueue.push_back( t );
292  this->Modified();
293  }
294 
295  virtual void PopFrontTransform()
296  {
297  this->m_TransformQueue.pop_front();
298  this->Modified();
299  }
300 
301  virtual void PopBackTransform()
302  {
303  this->m_TransformQueue.pop_back();
304  this->Modified();
305  }
306 
309 
313 
314 private:
315  MultiTransform( const Self & ); // purposely not implemented
316  void operator=( const Self & ); // purposely not implemented
317 
318 };
319 
320 } // end namespace itk
321 
322 #ifndef ITK_MANUAL_INSTANTIATION
323 #include "itkMultiTransform.hxx"
324 #endif
325 
326 #endif // __itkMultiTransform_h
327