ITK  4.8.0
Insight Segmentation and Registration Toolkit
itkCompositeTransform.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 itkCompositeTransform_h
19 #define itkCompositeTransform_h
20 
21 #include "itkMultiTransform.h"
22 
23 #include <deque>
24 
25 namespace itk
26 {
27 
86 template<typename TParametersValueType=double, unsigned int NDimensions = 3>
88  public MultiTransform<TParametersValueType, NDimensions, NDimensions>
89 {
90 public:
96 
98  itkTypeMacro( CompositeTransform, Transform );
99 
101  itkNewMacro( Self );
102 
104  typedef typename Superclass::TransformType TransformType;
106 
109 
112 
118 
121 
124 
127 
131 
135 
139 
143 
147 
151 
155 
158 
161 
163  typedef std::deque<bool> TransformsToOptimizeFlagsType;
164 
166  itkStaticConstMacro( InputDimension, unsigned int, NDimensions );
167  itkStaticConstMacro( OutputDimension, unsigned int, NDimensions );
169 
172  virtual void SetNthTransformToOptimize( SizeValueType i, bool state )
173  {
174  this->m_TransformsToOptimizeFlags.at(i) = state;
175  this->Modified();
176  }
177 
179  {
180  this->SetNthTransformToOptimize( i, true );
181  }
182 
184  {
185  this->SetNthTransformToOptimize( i, false );
186  }
187 
188  virtual void SetAllTransformsToOptimize( bool state )
189  {
190  this->m_TransformsToOptimizeFlags.assign(
191  this->m_TransformsToOptimizeFlags.size(), state );
192  this->Modified();
193  }
194 
196  {
197  this->SetAllTransformsToOptimize( true );
198  }
199 
201  {
202  this->SetAllTransformsToOptimize( false );
203  }
204 
205  /* With AddTransform() as the only way to add a transform, we
206  * can have this method to easily allow user to optimize only
207  * the transform added most recenlty. */
209  {
210  this->SetAllTransformsToOptimize( false );
212  }
213 
214  /* Get whether the Nth transform is set to be optimzied */
215  /* NOTE: ambiguous function name here - are we getting if the Nth transform
216  is set to be optimized, or the Nth of the transforms that are set to be
217  optimized? */
218  virtual bool GetNthTransformToOptimize( SizeValueType i ) const
219  {
220  return this->m_TransformsToOptimizeFlags.at(i);
221  }
222 
225  {
226  return this->m_TransformsToOptimizeFlags;
227  }
228 
229  virtual void ClearTransformQueue() ITK_OVERRIDE
230  {
232  this->m_TransformsToOptimizeFlags.clear();
233  }
234 
240  bool GetInverse( Self *inverse ) const;
241 
242  virtual InverseTransformBasePointer GetInverseTransform() const ITK_OVERRIDE;
243 
258  virtual OutputPointType TransformPoint( const InputPointType & inputPoint ) const ITK_OVERRIDE;
259 
262  virtual OutputVectorType TransformVector(const InputVectorType &) const ITK_OVERRIDE;
263 
264  virtual OutputVnlVectorType TransformVector(const InputVnlVectorType & inputVector) const ITK_OVERRIDE;
265 
266  virtual OutputVectorPixelType TransformVector(const InputVectorPixelType & inputVector ) const ITK_OVERRIDE;
267 
268  virtual OutputVectorType TransformVector(const InputVectorType & inputVector,
269  const InputPointType & inputPoint ) const ITK_OVERRIDE;
270 
271  virtual OutputVnlVectorType TransformVector(const InputVnlVectorType & inputVector,
272  const InputPointType & inputPoint ) const ITK_OVERRIDE;
273 
274  virtual OutputVectorPixelType TransformVector(const InputVectorPixelType & inputVector,
275  const InputPointType & inputPoint ) const ITK_OVERRIDE;
276 
279  virtual OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const ITK_OVERRIDE;
280 
281  virtual OutputVectorPixelType TransformCovariantVector(const InputVectorPixelType &) const ITK_OVERRIDE;
282 
283  virtual OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType & inputVector,
284  const InputPointType & inputPoint ) const ITK_OVERRIDE;
285 
286  virtual OutputVectorPixelType TransformCovariantVector(const InputVectorPixelType & inputVector,
287  const InputPointType & inputPoint ) const ITK_OVERRIDE;
288 
291  virtual OutputDiffusionTensor3DType TransformDiffusionTensor3D(
292  const InputDiffusionTensor3DType & inputTensor) const ITK_OVERRIDE;
293 
294  virtual OutputVectorPixelType TransformDiffusionTensor3D(
295  const InputVectorPixelType & inputTensor) const ITK_OVERRIDE;
296 
297  virtual OutputDiffusionTensor3DType TransformDiffusionTensor3D(
298  const InputDiffusionTensor3DType & inputTensor,
299  const InputPointType & inputPoint ) const ITK_OVERRIDE;
300 
301  virtual OutputVectorPixelType TransformDiffusionTensor3D(
302  const InputVectorPixelType & inputTensor,
303  const InputPointType & inputPoint ) const ITK_OVERRIDE;
304 
307  virtual OutputSymmetricSecondRankTensorType TransformSymmetricSecondRankTensor(
308  const InputSymmetricSecondRankTensorType & inputTensor) const ITK_OVERRIDE;
309 
310  virtual OutputVectorPixelType TransformSymmetricSecondRankTensor(
311  const InputVectorPixelType & inputTensor) const ITK_OVERRIDE;
312 
313  virtual OutputSymmetricSecondRankTensorType TransformSymmetricSecondRankTensor(
314  const InputSymmetricSecondRankTensorType & inputTensor,
315  const InputPointType & inputPoint ) const ITK_OVERRIDE;
316 
317  virtual OutputVectorPixelType TransformSymmetricSecondRankTensor(
318  const InputVectorPixelType & inputTensor,
319  const InputPointType & inputPoint ) const ITK_OVERRIDE;
320 
325  virtual TransformCategoryType GetTransformCategory() const ITK_OVERRIDE;
326 
337  virtual const ParametersType & GetParameters() const ITK_OVERRIDE;
338 
339  /* SetParameters only for transforms that are set to be optimized
340  * See GetParameters() for parameter ordering. */
341  virtual void SetParameters(const ParametersType & p) ITK_OVERRIDE;
342 
343  /* GetFixedParameters only for transforms that are set to be optimized
344  * See GetParameters() for parameter ordering. */
345  virtual const FixedParametersType & GetFixedParameters() const ITK_OVERRIDE;
346 
347  /* SetFixedParameters only for transforms that are set to be optimized.
348  * See GetParameters() for parameter ordering. */
349  virtual void SetFixedParameters(const FixedParametersType & fixedParameters) ITK_OVERRIDE;
350 
351  /* Get total number of parameters for transforms that are set to be
352  * optimized */
353  virtual NumberOfParametersType GetNumberOfParameters(void) const ITK_OVERRIDE;
354 
355  /* Get total number of local parameters for transforms that are set
356  * to be optimized */
357  virtual NumberOfParametersType GetNumberOfLocalParameters(void) const ITK_OVERRIDE;
358 
359  /* Get total number of fixed parameters for transforms that are set
360  * to be optimized */
361  virtual NumberOfParametersType GetNumberOfFixedParameters(void) const ITK_OVERRIDE;
362 
365  virtual void UpdateTransformParameters( const DerivativeType & update, ScalarType factor = 1.0 ) ITK_OVERRIDE;
366 
370  virtual void FlattenTransformQueue();
371 
376  virtual void ComputeJacobianWithRespectToParameters(const InputPointType & p, JacobianType & j) const ITK_OVERRIDE;
377 
387  virtual void ComputeJacobianWithRespectToParametersCachedTemporaries( const InputPointType & p, JacobianType & outJacobian, JacobianType & jacobianWithRespectToPosition ) const ITK_OVERRIDE;
389 
390 protected:
392  virtual ~CompositeTransform();
393  virtual void PrintSelf( std::ostream& os, Indent indent ) const ITK_OVERRIDE;
394 
396  virtual typename LightObject::Pointer InternalClone() const ITK_OVERRIDE;
397 
398  virtual void PushFrontTransform( TransformTypePointer t ) ITK_OVERRIDE
399  {
401  /* Add element to list of flags, and set true by default */
402  this->m_TransformsToOptimizeFlags.push_front( true );
403  }
404 
405  virtual void PushBackTransform( TransformTypePointer t ) ITK_OVERRIDE
406  {
408  /* Add element to list of flags, and set true by default */
409  this->m_TransformsToOptimizeFlags.push_back( true );
410  }
411 
412  virtual void PopFrontTransform() ITK_OVERRIDE
413  {
415  this->m_TransformsToOptimizeFlags.pop_front();
416  }
417 
418  virtual void PopBackTransform() ITK_OVERRIDE
419  {
421  this->m_TransformsToOptimizeFlags.pop_back();
422  }
423 
426 
429 
430 private:
431  CompositeTransform( const Self & ); // purposely not implemented
432  void operator=( const Self & ); // purposely not implemented
433 
435 
436 };
437 
438 } // end namespace itk
439 
440 #ifndef ITK_MANUAL_INSTANTIATION
441 #include "itkCompositeTransform.hxx"
442 #endif
443 
444 #endif // itkCompositeTransform_h
virtual void SetAllTransformsToOptimizeOff()
Superclass::InputVectorPixelType InputVectorPixelType
virtual void ComputeJacobianWithRespectToParametersCachedTemporaries(const InputPointType &p, JacobianType &outJacobian, JacobianType &jacobianWithRespectToPosition) const override
Superclass::ScalarType ScalarType
Superclass::InputDiffusionTensor3DType InputDiffusionTensor3DType
Light weight base class for most itk classes.
bool GetInverse(Self *inverse) const
Superclass::ParametersValueType ParametersValueType
Superclass::ParametersType ParametersType
virtual NumberOfParametersType GetNumberOfParameters(void) const override
virtual void UpdateTransformParameters(const DerivativeType &update, ScalarType factor=1.0) override
virtual void SetAllTransformsToOptimize(bool state)
virtual void ComputeJacobianWithRespectToParameters(const InputPointType &p, JacobianType &j) const override
ModifiedTimeType m_PreviousTransformsToOptimizeUpdateTime
unsigned long ModifiedTimeType
Definition: itkIntTypes.h:164
Superclass::OutputDiffusionTensor3DType OutputDiffusionTensor3DType
TransformsToOptimizeFlagsType m_TransformsToOptimizeFlags
virtual void PushFrontTransform(TransformTypePointer t) override
void operator=(const Self &)
virtual void SetNthTransformToOptimize(SizeValueType i, bool state)
SmartPointer< const Self > ConstPointer
Superclass::OutputVectorType OutputVectorType
Superclass::InputVnlVectorType InputVnlVectorType
Superclass::OutputSymmetricSecondRankTensorType OutputSymmetricSecondRankTensorType
virtual void PushBackTransform(TransformTypePointer t) override
virtual void SetNthTransformToOptimizeOff(SizeValueType i)
SmartPointer< Self > Pointer
static const unsigned int OutputDimension
virtual OutputVectorType TransformVector(const InputVectorType &) const override
Superclass::FixedParametersValueType FixedParametersValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:143
Superclass::TransformQueueType TransformQueueType
virtual void PrintSelf(std::ostream &os, Indent indent) const override
Superclass::InverseTransformBasePointer InverseTransformBasePointer
Superclass::InputSymmetricSecondRankTensorType InputSymmetricSecondRankTensorType
virtual TransformCategoryType GetTransformCategory() const override
Superclass::OutputPointType OutputPointType
virtual void SetOnlyMostRecentTransformToOptimizeOn()
virtual void SetParameters(const ParametersType &p) override
virtual InverseTransformBasePointer GetInverseTransform() const override
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:82
virtual OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const override
Superclass::NumberOfParametersType NumberOfParametersType
virtual bool GetNthTransformToOptimize(SizeValueType i) const
Superclass::JacobianType JacobianType
Superclass::InputSymmetricSecondRankTensorType InputSymmetricSecondRankTensorType
TransformQueueType m_TransformsToOptimizeQueue
This class contains a list of transforms and concatenates them by composition.
virtual void ClearTransformQueue() override
virtual const TransformsToOptimizeFlagsType & GetTransformsToOptimizeFlags() const
Superclass::DerivativeType DerivativeType
Superclass::TransformTypePointer TransformTypePointer
virtual NumberOfParametersType GetNumberOfFixedParameters(void) const override
Superclass::OutputVectorPixelType OutputVectorPixelType
virtual void Modified() const
virtual NumberOfParametersType GetNumberOfLocalParameters(void) const override
static const unsigned int InputDimension
This abstract class contains a list of transforms and provides basic methods.
Superclass::OutputCovariantVectorType OutputCovariantVectorType
Superclass::TransformCategoryType TransformCategoryType
virtual OutputDiffusionTensor3DType TransformDiffusionTensor3D(const InputDiffusionTensor3DType &inputTensor) const override
Superclass::OutputVnlVectorType OutputVnlVectorType
Superclass::OutputSymmetricSecondRankTensorType OutputSymmetricSecondRankTensorType
Superclass::FixedParametersType FixedParametersType
Superclass::InputVectorType InputVectorType
virtual void SetAllTransformsToOptimizeOn()
virtual void SetFixedParameters(const FixedParametersType &fixedParameters) override
virtual const ParametersType & GetParameters() const override
Transform< TParametersValueType, NSubDimensions, NSubDimensions > TransformType
virtual const FixedParametersType & GetFixedParameters() const override
Superclass::TransformType TransformType
virtual void PopFrontTransform() override
Control indentation during Print() invocation.
Definition: itkIndent.h:49
virtual LightObject::Pointer InternalClone() const override
virtual OutputPointType TransformPoint(const InputPointType &inputPoint) const override
std::deque< bool > TransformsToOptimizeFlagsType
TransformQueueType & GetTransformsToOptimizeQueue() const
virtual void PopBackTransform() override
Superclass::NumberOfParametersType NumberOfParametersType
virtual void SetNthTransformToOptimizeOn(SizeValueType i)
Superclass::InputPointType InputPointType
MultiTransform< TParametersValueType, NDimensions, NDimensions > Superclass
Superclass::InputCovariantVectorType InputCovariantVectorType
virtual OutputSymmetricSecondRankTensorType TransformSymmetricSecondRankTensor(const InputSymmetricSecondRankTensorType &inputTensor) const override
virtual void FlattenTransformQueue()