ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkBalloonForceFilter.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 __itkBalloonForceFilter_h
19 #define __itkBalloonForceFilter_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 {
55 template< class TInputMesh, class TOutputMesh >
56 class ITK_EXPORT BalloonForceFilter:public MeshToMeshFilter< TInputMesh, TOutputMesh >
57 {
58 public:
64 
66  itkNewMacro(Self);
67 
70 
72  typedef TInputMesh InputMeshType;
73  typedef TOutputMesh OutputMeshType;
74 
76  typedef typename InputMeshType::PointsContainerPointer
78  typedef typename InputMeshType::PointsContainer::Iterator
80  typedef typename InputMeshType::PointsContainerConstPointer
82  typedef typename InputMeshType::PointsContainer::ConstIterator
84  typedef typename InputMeshType::PointDataContainerPointer
86  typedef typename InputMeshType::PointDataContainer::Iterator
88  typedef typename InputMeshType::CellsContainerPointer
90  typedef typename InputMeshType::CellsContainer::Iterator
92  typedef typename InputMeshType::CellDataContainerPointer
94  typedef typename InputMeshType::CellDataContainer::Iterator
96  typedef typename InputMeshType::CellsContainerConstPointer
98  typedef typename InputMeshType::CellsContainer::ConstIterator
100  typedef typename InputMeshType::CellDataContainerConstPointer
102  typedef typename InputMeshType::CellDataContainer::ConstIterator
104 
105  typedef typename OutputMeshType::PointsContainerPointer
107  typedef typename OutputMeshType::PointsContainer::Iterator
109 
111  typedef typename InputMeshType::PointType IPixelType;
112  typedef typename InputMeshType::PixelType PixelType;
113 
117  typedef typename InputMeshType::Pointer InputMeshPointer;
118  typedef typename InputMeshType::ConstPointer InputMeshConstPointer;
119  typedef typename OutputMeshType::Pointer OutputMeshPointer;
121  typedef typename ImageType::IndexType IndexType;
129 
131  typedef typename InputMeshType::CellType CellType;
132  typedef typename InputMeshType::CellTraits CellTraits;
133  typedef::itk::CellInterface< PixelType, CellTraits > CellInterface;
134  typedef::itk::TriangleCell< CellInterface > TriCell;
135 
137  void ComputeForce();
138 
139  void Initialize();
140 
141  void SetStiffnessMatrix();
142 
143  void Advance(); // update data for next iteration
144 
145  void Reset(); // reset all data
146 
147  void ComputeDt(); // compute point positions
148 
149  void ComputeOutput();
150 
151  void NodeAddition(int i, int res, IPixelType z); // (following 3) for adding
152  // new nodes, now disabled
153  // for further tests
154 
155  void NodesRearrange();
156 
157  void GapSearch();
158 
159  void GradientFit(); // fit the model with gradient information
160 
161  void ComputeNormals();
162 
163  void ACDSearch(); // remove weird structures on the model surface
164 
166  itkSetMacro(ImageOutput, ImagePointer);
167  itkGetConstMacro(ImageOutput, ImagePointer);
168  itkSetMacro(Gradient, GradientImagePointer);
170 
172  itkSetMacro(Stiffness, Double2Vector);
173  itkSetMacro(TimeStep, double);
174  itkSetMacro(GradientBegin, int);
175  itkSetMacro(Resolution, int);
176  itkSetMacro(Center, IndexType);
177  itkGetConstMacro(Normals, InputMeshPointer);
178  itkSetMacro(DistanceForGradient, float);
179  itkSetMacro(DistanceToStop, float);
180  itkSetMacro(Potential, ImagePointer);
181  itkGetConstMacro(Locations, InputMeshPointer);
182  itkGetConstMacro(Displacements, InputMeshPointer);
183  itkGetConstMacro(Derives, InputMeshPointer);
184  itkGetConstMacro(Forces, InputMeshPointer);
185 protected:
188  void PrintSelf(std::ostream & os, Indent indent) const;
190 
191  virtual void GenerateData();
192 
193 private:
194  BalloonForceFilter(const Self &); //purposely not implemented
195  void operator=(const Self &); //purposely not implemented
196 
205 
207  vnl_matrix_fixed< double, 4, 4 > m_NStiffness;
208  vnl_matrix_fixed< double, 4, 4 > m_SStiffness;
209  vnl_matrix_fixed< double, 4, 4 > m_CStiffness;
210  vnl_matrix_fixed< double, 4, 4 > **m_K;
211 
213  double m_TimeStep; // the time step of each iteration
216  float m_MiniT; // variabel help to stop the model when near
217  // potential estimation
218  int m_Step; // the number of iteration
219 
220  unsigned int m_NumberOfNodes;
221  unsigned int m_NumberOfCells;
222  unsigned int m_NumNewNodes; // for adding new nodes, now disabled for
223  // further tests
225  float ** m_NewNodes;
227  unsigned int m_NewNodeLimit;
228  unsigned int m_ImageWidth; // input image size
229  unsigned int m_ImageHeight;
230  unsigned int m_ImageDepth;
231 
232  int m_ModelXUpLimit; // the following 4 variables record the size of the
233  // model
237  int **m_ACD; // help to remove the weird structure on the model surface
240 
241  Int2Vector m_StepThreshold; // the threshold decide when to transfer from
242  // potential fit to gradient fit
243 
244  // and the threshold decide when to stop the model
248 
249  ImagePointer m_Potential; // for calculate of image force from
250  // potential
251  GradientImagePointer m_Gradient; // for calculate of image force from
252  // gradient
253 
254  // for Gibbs Prior Model parameters' recalculation
256  unsigned short m_ObjectLabel;
257 
259 };
260 } // end namespace itk
261 
262 #ifndef ITK_MANUAL_INSTANTIATION
263 #include "itkBalloonForceFilter.hxx"
264 #endif
265 
266 #endif
267