ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
00001 /*========================================================================= 00002 * 00003 * Copyright Insight Software Consortium 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0.txt 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 *=========================================================================*/ 00018 #ifndef __itkBSplineDeformableTransform_h 00019 #define __itkBSplineDeformableTransform_h 00020 00021 #include "itkConfigure.h" // Needed to determine value of ITKV3_COMPATIBILITY 00022 #include "itkBSplineBaseTransform.h" 00023 00024 namespace itk 00025 { 00107 template <class TScalarType = double, unsigned int NDimensions = 3, 00108 unsigned int VSplineOrder = 3> 00109 class ITK_EXPORT BSplineDeformableTransform : 00110 public BSplineBaseTransform<TScalarType,NDimensions,VSplineOrder> 00111 { 00112 public: 00114 typedef BSplineDeformableTransform Self; 00115 typedef BSplineBaseTransform<TScalarType,NDimensions,VSplineOrder> Superclass; 00116 typedef SmartPointer<Self> Pointer; 00117 typedef SmartPointer<const Self> ConstPointer; 00118 00120 // Explicit New() method, used here because we need to split the itkNewMacro() 00121 // in order to overload the CreateAnother() method so that we can copy the m_BulkTransform 00122 // explicitly. 00123 // TODO: shouldn't it be done with the Clone() method? 00124 itkSimpleNewMacro(Self); 00125 virtual ::itk::LightObject::Pointer CreateAnother(void) const 00126 { 00127 ::itk::LightObject::Pointer smartPtr; 00128 Pointer copyPtr = Self::New().GetPointer(); 00129 //THE FOLLOWING LINE IS DIFFERENT FROM THE DEFAULT MACRO! 00130 copyPtr->m_BulkTransform = this->GetBulkTransform(); 00131 smartPtr = static_cast<Pointer>( copyPtr ); 00132 return smartPtr; 00133 } 00135 00137 itkCloneMacro(Self); 00138 00140 itkTypeMacro( BSplineDeformableTransform, BSplineBaseTransform ); 00141 00143 itkStaticConstMacro( SpaceDimension, unsigned int, NDimensions ); 00144 00146 itkStaticConstMacro( SplineOrder, unsigned int, VSplineOrder ); 00147 00149 typedef typename Superclass::ScalarType ScalarType; 00150 00152 typedef typename Superclass::ParametersType ParametersType; 00153 00155 typedef typename Superclass::JacobianType JacobianType; 00156 00158 typedef typename Superclass::NumberOfParametersType NumberOfParametersType; 00159 00161 typedef typename Superclass::InputVectorType InputVectorType; 00162 typedef typename Superclass::OutputVectorType OutputVectorType; 00163 00165 typedef typename Superclass::InputCovariantVectorType InputCovariantVectorType; 00166 typedef typename Superclass::OutputCovariantVectorType OutputCovariantVectorType; 00167 00169 typedef typename Superclass::InputVnlVectorType InputVnlVectorType; 00170 typedef typename Superclass::OutputVnlVectorType OutputVnlVectorType; 00171 00173 typedef Point <TScalarType, itkGetStaticConstMacro( SpaceDimension )> InputPointType; 00174 typedef Point <TScalarType, itkGetStaticConstMacro( SpaceDimension )> OutputPointType; 00176 00177 00194 virtual void SetFixedParameters( const ParametersType & parameters ); 00196 00198 typedef typename Superclass::ParametersValueType ParametersValueType; 00199 typedef typename Superclass::ImageType ImageType; 00200 typedef typename Superclass::ImagePointer ImagePointer; 00201 typedef typename Superclass::CoefficientImageArray CoefficientImageArray; 00202 00214 virtual void SetCoefficientImages( const CoefficientImageArray & images ); 00215 00216 #ifdef ITKV3_COMPATIBILITY 00217 virtual void SetCoefficientImage( const CoefficientImageArray & images ) 00218 { 00219 this->SetCoefficientImages( images ); 00220 } 00221 /* Only for backwards compatibility with ITKv3. */ 00222 CoefficientImageArray GetCoefficientImage() 00223 { 00224 return this->GetCoefficientImages(); 00225 } 00226 #endif 00227 00229 typedef typename Superclass::RegionType RegionType; 00230 00231 typedef typename Superclass::IndexType IndexType; 00232 typedef typename Superclass::SizeType SizeType; 00233 typedef typename Superclass::SpacingType SpacingType; 00234 typedef typename Superclass::DirectionType DirectionType; 00235 typedef typename Superclass::OriginType OriginType; 00236 00238 typedef typename Superclass::WeightsFunctionType WeightsFunctionType; 00239 00240 typedef typename Superclass::WeightsType WeightsType; 00241 typedef typename Superclass::ContinuousIndexType ContinuousIndexType; 00242 00244 typedef typename Superclass::ParameterIndexArrayType ParameterIndexArrayType; 00245 00254 using Superclass::TransformPoint; 00255 virtual void TransformPoint( const InputPointType & inputPoint, OutputPointType & outputPoint, 00256 WeightsType & weights, ParameterIndexArrayType & indices, bool & inside ) const; 00258 00259 virtual void ComputeJacobianWithRespectToParameters( const InputPointType &, JacobianType & ) const; 00260 00262 virtual NumberOfParametersType GetNumberOfParameters() const; 00263 00265 NumberOfParametersType GetNumberOfParametersPerDimension() const; 00266 00267 typedef typename Superclass::SpacingType PhysicalDimensionsType; 00268 typedef typename Superclass::PixelType PixelType; 00269 00270 typedef typename Superclass::MeshSizeType MeshSizeType; 00271 00273 virtual void SetGridOrigin( const OriginType & ); 00274 00276 itkGetConstMacro( GridOrigin, OriginType ); 00277 00279 virtual void SetGridSpacing( const SpacingType & ); 00280 00282 itkGetConstMacro( GridSpacing, SpacingType ); 00283 00285 virtual void SetGridDirection( const DirectionType & ); 00286 00288 itkGetConstMacro( GridDirection, DirectionType ); 00289 00291 virtual void SetGridRegion( const RegionType & ); 00292 00294 itkGetConstMacro( GridRegion, RegionType ); 00295 00296 typedef Transform<ScalarType, itkGetStaticConstMacro(SpaceDimension), 00297 itkGetStaticConstMacro(SpaceDimension)> BulkTransformType; 00298 typedef typename BulkTransformType::ConstPointer BulkTransformPointer; 00302 itkSetConstObjectMacro(BulkTransform, BulkTransformType); 00303 itkGetConstObjectMacro(BulkTransform, BulkTransformType); 00305 00307 itkGetConstReferenceMacro(ValidRegion, RegionType); 00308 00310 virtual NumberOfParametersType GetNumberOfLocalParameters() const 00311 { 00312 itkExceptionMacro("GetNumberOfLocalParameters not yet implemented."); 00313 } 00314 00315 protected: 00317 void PrintSelf( std::ostream & os, Indent indent ) const; 00318 00319 BSplineDeformableTransform(); 00320 virtual ~BSplineDeformableTransform(); 00321 00322 private: 00323 00325 virtual void SetFixedParametersGridSizeFromTransformDomainInformation() const; 00326 00328 virtual void SetFixedParametersGridOriginFromTransformDomainInformation() const; 00329 00331 virtual void SetFixedParametersGridSpacingFromTransformDomainInformation() const; 00332 00334 virtual void SetFixedParametersGridDirectionFromTransformDomainInformation() const; 00335 00337 virtual void SetCoefficientImageInformationFromFixedParameters(); 00338 00339 BSplineDeformableTransform( const Self & ); // purposely not implemented 00340 void operator=( const Self & ); // purposely not implemented 00341 00343 virtual bool InsideValidRegion( ContinuousIndexType & ) const; 00344 00353 const RegionType & m_GridRegion; 00354 const OriginType & m_GridOrigin; 00355 const SpacingType & m_GridSpacing; 00356 const DirectionType & m_GridDirection; 00357 00359 BulkTransformPointer m_BulkTransform; 00360 00361 RegionType m_ValidRegion; 00362 00364 unsigned long m_Offset; 00365 bool m_SplineOrderOdd; 00366 IndexType m_ValidRegionLast; 00367 IndexType m_ValidRegionFirst; 00368 00369 void UpdateValidGridRegion(); 00370 00371 }; // class BSplineDeformableTransform 00372 } // namespace itk 00373 00374 // Define instantiation macro for this template. 00375 #define ITK_TEMPLATE_BSplineDeformableTransform(_, EXPORT, TypeX, TypeY) \ 00376 namespace itk \ 00377 { \ 00378 _( 3 ( class EXPORT BSplineDeformableTransform<ITK_TEMPLATE_3 TypeX> ) ) \ 00379 namespace Templates \ 00380 { \ 00381 typedef BSplineDeformableTransform<ITK_TEMPLATE_3 TypeX> \ 00382 BSplineDeformableTransform##TypeY; \ 00383 } \ 00384 } 00385 00386 #if ITK_TEMPLATE_EXPLICIT 00387 // template < class TScalarType, unsigned int NDimensions, unsigned int 00388 // VSplineOrder > 00389 // const unsigned int itk::BSplineDeformableTransform<TScalarType, 00390 // NDimensions, VSplineOrder >::SpaceDimension; 00391 // template < class TScalarType, unsigned int NDimensions, unsigned int 00392 // VSplineOrder > 00393 // const unsigned int itk::BSplineDeformableTransform<TScalarType, 00394 // NDimensions, VSplineOrder >::SplineOrder; 00395 #include "Templates/itkBSplineDeformableTransform+-.h" 00396 #endif 00397 00398 #if ITK_TEMPLATE_TXX 00399 #include "itkBSplineDeformableTransform.hxx" 00400 #endif 00401 00402 #endif /* __itkBSplineDeformableTransform_h */ 00403