ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkBSplineDeformableTransform.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 __itkBSplineDeformableTransform_h
19 #define __itkBSplineDeformableTransform_h
20 
21 #include "itkConfigure.h" // Needed to determine value of ITKV3_COMPATIBILITY
23 
24 namespace itk
25 {
107 template <class TScalarType = double, unsigned int NDimensions = 3,
108  unsigned int VSplineOrder = 3>
109 class ITK_EXPORT BSplineDeformableTransform :
110  public BSplineBaseTransform<TScalarType,NDimensions,VSplineOrder>
111 {
112 public:
118 
120  // Explicit New() method, used here because we need to split the itkNewMacro()
121  // in order to overload the CreateAnother() method so that we can copy the m_BulkTransform
122  // explicitly.
123  // TODO: shouldn't it be done with the Clone() method?
124  itkSimpleNewMacro(Self);
125  virtual ::itk::LightObject::Pointer CreateAnother(void) const
126  {
128  Pointer copyPtr = Self::New().GetPointer();
129  //THE FOLLOWING LINE IS DIFFERENT FROM THE DEFAULT MACRO!
130  copyPtr->m_BulkTransform = this->GetBulkTransform();
131  smartPtr = static_cast<Pointer>( copyPtr );
132  return smartPtr;
133  }
135 
137  itkCloneMacro(Self);
138 
141 
143  itkStaticConstMacro( SpaceDimension, unsigned int, NDimensions );
144 
146  itkStaticConstMacro( SplineOrder, unsigned int, VSplineOrder );
147 
149  typedef typename Superclass::ScalarType ScalarType;
150 
152  typedef typename Superclass::ParametersType ParametersType;
153 
155  typedef typename Superclass::JacobianType JacobianType;
156 
158  typedef typename Superclass::NumberOfParametersType NumberOfParametersType;
159 
161  typedef typename Superclass::InputVectorType InputVectorType;
162  typedef typename Superclass::OutputVectorType OutputVectorType;
163 
165  typedef typename Superclass::InputCovariantVectorType InputCovariantVectorType;
166  typedef typename Superclass::OutputCovariantVectorType OutputCovariantVectorType;
167 
169  typedef typename Superclass::InputVnlVectorType InputVnlVectorType;
170  typedef typename Superclass::OutputVnlVectorType OutputVnlVectorType;
171 
176 
177 
194  virtual void SetFixedParameters( const ParametersType & parameters );
196 
198  typedef typename Superclass::ParametersValueType ParametersValueType;
199  typedef typename Superclass::ImageType ImageType;
200  typedef typename Superclass::ImagePointer ImagePointer;
201  typedef typename Superclass::CoefficientImageArray CoefficientImageArray;
202 
214  virtual void SetCoefficientImages( const CoefficientImageArray & images );
215 
216 #ifdef ITKV3_COMPATIBILITY
217  virtual void SetCoefficientImage( const CoefficientImageArray & images )
218  {
219  this->SetCoefficientImages( images );
220  }
221  /* Only for backwards compatibility with ITKv3. */
222  CoefficientImageArray GetCoefficientImage()
223  {
224  return this->GetCoefficientImages();
225  }
226 #endif
227 
229  typedef typename Superclass::RegionType RegionType;
230 
231  typedef typename Superclass::IndexType IndexType;
232  typedef typename Superclass::SizeType SizeType;
233  typedef typename Superclass::SpacingType SpacingType;
236 
238  typedef typename Superclass::WeightsFunctionType WeightsFunctionType;
239 
240  typedef typename Superclass::WeightsType WeightsType;
241  typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
242 
244  typedef typename Superclass::ParameterIndexArrayType ParameterIndexArrayType;
245 
254  using Superclass::TransformPoint;
255  virtual void TransformPoint( const InputPointType & inputPoint, OutputPointType & outputPoint,
256  WeightsType & weights, ParameterIndexArrayType & indices, bool & inside ) const;
258 
259  virtual void ComputeJacobianWithRespectToParameters( const InputPointType &, JacobianType & ) const;
260 
262  virtual NumberOfParametersType GetNumberOfParameters() const;
263 
265  NumberOfParametersType GetNumberOfParametersPerDimension() const;
266 
267  typedef typename Superclass::SpacingType PhysicalDimensionsType;
268  typedef typename Superclass::PixelType PixelType;
269 
270  typedef typename Superclass::MeshSizeType MeshSizeType;
271 
273  virtual void SetGridOrigin( const OriginType & );
274 
276  itkGetConstMacro( GridOrigin, OriginType );
277 
279  virtual void SetGridSpacing( const SpacingType & );
280 
282  itkGetConstMacro( GridSpacing, SpacingType );
283 
285  virtual void SetGridDirection( const DirectionType & );
286 
288  itkGetConstMacro( GridDirection, DirectionType );
289 
291  virtual void SetGridRegion( const RegionType & );
292 
294  itkGetConstMacro( GridRegion, RegionType );
295 
296  typedef Transform<ScalarType, itkGetStaticConstMacro(SpaceDimension),
297  itkGetStaticConstMacro(SpaceDimension)> BulkTransformType;
302  itkSetConstObjectMacro(BulkTransform, BulkTransformType);
303  itkGetConstObjectMacro(BulkTransform, BulkTransformType);
305 
307  itkGetConstReferenceMacro(ValidRegion, RegionType);
308 
310  virtual NumberOfParametersType GetNumberOfLocalParameters() const
311  {
312  itkExceptionMacro("GetNumberOfLocalParameters not yet implemented.");
313  }
314 
315 protected:
317  void PrintSelf( std::ostream & os, Indent indent ) const;
318 
320  virtual ~BSplineDeformableTransform();
321 
322 private:
323 
325  virtual void SetFixedParametersGridSizeFromTransformDomainInformation() const;
326 
328  virtual void SetFixedParametersGridOriginFromTransformDomainInformation() const;
329 
331  virtual void SetFixedParametersGridSpacingFromTransformDomainInformation() const;
332 
334  virtual void SetFixedParametersGridDirectionFromTransformDomainInformation() const;
335 
337  virtual void SetCoefficientImageInformationFromFixedParameters();
338 
339  BSplineDeformableTransform( const Self & ); // purposely not implemented
340  void operator=( const Self & ); // purposely not implemented
341 
343  virtual bool InsideValidRegion( ContinuousIndexType & ) const;
344 
357 
360 
362 
364  unsigned long m_Offset;
368 
369  void UpdateValidGridRegion();
370 
371 }; // class BSplineDeformableTransform
372 } // namespace itk
373 
374 // Define instantiation macro for this template.
375 #define ITK_TEMPLATE_BSplineDeformableTransform(_, EXPORT, TypeX, TypeY) \
376  namespace itk \
377  { \
378  _( 3 ( class EXPORT BSplineDeformableTransform<ITK_TEMPLATE_3 TypeX> ) ) \
379  namespace Templates \
380  { \
381  typedef BSplineDeformableTransform<ITK_TEMPLATE_3 TypeX> \
382  BSplineDeformableTransform##TypeY; \
383  } \
384  }
385 
386 #if ITK_TEMPLATE_EXPLICIT
387 // template < class TScalarType, unsigned int NDimensions, unsigned int
388 // VSplineOrder >
389 // const unsigned int itk::BSplineDeformableTransform<TScalarType,
390 // NDimensions, VSplineOrder >::SpaceDimension;
391 // template < class TScalarType, unsigned int NDimensions, unsigned int
392 // VSplineOrder >
393 // const unsigned int itk::BSplineDeformableTransform<TScalarType,
394 // NDimensions, VSplineOrder >::SplineOrder;
395 #include "Templates/itkBSplineDeformableTransform+-.h"
396 #endif
397 
398 #if ITK_TEMPLATE_TXX
399 #include "itkBSplineDeformableTransform.hxx"
400 #endif
401 
402 #endif /* __itkBSplineDeformableTransform_h */
403