Shapeworks Studio  2.1
Shape analysis software suite
itkPSMCostFunction.h
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicabcle law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkPSMCostFunction_h
19 #define __itkPSMCostFunction_h
20 
21 #include "itkLightObject.h"
22 #include "itkObjectFactory.h"
23 #include "itkWeakPointer.h"
24 #include "itkPSMParticleSystem.h"
25 #include "vnl/vnl_vector_fixed.h"
26 
27 namespace itk
28 {
29 
51 template <unsigned int VDimension>
52 class PSMCostFunction : public LightObject
53 {
54 public:
57  typedef SmartPointer<Self> Pointer;
58  typedef SmartPointer<const Self> ConstPointer;
59  typedef LightObject Superclass;
60  itkTypeMacro( PSMCostFunction, LightObject);
61 
64 
66  typedef vnl_vector_fixed<double, VDimension> VectorType;
67 
69  // itkNewMacro(Self);
70 
72  itkStaticConstMacro(Dimension, unsigned int, VDimension);
73 
79  virtual VectorType Evaluate(unsigned int , unsigned int, const ParticleSystemType *,
80  double &maxtimestep) const = 0;
81  virtual VectorType Evaluate(unsigned int , unsigned int, const ParticleSystemType *,
82  double &maxtimestep, double &energy) const = 0;
83  virtual double Energy(unsigned int, unsigned int, const ParticleSystemType *) const = 0;
84 
85 
87  virtual void ResetBuffers() { }
88 
91  virtual void AfterIteration() { }
92 
95  virtual void BeforeIteration() {}
96 
102  virtual void BeforeEvaluate(unsigned int , unsigned int, const ParticleSystemType *) {}
103 
106  virtual void SetParticleSystem( ParticleSystemType *p)
107  { m_ParticleSystem = p; }
108  virtual ParticleSystemType *GetParticleSystem() const
109  { return m_ParticleSystem; }
110  virtual void SetDomainNumber( unsigned int i)
111  { m_DomainNumber = i; }
112  virtual int GetDomainNumber() const
113  { return m_DomainNumber; }
114 
115 protected:
116  PSMCostFunction() : m_ParticleSystem(0), m_DomainNumber(0) {}
117  virtual ~PSMCostFunction() {}
118  void operator=(const PSMCostFunction &);
120 
121  ParticleSystemType *m_ParticleSystem;
122  unsigned int m_DomainNumber;
123 };
124 
125 } //end namespace
126 
127 #endif
virtual void ResetBuffers()
virtual void BeforeEvaluate(unsigned int, unsigned int, const ParticleSystemType *)
virtual VectorType Evaluate(unsigned int, unsigned int, const ParticleSystemType *, double &maxtimestep) const =0
virtual void SetParticleSystem(ParticleSystemType *p)
A facade class that manages interactions with a particle system.
virtual void AfterIteration()
vnl_vector_fixed< double, VDimension > VectorType
virtual void BeforeIteration()
PSMParticleSystem< VDimension > ParticleSystemType
itkStaticConstMacro(Dimension, unsigned int, VDimension)