Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkBalloonForceFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkBalloonForceFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-11-22 18:19:44 $
00007   Version:   $Revision: 1.42 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00014      PURPOSE.  See the above copyright notices for more information.
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 ITK_EXPORT 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::PointsContainerConstPointer
00081   InputPointsContainerConstPointer;
00082   typedef typename InputMeshType::PointsContainer::ConstIterator
00083   InputPointsContainerConstIterator;
00084   typedef typename InputMeshType::PointDataContainerPointer
00085   InputPointDataContainerPointer;
00086   typedef typename InputMeshType::PointDataContainer::Iterator
00087   InputPointDataContainerIterator;
00088   typedef typename InputMeshType::CellsContainerPointer
00089   InputCellsContainerPointer;
00090   typedef typename InputMeshType::CellsContainer::Iterator
00091   InputCellsContainerIterator;
00092   typedef typename InputMeshType::CellDataContainerPointer
00093   InputCellDataContainerPointer;
00094   typedef typename InputMeshType::CellDataContainer::Iterator
00095   InputCellDataContainerIterator;
00096   typedef typename InputMeshType::CellsContainerConstPointer
00097   InputCellsContainerConstPointer;
00098   typedef typename InputMeshType::CellsContainer::ConstIterator
00099   InputCellsContainerConstIterator;
00100   typedef typename InputMeshType::CellDataContainerConstPointer
00101   InputCellDataContainerConstPointer;
00102   typedef typename InputMeshType::CellDataContainer::ConstIterator
00103   InputCellDataContainerConstIterator;
00104 
00105   typedef typename OutputMeshType::PointsContainerPointer
00106   OutputPointsContainerPointer;
00107   typedef typename OutputMeshType::PointsContainer::Iterator
00108   OutputPointsContainerIterator;
00109 
00111   typedef typename InputMeshType::PointType   IPixelType;
00112   typedef typename InputMeshType::PixelType   PixelType;
00113 
00114   typedef Image<unsigned short, 2>              ImageType;
00115   typedef CovariantVector<PixelType, 2>         GradientType;
00116   typedef Image<GradientType, 2>                GradientImageType;
00117   typedef typename InputMeshType::Pointer       InputMeshPointer;
00118   typedef typename InputMeshType::ConstPointer  InputMeshConstPointer;
00119   typedef typename OutputMeshType::Pointer      OutputMeshPointer;
00120   typedef typename ImageType::Pointer           ImagePointer;
00121   typedef typename ImageType::IndexType         IndexType;
00122   typedef typename GradientImageType::Pointer   GradientImagePointer;
00123   typedef typename GradientImageType::IndexType GradientIndexType;
00124   typedef ImageRegionIterator<ImageType>        ImageIterator;
00125   typedef Vector<float, 3>                      FloatVector;
00126   typedef Vector<int, 3>                        IntVector;
00127   typedef Vector<double, 2>                     Double2Vector;
00128   typedef Vector<int, 2>                        Int2Vector;
00129 
00131   typedef typename InputMeshType::CellType              CellType;
00132   typedef typename InputMeshType::CellTraits            CellTraits;
00133   typedef ::itk::CellInterface<PixelType, CellTraits>   CellInterface;
00134   typedef ::itk::TriangleCell< CellInterface >          TriCell;
00135 
00136 
00138   void ComputeForce();
00139   void Initialize();
00140   void SetStiffnessMatrix();
00141   void Advance();             // update data for next iteration
00142   void Reset();               // reset all data
00143   void ComputeDt();             // compute point positions
00144   void ComputeOutput();
00145   void NodeAddition(int i, int res, IPixelType z); // (folowing 3) for adding new nodes, now disabled for further tests
00146   void NodesRearrange();
00147   void GapSearch();
00148   void GradientFit();           // fit the model with gradient information
00149   void ComputeNormals();
00150   void ACDSearch();             // remove weird structures on the model surface
00152 
00154   itkSetMacro(ImageOutput, ImagePointer);
00155   itkGetConstMacro(ImageOutput, ImagePointer);
00156   itkSetMacro(Gradient, GradientImagePointer);
00158 
00160   itkSetMacro(Stiffness, Double2Vector);
00161   itkSetMacro(TimeStep, double);
00162   itkSetMacro(GradientBegin, int);
00163   itkSetMacro(Resolution, int);
00164   itkSetMacro(Center, IndexType);
00165   itkGetConstMacro(Normals, InputMeshPointer);
00166   itkSetMacro(DistanceForGradient, float);
00167   itkSetMacro(DistanceToStop, float);
00168   itkSetMacro(Potential, ImagePointer);
00169   itkGetConstMacro(Locations, InputMeshPointer);
00170   itkGetConstMacro(Displacements, InputMeshPointer);
00171   itkGetConstMacro(Derives, InputMeshPointer);
00172   itkGetConstMacro(Forces, InputMeshPointer);
00174 
00175 protected:
00176   BalloonForceFilter();
00177   ~BalloonForceFilter();
00178   void PrintSelf(std::ostream& os, Indent indent) const;
00179 
00180   virtual void GenerateData();
00181 
00182 private:
00183   BalloonForceFilter(const Self&); //purposely not implemented
00184   void operator=(const Self&); //purposely not implemented
00185 
00187   InputMeshPointer  m_Forces;
00188   InputMeshPointer  m_Normals;
00189   InputMeshPointer  m_Displacements;
00190   InputMeshPointer  m_Derives;
00191   InputMeshPointer  m_Locations;
00192   InputMeshPointer  m_Input;
00193   OutputMeshPointer m_Output;
00194 
00196   vnl_matrix_fixed<double, 4, 4>   m_NStiffness;
00197   vnl_matrix_fixed<double, 4, 4>   m_SStiffness;
00198   vnl_matrix_fixed<double, 4, 4>   m_CStiffness;
00199   vnl_matrix_fixed<double, 4, 4> **m_K;
00200 
00201   Double2Vector  m_Stiffness;
00202   double         m_TimeStep;       // the time step of each iteration
00203   int            m_Resolution;
00204   IndexType      m_Center;
00205   float          m_MiniT;        // variabel help to stop the model when near potential estimation
00206   int            m_Step;         // the number of iteration
00207 
00208   unsigned int   m_NumberOfNodes;
00209   unsigned int   m_NumberOfCells;
00210   unsigned int   m_NumNewNodes;      // for adding new nodes, now disabled for further tests
00211   int           *m_GapLocations;
00212   float        **m_NewNodes;
00213   int            m_NewNodesExisted;
00214   unsigned int   m_NewNodeLimit;
00215   unsigned int   m_ImageWidth;       // input image size
00216   unsigned int   m_ImageHeight;
00217   unsigned int   m_ImageDepth;
00218 
00219   int   m_ModelXUpLimit;    // the following 4 variables record the size of the model
00220   int   m_ModelXDownLimit;
00221   int   m_ModelYUpLimit;
00222   int   m_ModelYDownLimit;
00223   int **m_ACD;        // help to remove the weird structure on the model surface
00224   int   m_ModelRestart;
00225   int   m_GradientBegin;
00226 
00227   Int2Vector   m_StepThreshold;   // the threshold decide when to transfer from potential fit to gradient fit
00228 
00229   // and the threshold decide when to stop the model
00230   float m_DistanceToBoundary;
00231   float m_DistanceToStop;
00232   float m_DistanceForGradient;
00233 
00234   ImagePointer            m_Potential;  // for calculate of image force from potential
00235   GradientImagePointer    m_Gradient;   // for calculate of image force from gradient
00236 
00237   // for Gibbs Prior Model parameters' recalculation
00238   ImagePointer    m_ImageOutput;
00239   unsigned short  m_ObjectLabel;
00240 
00241   typedef ImageType::SizeType ImageSizeType;
00242 
00243 };
00244 
00245 } // end namespace itk
00246 
00247 #ifndef ITK_MANUAL_INSTANTIATION
00248 #include "itkBalloonForceFilter.txx"
00249 #endif
00250 
00251 #endif
00252 

Generated at Mon Jul 12 2010 17:45:53 for ITK by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2000