| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkElasticBodyReciprocalSplineKernelTransform.txx.html,v $ |
| 5 |
|
Language: C++ |
| 6 |
|
Date: $Date: 2006/01/17 19:15:35 $ |
| 7 |
|
Version: $Revision: 1.4 $ |
| 8 |
|
|
| 9 |
|
Copyright (c) Insight Software Consortium. All rights reserved. |
| 10 |
|
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. |
| 11 |
|
|
| 12 |
|
This software is distributed WITHOUT ANY WARRANTY; without even |
| 13 |
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 |
|
PURPOSE. See the above copyright notices for more information. |
| 15 |
|
|
| 16 |
|
=========================================================================*/ |
| 17 |
DEF |
#ifndef _itkElasticBodyReciprocalSplineKernelTransform_txx |
| 18 |
DEF |
#define _itkElasticBodyReciprocalSplineKernelTransform_txx |
| 19 |
|
#include "itkElasticBodyReciprocalSplineKernelTransform.h" |
| 20 |
|
|
| 21 |
|
namespace itk |
| 22 |
|
{ |
| 23 |
|
|
| 24 |
|
template <class TScalarType, unsigned int NDimensions> |
| 25 |
|
ElasticBodyReciprocalSplineKernelTransform<TScalarType, NDimensions>:: |
| 26 |
|
ElasticBodyReciprocalSplineKernelTransform() |
| 27 |
|
{ |
| 28 |
|
// Alpha = 8 ( 1 - \nu ) - 1 |
| 29 |
|
m_Alpha = 8.0 * ( 1.0 - .25 ) - 1; |
| 30 |
|
} |
| 31 |
|
|
| 32 |
|
template <class TScalarType, unsigned int NDimensions> |
| 33 |
|
ElasticBodyReciprocalSplineKernelTransform<TScalarType, NDimensions>:: |
| 34 |
|
~ElasticBodyReciprocalSplineKernelTransform() |
| 35 |
|
{ |
| 36 |
|
} |
| 37 |
|
|
| 38 |
|
template <class TScalarType, unsigned int NDimensions> |
| 39 |
LEN |
const typename ElasticBodyReciprocalSplineKernelTransform<TScalarType, NDimensions>::GMatrixType & |
| 40 |
|
ElasticBodyReciprocalSplineKernelTransform<TScalarType, NDimensions> |
| 41 |
|
::ComputeG(const InputVectorType & x) const |
| 42 |
|
{ |
| 43 |
|
const TScalarType r = x.GetNorm(); |
| 44 |
|
const TScalarType factor = |
| 45 |
IND |
****( r > 1e-8 ) ? ( -1.0 / r ): NumericTraits<TScalarType>::Zero; |
| 46 |
|
const TScalarType radial = m_Alpha * r; |
| 47 |
|
for(unsigned int i=0; i<NDimensions; i++) |
| 48 |
|
{ |
| 49 |
|
const typename InputVectorType::ValueType xi = x[i] * factor; |
| 50 |
|
// G is symmetric |
| 51 |
|
for(unsigned int j=0; j<i; j++) |
| 52 |
|
{ |
| 53 |
|
const TScalarType value = xi * x[j]; |
| 54 |
|
this->m_GMatrix[i][j] = value; |
| 55 |
|
this->m_GMatrix[j][i] = value; |
| 56 |
|
} |
| 57 |
|
this->m_GMatrix[i][i] = radial + xi * x[i]; |
| 58 |
|
} |
| 59 |
|
|
| 60 |
|
return this->m_GMatrix; |
| 61 |
|
} |
| 62 |
|
|
| 63 |
|
template <class TScalarType, unsigned int NDimensions> |
| 64 |
|
void |
| 65 |
|
ElasticBodyReciprocalSplineKernelTransform<TScalarType, NDimensions> |
| 66 |
|
::PrintSelf(std::ostream& os, Indent indent) const |
| 67 |
|
{ |
| 68 |
|
Superclass::PrintSelf(os,indent); |
| 69 |
|
os << indent << "m_Alpha: " << m_Alpha << std::endl; |
| 70 |
|
} |
| 71 |
|
|
| 72 |
|
} // namespace itk |
| 73 |
|
#endif |
| 74 |
|
|