00001 #if defined (_MSC_VER) && (_MSC_VER >= 1000)
00002 #pragma once
00003 #endif
00004 #ifndef _INC_Phys_Euler_422B64F703C8_INCLUDED
00005 #define _INC_Phys_Euler_422B64F703C8_INCLUDED
00006 #include "stdafx.h"
00007 #include "Physics.h"
00008 #include "SpringMassDeformation.h"
00009
00010
00011
00012
00013 #include <itkVectorLinearInterpolateImageFunction.h>
00014
00015 #include <math.h>
00016
00017 #define DEBUG 0
00018 #define BOUND_CHECKING 1
00019
00020 namespace mial
00021 {
00022
00024
00045 template<class DataType, class TGradientImage, int nDims,class MType = vnl_matrix<DataType>, class VType = vnl_vector<DataType> >
00046 class Phys_Euler: public Physics<DataType,nDims, MType,VType>
00047 {
00048
00049
00050
00051
00052 public:
00053
00054 typedef Phys_Euler Self;
00055 typedef itk::SmartPointer<Self> Pointer;
00056 typedef itk::SmartPointer<const Self> ConstPointer;
00057 typedef itk::WeakPointer<const Self> ConstWeakPointer;
00058 itkNewMacro(Self);
00059
00060
00061 typedef SpringMassDeformation<DataType,nDims,MType,VType> DeformationType;
00062
00063 typedef MType MatrixType;
00064 typedef VType VectorType;
00065 typedef TGradientImage GradientImageType;
00066
00067 struct Error: public Physics<DataType,nDims,MType,VType>::Error
00068 {
00069
00070 };
00071
00072
00073
00074
00075 protected:
00076
00077
00079 typedef typename GradientImageType::Pointer GradientImageTypePointer;
00080
00082 MatrixType nodes;
00083
00085 MatrixType nodesV;
00086
00088 MatrixType nodesF;
00089
00091 MatrixType nodesFDef;
00092
00094 MatrixType nodesA;
00095
00097 VectorType nodesM;
00098
00100 DataType defaultMass;
00101
00103 VectorType springsRest;
00104
00106 VectorType springsDamp;
00107
00109 DataType defaultDamp;
00110
00112 MatrixType springsNodes;
00113
00115 VectorType springLengths;
00116
00118 VectorType springsK;
00119
00121 DataType defaultK;
00122
00124 DataType defaultDrag;
00125
00127 double timeStep;
00128
00129
00131 GradientImageTypePointer gradientPointer;
00132
00134 bool imageForces;
00135
00136
00137
00138 public:
00139
00141
00147 virtual bool runDeformation(const std::string defName,typename DeformationType::deformationIn* const i,std::stringstream * const s = NULL);
00148
00150
00155 virtual void setRestLengths(int* a, DataType* values, int n);
00156
00158
00162 virtual void setRestLengths(VectorType a, VectorType values);
00163
00165
00168 virtual void setTimeStep(double a){timeStep = a;}
00169
00171
00176 virtual void setSpringLengths(int* a, DataType* values, int n);
00177
00179
00183 virtual void setSpringLengths(VectorType a, VectorType values);
00184
00185
00187
00192 virtual void setSpringsK(int* a, DataType* values, int n);
00193
00195
00199 virtual void setSpringsK(VectorType a, VectorType values);
00200
00202 virtual void enableImageForces(){imageForces = true;};
00203
00205 virtual void disableImageForces(){imageForces = false;};
00206
00208 virtual bool simulate();
00209
00211 virtual void setExternalForces(void * f){gradientPointer = *((GradientImageTypePointer *) f);};
00212
00213
00214 protected:
00215 Phys_Euler(int numNodes =0 ,int numSprings = 0, int numPossibleDeformations = 0, int defK = 35);
00216
00217 private:
00218 virtual void updateSpringsFromGeometric();
00219
00220 };
00221 }
00222 #include "Phys_Euler.cxx"
00223 #endif