ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkDeformableMesh3DFilter.h
Go to the documentation of this file.
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 applicable 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 __itkDeformableMesh3DFilter_h
19 #define __itkDeformableMesh3DFilter_h
20 
21 #include "itkMeshToMeshFilter.h"
22 #include "vnl/vnl_matrix_fixed.h"
23 #include "vnl/vnl_math.h"
24 #include "itkMesh.h"
25 #include "itkTriangleCell.h"
26 #include "itkImage.h"
27 #include "itkImageRegionIterator.h"
28 #include "itkCovariantVector.h"
29 
30 namespace itk
31 {
56 template< class TInputMesh, class TOutputMesh >
57 class ITK_EXPORT DeformableMesh3DFilter:public MeshToMeshFilter< TInputMesh, TOutputMesh >
58 {
59 public:
62 
65 
69 
71  itkNewMacro(Self);
72 
75 
77  typedef TInputMesh InputMeshType;
78  typedef typename InputMeshType::PointsContainerPointer InputPointsContainerPointer;
79  typedef typename InputMeshType::PointsContainerConstPointer InputPointsContainerConstPointer;
80  typedef typename InputMeshType::PointsContainer::Iterator InputPointsContainerIterator;
81  typedef typename InputMeshType::PointsContainer::ConstIterator InputPointsContainerConstIterator;
82  typedef typename InputMeshType::PointDataContainerPointer InputPointDataContainerPointer;
83  typedef typename InputMeshType::PointDataContainer::Iterator InputPointDataContainerIterator;
84  typedef typename InputMeshType::CellsContainerPointer InputCellsContainerPointer;
85  typedef typename InputMeshType::CellsContainer::Iterator InputCellsContainerIterator;
86  typedef typename InputMeshType::CellsContainerConstPointer InputCellsContainerConstPointer;
87  typedef typename InputMeshType::CellsContainer::ConstIterator InputCellsContainerConstIterator;
88  typedef typename InputMeshType::CellDataContainerPointer InputCellDataContainerPointer;
89  typedef typename InputMeshType::CellDataContainer::Iterator InputCellDataContainerIterator;
90  typedef typename InputMeshType::CellDataContainerConstPointer InputCellDataContainerConstPointer;
91  typedef typename InputMeshType::CellDataContainer::ConstIterator InputCellDataContainerConstIterator;
92 
93  typedef TOutputMesh OutputMeshType;
94  typedef typename OutputMeshType::PointsContainerPointer OutputPointsContainerPointer;
95  typedef typename OutputMeshType::CellsContainer OutputCellsContainer;
96  typedef typename OutputMeshType::CellsContainerPointer OutputCellsContainerPointer;
97  typedef typename OutputMeshType::PointsContainer::Iterator OutputPointsContainerIterator;
98 
100  typedef typename InputMeshType::CellType CellType;
101  typedef typename InputMeshType::CellTraits CellTraits;
102  typedef typename InputMeshType::PointType InputPointType;
103  typedef typename InputMeshType::PixelType PixelType;
104 
113 
116 
120 
121  /* Mesh pointer definition. */
122  typedef typename InputMeshType::Pointer InputMeshPointer;
123  typedef typename InputMeshType::ConstPointer InputMeshConstPointer;
124  typedef typename OutputMeshType::Pointer OutputMeshPointer;
126 
127  /* Stiffness Matrix Type definition */
128  typedef vnl_matrix_fixed< double, 4, 4 > StiffnessMatrixType;
130 
132  void SetStiffnessMatrix(StiffnessMatrixType *stiff, int i);
133 
135  itkSetMacro(Gradient, GradientImagePointer);
136  itkGetConstMacro(Gradient, GradientImagePointer);
138 
139  itkSetMacro(StepThreshold, int);
140  itkGetConstMacro(StepThreshold, int);
141 
142  itkSetMacro(Stiffness, double2DVector);
143  itkGetConstMacro(Stiffness, double2DVector);
144 
145  itkSetMacro(TimeStep, double);
146  itkGetConstMacro(TimeStep, double);
147 
148  itkSetMacro(Scale, double3DVector);
149 
150  itkSetMacro(PotentialMagnitude, PixelType);
151  itkSetMacro(GradientMagnitude, PixelType);
152  itkSetMacro(PotentialOn, unsigned short);
153  itkSetMacro(ObjectLabel, unsigned char);
154 
155  itkGetConstMacro(Normals, InputMeshPointer);
156 protected:
160  void operator=(const Self &) {}
161  void PrintSelf(std::ostream & os, Indent indent) const;
162 
163  virtual void GenerateData();
164 
165 private:
172 
173  void Initialize();
174 
175  void SetDefaultStiffnessMatrix();
176 
177  void SetMeshStiffness();
178 
179  void Advance(); // update data for next iteration
180 
181  void ComputeDt(); // compute point positions
182 
183  void ComputeOutput();
184 
185  void GradientFit(); // fit the model with gradient information
186 
187  void ComputeNormals();
188 
189  void PotentialFit();
190 
192  StiffnessMatrixType m_StiffnessMatrix[10];
194 
197 
200 
204 
208 
212  unsigned short m_ModelXUpLimit;
213  unsigned short m_ModelXDownLimit;
214  unsigned short m_ModelYUpLimit;
215  unsigned short m_ModelYDownLimit;
216  unsigned short m_ModelZUpLimit;
217  unsigned short m_ModelZDownLimit;
218  unsigned short m_PotentialOn;
219  unsigned char m_ObjectLabel;
222 
226 };
227 } // end namespace itk
228 
229 #ifndef ITK_MANUAL_INSTANTIATION
230 #include "itkDeformableMesh3DFilter.hxx"
231 #endif
232 
233 #endif
234