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 #include <itkCovariantVector.h>
00029
00030 namespace itk
00031 {
00032
00055 template <class TInputMesh, class TOutputMesh>
00056 class BalloonForceFilter : public MeshToMeshFilter<TInputMesh, TOutputMesh>
00057 {
00058 public:
00060 typedef BalloonForceFilter Self;
00061 typedef MeshToMeshFilter<TInputMesh, TOutputMesh> Superclass;
00062 typedef SmartPointer<Self> Pointer;
00063 typedef SmartPointer<const Self> ConstPointer;
00064
00066 itkNewMacro(Self);
00067
00069 itkTypeMacro(BalloonForceFilter,MeshToMeshFilter);
00070
00072 typedef TInputMesh InputMeshType;
00073 typedef TOutputMesh OutputMeshType;
00074
00076 typedef typename InputMeshType::PointsContainerPointer
00077 InputPointsContainerPointer;
00078 typedef typename InputMeshType::PointsContainer::Iterator
00079 InputPointsContainerIterator;
00080 typedef typename InputMeshType::PointDataContainerPointer
00081 InputPointDataContainerPointer;
00082 typedef typename InputMeshType::PointDataContainer::Iterator
00083 InputPointDataContainerIterator;
00084 typedef typename InputMeshType::CellsContainerPointer
00085 InputCellsContainerPointer;
00086 typedef typename InputMeshType::CellsContainer::Iterator
00087 InputCellsContainerIterator;
00088 typedef typename InputMeshType::CellDataContainerPointer
00089 InputCellDataContainerPointer;
00090 typedef typename InputMeshType::CellDataContainer::Iterator
00091 InputCellDataContainerIterator;
00092 typedef typename OutputMeshType::PointsContainerPointer
00093 OutputPointsContainerPointer;
00094 typedef typename OutputMeshType::PointsContainer::Iterator
00095 OutputPointsContainerIterator;
00096
00098 typedef typename InputMeshType::PointType IPixelType;
00099 typedef typename InputMeshType::PixelType PixelType;
00100
00101 typedef Image<unsigned short, 2> ImageType;
00102 typedef CovariantVector<PixelType, 2> GradientType;
00103 typedef Image<GradientType, 2> GradientImageType;
00104 typedef typename InputMeshType::Pointer InputMeshPointer;
00105 typedef typename OutputMeshType::Pointer OutputMeshPointer;
00106 typedef typename ImageType::Pointer ImagePointer;
00107 typedef typename ImageType::IndexType IndexType;
00108 typedef typename GradientImageType::Pointer GradientImagePointer;
00109 typedef typename GradientImageType::IndexType GradientIndexType;
00110 typedef ImageRegionIterator<ImageType> ImageIterator;
00111 typedef Vector<float, 3> FloatVector;
00112 typedef Vector<int, 3> IntVector;
00113 typedef Vector<double, 2> Double2Vector;
00114 typedef Vector<int, 2> Int2Vector;
00115
00117 typedef typename InputMeshType::CellType CellType;
00118 typedef typename InputMeshType::CellTraits CellTraits;
00119 typedef CellInterface<PixelType, CellTraits> CellInterface;
00120 typedef TriangleCell< CellInterface > TriCell;
00121
00122
00124 void ComputeForce();
00125 void Initialize();
00126 void SetStiffnessMatrix();
00127 void Advance();
00128 void Reset();
00129 void ComputeDt();
00130 void ComputeOutput();
00131 void NodeAddition(int i, int res, IPixelType z);
00132 void NodesRearrange();
00133 void GapSearch();
00134 void GradientFit();
00135 void ComputeNormals();
00136 void ACDSearch();
00137
00139 itkSetMacro(ImageOutput, ImagePointer);
00140 itkGetMacro(ImageOutput, ImagePointer);
00141 itkSetMacro(Gradient, GradientImagePointer);
00142
00144 itkSetMacro(NeighborRadius, int);
00145 itkSetMacro(Stiffness, Double2Vector);
00146 itkSetMacro(TimeStep, double);
00147 itkSetMacro(GradientBegin, int);
00148 itkSetMacro(Resolution, int);
00149 itkSetMacro(Center, IndexType);
00150 itkGetMacro(Normals, InputMeshPointer);
00151 itkSetMacro(DistanceForGradient, float);
00152 itkSetMacro(DistanceToStop, float);
00153 itkSetMacro(Potential, ImagePointer);
00154 itkGetMacro(Locations, InputMeshPointer);
00155 itkGetMacro(Displacements, InputMeshPointer);
00156 itkGetMacro(Derives, InputMeshPointer);
00157 itkGetMacro(Forces, InputMeshPointer);
00158
00159 protected:
00160 BalloonForceFilter();
00161 ~BalloonForceFilter();
00162 void PrintSelf(std::ostream& os, Indent indent) const;
00163
00164 virtual void GenerateData();
00165
00166 private:
00167 BalloonForceFilter(const Self&);
00168 void operator=(const Self&);
00169
00171 InputMeshPointer m_Forces;
00172 InputMeshPointer m_Normals;
00173 InputMeshPointer m_Displacements;
00174 InputMeshPointer m_Derives;
00175 InputMeshPointer m_Locations;
00176 InputMeshPointer m_Input;
00177 OutputMeshPointer m_Output;
00178
00180 vnl_matrix_fixed<double, 4, 4> NStiffness;
00181 vnl_matrix_fixed<double, 4, 4> SStiffness;
00182 vnl_matrix_fixed<double, 4, 4> CStiffness;
00183 vnl_matrix_fixed<double, 4, 4> **K;
00184
00185 Double2Vector m_Stiffness;
00186 double m_TimeStep;
00187 int m_Resolution;
00188 IndexType m_Center;
00189 float m_MiniT;
00190 int m_Step;
00191 unsigned int m_NumberOfNodes;
00192 unsigned int m_NumberOfCells;
00193 unsigned int m_NumNewNodes;
00194 int *m_GapLocations;
00195 float **m_NewNodes;
00196 int m_NewNodesExisted;
00197 unsigned int m_NewNodeLimit;
00198 unsigned int m_ImageWidth;
00199 unsigned int m_ImageHeight;
00200 unsigned int m_ImageDepth;
00201 int m_ModelXUpLimit;
00202 int m_ModelXDownLimit;
00203 int m_ModelYUpLimit;
00204 int m_ModelYDownLimit;
00205 int **m_ACD;
00206 int m_ModelRestart;
00207 int m_GradientBegin;
00208 Int2Vector m_StepThreshold;
00209
00210 int m_NeighborRadius;
00211 float m_DistanceToBoundary;
00212 float m_DistanceToStop;
00213 float m_DistanceForGradient;
00214
00215 ImagePointer m_Potential;
00216 GradientImagePointer m_Gradient;
00217
00218
00219 ImagePointer m_ImageOutput;
00220 unsigned short m_ObjectLabel;
00221
00222 typedef ImageType::SizeType ImageSizeType;
00223
00224 };
00225
00226 }
00227
00228 #ifndef ITK_MANUAL_INSTANTIATION
00229 #include "itkBalloonForceFilter.txx"
00230 #endif
00231
00232 #endif