19 #include "itkPSMTwoCostFunction.h" 24 template <
unsigned int VDimension>
30 typedef SmartPointer<Self> Pointer;
31 typedef SmartPointer<const Self> ConstPointer;
52 virtual VectorType
Evaluate(
unsigned int,
unsigned int,
53 const ParticleSystemType *,
double &maxtimestep,
56 maxtimestep = m_Value;
62 virtual VectorType
Evaluate(
unsigned int a,
unsigned int b,
63 const ParticleSystemType *c,
double &d)
const 68 virtual double Energy(
unsigned int a,
unsigned int b,
69 const ParticleSystemType *c)
const 82 void SetValue(
double v) {m_Value = v;}
83 double GetValue()
const {
return m_Value;}
97 int itkPSMTwoCostFunctionTest(
int,
char* [] )
100 std::string errstring =
"";
119 P->SetFunctionA(cfa);
120 P->SetFunctionB(cfb);
124 double maxtimestep = aval;
125 double energy = aval;
126 res = P->
Evaluate(0,0,ps,maxtimestep,energy);
133 if ( res != avec + bvec )
136 errstring =
"Problem calling the Evaluate function";
141 res = P->
Evaluate(0,0,ps,maxtimestep,energy);
145 errstring =
"Problem disabling B function";
151 res = P->
Evaluate(0,0,ps,maxtimestep,energy);
155 errstring =
"Problem re-enabling B function or disabling A function";
161 P->SetRelativeGradientScaling(2.0);
162 res = P->
Evaluate(0,0,ps,maxtimestep,energy);
163 if ( res != avec + (bvec * 2.0) )
166 errstring =
"Problem calling the Evaluate function";
172 catch(itk::ExceptionObject &e)
174 errstring =
"ITK exception with description: " + std::string(e.GetDescription())
175 + std::string(
"\n at location:") + std::string(e.GetLocation())
176 + std::string(
"\n in file:") + std::string(e.GetFile());
181 errstring =
"Unknown exception thrown";
187 std::cout <<
"All tests passed" << std::endl;
192 std::cout <<
"Test failed with the following error:" << std::endl;
193 std::cout << errstring << std::endl;
virtual void AfterIteration()
itkStaticConstMacro(Dimension, unsigned int, VDimension)
virtual VectorType Evaluate(unsigned int, unsigned int, const ParticleSystemType *, double &maxtimestep, double &energy) const
virtual VectorType Evaluate(unsigned int idx, unsigned int d, const ParticleSystemType *system, double &maxmove) const
A facade class that manages interactions with a particle system.
Superclass::VectorType VectorType
virtual void SetParticleSystem(ParticleSystemType *p)
virtual void BeforeIteration()
vnl_vector_fixed< double, VDimension > VectorType
virtual VectorType Evaluate(unsigned int a, unsigned int b, const ParticleSystemType *c, double &d) const
PSMParticleSystem< VDimension > ParticleSystemType
Superclass::ParticleSystemType ParticleSystemType