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-04-23 03:53:34 $
00007   Version:   $Revision: 1.40 $
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::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 ::itk::CellInterface<PixelType, CellTraits>   CellInterface;
00120   typedef ::itk::TriangleCell< CellInterface >          TriCell;
00121 
00122 
00124   void ComputeForce();
00125   void Initialize();
00126   void SetStiffnessMatrix();
00127   void Advance();             // update data for next iteration
00128   void Reset();               // reset all data
00129   void ComputeDt();             // compute point positions
00130   void ComputeOutput();
00131   void NodeAddition(int i, int res, IPixelType z); // (folowing 3) for adding new nodes, now disabled for further tests
00132   void NodesRearrange();
00133   void GapSearch();
00134   void GradientFit();           // fit the model with gradient information
00135   void ComputeNormals();
00136   void ACDSearch();             // remove weird structures on the model surface
00138 
00140   itkSetMacro(ImageOutput, ImagePointer);
00141   itkGetConstMacro(ImageOutput, ImagePointer);
00142   itkSetMacro(Gradient, GradientImagePointer);
00144 
00146   itkSetMacro(Stiffness, Double2Vector);
00147   itkSetMacro(TimeStep, double);
00148   itkSetMacro(GradientBegin, int);
00149   itkSetMacro(Resolution, int);
00150   itkSetMacro(Center, IndexType);
00151   itkGetConstMacro(Normals, InputMeshPointer);
00152   itkSetMacro(DistanceForGradient, float);
00153   itkSetMacro(DistanceToStop, float);
00154   itkSetMacro(Potential, ImagePointer);
00155   itkGetConstMacro(Locations, InputMeshPointer);
00156   itkGetConstMacro(Displacements, InputMeshPointer);
00157   itkGetConstMacro(Derives, InputMeshPointer);
00158   itkGetConstMacro(Forces, InputMeshPointer);
00160 
00161 protected:
00162   BalloonForceFilter();
00163   ~BalloonForceFilter();
00164   void PrintSelf(std::ostream& os, Indent indent) const;
00165 
00166   virtual void GenerateData();
00167 
00168 private:
00169   BalloonForceFilter(const Self&); //purposely not implemented
00170   void operator=(const Self&); //purposely not implemented
00171 
00173   InputMeshPointer  m_Forces;
00174   InputMeshPointer  m_Normals;
00175   InputMeshPointer  m_Displacements;
00176   InputMeshPointer  m_Derives;
00177   InputMeshPointer  m_Locations;
00178   InputMeshPointer  m_Input;
00179   OutputMeshPointer m_Output;
00180 
00182   vnl_matrix_fixed<double, 4, 4>   m_NStiffness;
00183   vnl_matrix_fixed<double, 4, 4>   m_SStiffness;
00184   vnl_matrix_fixed<double, 4, 4>   m_CStiffness;
00185   vnl_matrix_fixed<double, 4, 4> **m_K;
00186 
00187   Double2Vector  m_Stiffness;
00188   double         m_TimeStep;       // the time step of each iteration
00189   int            m_Resolution;
00190   IndexType      m_Center;
00191   float          m_MiniT;        // variabel help to stop the model when near potential estimation
00192   int            m_Step;         // the number of iteration
00193 
00194   unsigned int   m_NumberOfNodes;
00195   unsigned int   m_NumberOfCells;
00196   unsigned int   m_NumNewNodes;      // for adding new nodes, now disabled for further tests
00197   int           *m_GapLocations;
00198   float        **m_NewNodes;
00199   int            m_NewNodesExisted;
00200   unsigned int   m_NewNodeLimit;
00201   unsigned int   m_ImageWidth;       // input image size
00202   unsigned int   m_ImageHeight;
00203   unsigned int   m_ImageDepth;
00204 
00205   int   m_ModelXUpLimit;    // the following 4 variables record the size of the model
00206   int   m_ModelXDownLimit;
00207   int   m_ModelYUpLimit;
00208   int   m_ModelYDownLimit;
00209   int **m_ACD;        // help to remove the weird structure on the model surface
00210   int   m_ModelRestart;
00211   int   m_GradientBegin;
00212 
00213   Int2Vector   m_StepThreshold;   // the threshold decide when to transfer from potential fit to gradient fit
00214 
00215   // and the threshold decide when to stop the model
00216   float m_DistanceToBoundary;
00217   float m_DistanceToStop;
00218   float m_DistanceForGradient;
00219 
00220   ImagePointer            m_Potential;  // for calculate of image force from potential
00221   GradientImagePointer    m_Gradient;   // for calculate of image force from gradient
00222 
00223   // for Gibbs Prior Model parameters' recalculation
00224   ImagePointer    m_ImageOutput;
00225   unsigned short  m_ObjectLabel;
00226 
00227   typedef ImageType::SizeType ImageSizeType;
00228 
00229 };
00230 
00231 } // end namespace itk
00232 
00233 #ifndef ITK_MANUAL_INSTANTIATION
00234 #include "itkBalloonForceFilter.txx"
00235 #endif
00236 
00237 #endif
00238 

Generated at Thu May 28 09:21:09 2009 for ITK by doxygen 1.5.5 written by Dimitri van Heesch, © 1997-2000