00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkBalloonForceFilter_h
00018 #define __itkBalloonForceFilter_h
00019
00020 #include "itkMeshToMeshFilter.h"
00021 #include "vnl/vnl_matrix_fixed.h"
00022 #include "vnl/vnl_math.h"
00023 #include "itkMesh.h"
00024 #include "itkVector.h"
00025 #include "itkTriangleCell.h"
00026 #include "itkImage.h"
00027 #include "itkImageRegionIterator.h"
00028
00029 namespace itk
00030 {
00031
00053 template <class TInputMesh, class TOutputMesh>
00054 class BalloonForceFilter : public MeshToMeshFilter<TInputMesh, TOutputMesh>
00055 {
00056 public:
00058 typedef BalloonForceFilter Self;
00059 typedef MeshToMeshFilter<TInputMesh, TOutputMesh> Superclass;
00060 typedef SmartPointer<Self> Pointer;
00061 typedef SmartPointer<const Self> ConstPointer;
00062
00064 itkNewMacro(Self);
00065
00067 itkTypeMacro(BalloonForceFilter,MeshToMeshFilter);
00068
00070 typedef TInputMesh InputMeshType;
00071 typedef TOutputMesh OutputMeshType;
00072
00074 typedef typename InputMeshType::PointsContainerPointer
00075 InputPointsContainerPointer;
00076 typedef typename InputMeshType::PointsContainer::Iterator
00077 InputPointsContainerIterator;
00078 typedef typename InputMeshType::PointDataContainerPointer
00079 InputPointDataContainerPointer;
00080 typedef typename InputMeshType::PointDataContainer::Iterator
00081 InputPointDataContainerIterator;
00082 typedef typename InputMeshType::CellsContainerPointer
00083 InputCellsContainerPointer;
00084 typedef typename InputMeshType::CellsContainer::Iterator
00085 InputCellsContainerIterator;
00086 typedef typename InputMeshType::CellDataContainerPointer
00087 InputCellDataContainerPointer;
00088 typedef typename InputMeshType::CellDataContainer::Iterator
00089 InputCellDataContainerIterator;
00090 typedef typename OutputMeshType::PointsContainerPointer
00091 OutputPointsContainerPointer;
00092 typedef typename OutputMeshType::PointsContainer::Iterator
00093 OutputPointsContainerIterator;
00094
00096 typedef Image<unsigned short, 3> ImageType;
00097 typedef typename InputMeshType::Pointer InputMeshPointer;
00098 typedef typename OutputMeshType::Pointer OutputMeshPointer;
00099 typedef typename ImageType::Pointer ImagePointer;
00100 typedef typename ImageType::IndexType IndexType;
00101 typedef ImageRegionIterator<ImageType> ImageIterator;
00102 typedef Vector<float, 3> FloatVector;
00103 typedef Vector<int, 3> IntVector;
00104
00106 typedef typename InputMeshType::CellType CellType;
00107 typedef typename InputMeshType::CellTraits CellTraits;
00108 typedef CellInterface<float, CellTraits> CellInterface;
00109 typedef TriangleCell< CellInterface > TriCell;
00110 typedef typename InputMeshType::PointType IPT;
00111 typedef typename InputMeshType::PixelType PT;
00112
00114 void ComputeForce();
00115 void Initialize();
00116 void SetStiffnessMatrix();
00117 void Advance();
00118 void SetStiffness(double a, double b);
00119 void SetResolution(int a, int b, int c);
00120 void SetCenter(int a, int b, int c);
00121 void Reset();
00122 void ComputeDt();
00123 void ComputeOutput();
00124 void SetPotential(ImagePointer potential);
00125 void SetGradient(ImagePointer gradient);
00126 void NodeAddition(int i, int res, IPT z);
00127 void NodesRearrange();
00128 void GapSearch();
00129 void GradientFit();
00130 void ComputeNormals();
00131 void ACDSearch();
00132
00134 itkSetMacro(ImageOutput, ImagePointer);
00135 itkGetMacro(ImageOutput, ImagePointer);
00136
00138 itkSetMacro(FirstSlice, int);
00139 itkGetMacro(FirstSlice, int);
00140
00142 itkSetMacro(NeighborRadius, int);
00143 itkSetMacro(StepThreshold1, int);
00144 itkSetMacro(StepThreshold2, int);
00145 itkGetMacro(Resolution, int*);
00146 itkGetMacro(Normals, InputMeshPointer);
00147
00148 protected:
00149 BalloonForceFilter();
00150 ~BalloonForceFilter() {}
00151 void PrintSelf(std::ostream& os, Indent indent) const;
00152
00153 virtual void GenerateData();
00154
00155 private:
00156 BalloonForceFilter(const Self&);
00157 void operator=(const Self&);
00158
00160 InputMeshPointer m_Forces;
00161 InputMeshPointer m_Normals;
00162 InputMeshPointer m_Displacements;
00163 InputMeshPointer m_Derives;
00164 InputMeshPointer m_Locations;
00165 InputMeshPointer m_Input;
00166 OutputMeshPointer m_Output;
00167
00169 vnl_matrix_fixed<double, 4, 4> NStiffness;
00170 vnl_matrix_fixed<double, 4, 4> SStiffness;
00171 vnl_matrix_fixed<double, 4, 4> CStiffness;
00172 vnl_matrix_fixed<double, 4, 4> **K;
00173
00174 double m_Stiffness[2];
00175 double TimeStep;
00176 int m_Resolution[3];
00177 IndexType m_Center;
00178 float m_MiniT;
00179 int m_Step;
00180 int m_NumNodes;
00181 int m_NumCells;
00182 int m_NumNewNodes;
00183 int *m_GapLocations;
00184 float **m_NewNodes;
00185 int m_NewNodesExisted;
00186 int m_NewNodeLimit;
00187 int m_ImageWidth;
00188 int m_ImageHeight;
00189 int m_ImageDepth;
00190 int m_ModelXUpLimit;
00191 int m_ModelXDownLimit;
00192 int m_ModelYUpLimit;
00193 int m_ModelYDownLimit;
00194 int **m_ACD;
00195 int m_ModelRestart;
00196 int m_StepThreshold1;
00197 int m_StepThreshold2;
00198 int m_FirstSlice;
00199 int m_NeighborRadius;
00200
00201 ImagePointer m_Potential;
00202 ImagePointer m_Gradient;
00203
00204
00205 ImagePointer m_ImageOutput;
00206 unsigned short m_ObjectLabel;
00207
00208 typedef ImageType::SizeType PotentialSizeType;
00209
00210 };
00211
00212 }
00213
00214 #ifndef ITK_MANUAL_INSTANTIATION
00215 #include "itkBalloonForceFilter.txx"
00216 #endif
00217
00218 #endif