#pragma once#include"itkParticleEntropyGradientFunction.h"#include"ParticleImageDomainWithGradients.h"#include"ParticleImageDomainWithCurvature.h"#include"itkParticleMeanCurvatureAttribute.h"#include"itkCommand.h"// PRATEEP#include<fstream>#include<math.h>#include"itkMath.h"// end PRATEEPnamespaceitk{template<classTGradientNumericType,unsignedintVDimension>classParticleModifiedCotangentEntropyGradientFunction:publicParticleEntropyGradientFunction<TGradientNumericType,VDimension>{public:typedefParticleModifiedCotangentEntropyGradientFunctionSelf;typedefSmartPointer<Self>Pointer;typedefSmartPointer<constSelf>ConstPointer;typedefParticleEntropyGradientFunction<TGradientNumericType,VDimension>Superclass;itkTypeMacro(ParticleModifiedCotangentEntropyGradientFunction,ParticleEntropyGradientFunction);typedeftypenameSuperclass::GradientNumericTypeGradientNumericType;typedeftypenameSuperclass::ParticleSystemTypeParticleSystemType;typedeftypenameSuperclass::VectorTypeVectorType;typedeftypenameSuperclass::PointTypePointType;typedeftypenameSuperclass::GradientVectorTypeGradientVectorType;typedeftypenameshapeworks::ParticleImageDomainWithCurvature<TGradientNumericType>::VnlMatrixTypeVnlMatrixType;itkNewMacro(Self);itkStaticConstMacro(Dimension,unsignedint,VDimension);inlinevirtualVectorTypeEvaluate(unsignedinta,unsignedintb,constParticleSystemType*c,double&d)const{doublee;returnthis->Evaluate(a,b,c,d,e);}virtualVectorTypeEvaluate(unsignedint,unsignedint,constParticleSystemType*,double&,double&)const;virtualvoidBeforeEvaluate(unsignedint,unsignedint,constParticleSystemType*){}inlinevirtualdoubleEnergy(unsignedinta,unsignedintb,constParticleSystemType*c)const{doubled,e;this->Evaluate(a,b,c,d,e);returne;}virtualvoidAfterIteration(){}virtualvoidBeforeIteration(){// not needed -- Praful}inlinedoubleComputeModifiedCotangent(doublerij,unsignedintd)const{if(rij>m_GlobalSigma[d])return0.0;constdoubleepsilon=1.0e-6;rij+=epsilon;doubler=itk::Math::pi_over_2*rij/m_GlobalSigma[d];doublecotan=cos(r)/sin(r);doubleval=cotan+r-itk::Math::pi_over_2;doubleA=-1.0*itk::Math::pi_over_4*m_GlobalSigma[d]-itk::Math::pi_over_4*std::pow(epsilon,2)/m_GlobalSigma[d]+itk::Math::pi_over_2*epsilon;A-=(m_GlobalSigma[d]/itk::Math::pi_over_2)*std::log(std::sin(epsilon*itk::Math::pi_over_2/m_GlobalSigma[d]));val/=A;returnval;}inlinedoubleComputeModifiedCotangentDerivative(doublerij,unsignedintd)const{if(rij>m_GlobalSigma[d])return0.0;constdoubleepsilon=1.0e-6;rij+=epsilon;doubler=itk::Math::pi_over_2*rij/m_GlobalSigma[d];doublesin_2=1.0/pow(sin(r),2.0);doubleval=(itk::Math::pi_over_2/m_GlobalSigma[d])*(1.0-sin_2);doubleA=-1.0*itk::Math::pi_over_4*m_GlobalSigma[d]-itk::Math::pi_over_4*std::pow(epsilon,2)/m_GlobalSigma[d]+itk::Math::pi_over_2*epsilon;A-=(m_GlobalSigma[d]/itk::Math::pi_over_2)*std::log(std::sin(epsilon*itk::Math::pi_over_2/m_GlobalSigma[d]));val/=A;returnval;}voidClearGlobalSigma(){m_GlobalSigma.clear();}voidSetGlobalSigma(std::vector<double>i){m_GlobalSigma=i;}voidSetGlobalSigma(doublei){m_GlobalSigma.push_back(i);}virtualtypenameParticleVectorFunction<VDimension>::PointerClone(){typenameParticleModifiedCotangentEntropyGradientFunction<TGradientNumericType,VDimension>::Pointercopy=ParticleModifiedCotangentEntropyGradientFunction<TGradientNumericType,VDimension>::New();copy->SetParticleSystem(this->GetParticleSystem());copy->m_GlobalSigma=this->m_GlobalSigma;copy->m_MinimumNeighborhoodRadius=this->m_MinimumNeighborhoodRadius;copy->m_MaximumNeighborhoodRadius=this->m_MaximumNeighborhoodRadius;copy->m_FlatCutoff=this->m_FlatCutoff;copy->m_NeighborhoodToSigmaRatio=this->m_NeighborhoodToSigmaRatio;copy->m_DomainNumber=this->m_DomainNumber;copy->m_ParticleSystem=this->m_ParticleSystem;return(typenameParticleVectorFunction<VDimension>::Pointer)copy;}protected:ParticleModifiedCotangentEntropyGradientFunction(){}virtual~ParticleModifiedCotangentEntropyGradientFunction(){}voidoperator=(constParticleModifiedCotangentEntropyGradientFunction&);ParticleModifiedCotangentEntropyGradientFunction(constParticleModifiedCotangentEntropyGradientFunction&);std::vector<double>m_GlobalSigma;};}//end namespace#include"itkParticleModifiedCotangentEntropyGradientFunction.txx"