ITK  4.4.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 
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 
309 protected:
311  void PrintSelf( std::ostream & os, Indent indent ) const;
312 
314  virtual ~BSplineDeformableTransform();
315 
316 private:
317 
319  virtual void SetFixedParametersGridSizeFromTransformDomainInformation() const;
320 
322  virtual void SetFixedParametersGridOriginFromTransformDomainInformation() const;
323 
325  virtual void SetFixedParametersGridSpacingFromTransformDomainInformation() const;
326 
328  virtual void SetFixedParametersGridDirectionFromTransformDomainInformation() const;
329 
331  virtual void SetCoefficientImageInformationFromFixedParameters();
332 
333  BSplineDeformableTransform( const Self & ); // purposely not implemented
334  void operator=( const Self & ); // purposely not implemented
335 
337  virtual bool InsideValidRegion( ContinuousIndexType & ) const;
338 
351 
354 
356 
358  unsigned long m_Offset;
362 
363  void UpdateValidGridRegion();
364 
365 }; // class BSplineDeformableTransform
366 } // namespace itk
367 
368 #ifndef ITK_MANUAL_INSTANTIATION
369 #include "itkBSplineDeformableTransform.hxx"
370 #endif
371 
372 #endif /* __itkBSplineDeformableTransform_h */
373