18 #ifndef __itkBSplineSecondOrderDerivativeKernelFunction2_h
19 #define __itkBSplineSecondOrderDerivativeKernelFunction2_h
21 #include "itkKernelFunctionBase.h"
22 #include "vnl/vnl_math.h"
42 template<
unsigned int VSplineOrder = 3 >
62 inline double Evaluate(
const double & u )
const
64 return this->
Evaluate( Dispatch< VSplineOrder >(), u );
69 inline void Evaluate(
const double & u,
double * weights )
const
71 this->
Evaluate( Dispatch< VSplineOrder >(), u, weights );
80 void PrintSelf( std::ostream & os, Indent indent )
const
82 Superclass::PrintSelf( os, indent );
83 os << indent <<
"Spline Order: " << SplineOrder << std::endl;
93 struct DispatchBase {};
94 template<
unsigned int >
95 struct Dispatch : DispatchBase {};
104 inline double Evaluate(
const Dispatch< 2 > &,
const double & u )
const
106 double absValue = vnl_math_abs( u );
112 else if( absValue == 0.5 )
116 else if( absValue < 1.5 )
120 else if( absValue == 1.5 )
131 inline void Evaluate(
const Dispatch< 2 > &,
const double & u,
double * weights )
const
140 inline double Evaluate(
const Dispatch< 3 > &,
const double & u )
const
142 const double absValue = vnl_math_abs( u );
146 return vnl_math_sgn0( u ) * ( 3.0 * u ) - 2.0;
148 else if( absValue < 2.0 )
150 return -vnl_math_sgn( u ) * u + 2.0;
159 inline void Evaluate(
const Dispatch< 3 > &,
const double & u,
double * weights )
const
161 weights[ 0 ] = -u + 2.0;
162 weights[ 1 ] = 3.0 * u - 5.0;
163 weights[ 2 ] = -3.0 * u + 4.0;
164 weights[ 3 ] = u - 1.0;
169 inline double Evaluate(
const DispatchBase &,
const double & )
const
171 itkExceptionMacro(
"Evaluate not implemented for spline order " << SplineOrder );
177 inline void Evaluate(
const DispatchBase &,
const double &,
double * )
const
179 itkExceptionMacro(
"Evaluate not implemented for spline order " << SplineOrder );