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

itkBinaryMask3DMeshSource.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkBinaryMask3DMeshSource.h,v $
00005   Language:  C++
00006   Date:      $Date: 2005/01/18 22:02:18 $
00007   Version:   $Revision: 1.13 $
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 __itkBinaryMask3DMeshSource_h
00018 #define __itkBinaryMask3DMeshSource_h
00019 
00020 #include "vnl/vnl_matrix_fixed.h"
00021 #include "itkMesh.h"
00022 #include "itkImageToMeshFilter.h"
00023 #include "itkVector.h"
00024 #include "itkCellInterface.h"
00025 #include "itkTriangleCell.h"
00026 #include "itkCovariantVector.h"
00027 #include "itkDefaultStaticMeshTraits.h"
00028 #include "itkImageRegionConstIterator.h"
00029 
00030 namespace itk
00031 {
00032 
00071 #ifndef ITK_EXPLICIT_INSTANTIATION
00072 //This is already explicitly defined when ITK_EXPLICIT_INSTANTIATION is used.
00073 template class Image<unsigned short,3>;
00074 #endif
00075 
00076 template <class TOutputMesh>
00077 class ITK_EXPORT BinaryMask3DMeshSource : public ImageToMeshFilter<Image<unsigned short, 3>,TOutputMesh>
00078 {
00079 public:
00081   typedef BinaryMask3DMeshSource         Self;
00082   typedef ImageToMeshFilter<Image<unsigned short, 3>,TOutputMesh>  Superclass;
00083   typedef SmartPointer<Self>  Pointer;
00084   typedef SmartPointer<const Self>  ConstPointer;
00085 
00087   itkNewMacro(Self);  
00088 
00090   itkTypeMacro(BinaryMask3DMeshSource, ImageToMeshFilter);
00091 
00093   typedef TOutputMesh OutputMeshType;
00094   typedef typename OutputMeshType::MeshTraits   OMeshTraits;
00095   typedef typename OutputMeshType::PointType    OPointType;
00096   typedef typename OMeshTraits::PixelType       OPixelType;  
00097 
00099   typedef typename OutputMeshType::Pointer OutputMeshPointer;
00100   typedef typename OutputMeshType::CellTraits CellTraits;
00101   typedef typename OutputMeshType::PointsContainerPointer PointsContainerPointer;
00102   typedef typename OutputMeshType::PointsContainer   PointsContainer;
00103   typedef typename OutputMeshType::CellsContainerPointer CellsContainerPointer;
00104   typedef typename OutputMeshType::CellsContainer   CellsContainer;
00105   typedef CovariantVector<double, 2>     doubleVector;
00106   typedef CovariantVector<int, 2>        intVector;
00107   
00110   typedef CellInterface<OPixelType, CellTraits>  TCellInterface;
00111   typedef TriangleCell<TCellInterface> TriCell;
00112   typedef typename TriCell::SelfAutoPointer TriCellAutoPointer;
00113 
00115   typedef Image<unsigned short, 3> InputImageType;
00116   typedef typename InputImageType::Pointer         InputImagePointer;
00117      
00119   typedef typename InputImageType::IndexType       InputImageIndexType;
00120 
00121   typedef ImageRegionConstIterator<InputImageType> InputImageIterator;
00122   
00123   itkSetMacro(ObjectValue, unsigned char);
00124 
00125   itkGetMacro(NumberOfNodes, unsigned long);
00126   itkGetMacro(NumberOfCells, unsigned long);
00127 
00129   virtual void SetInput( const InputImageType * inputImage );
00130 
00131 
00132 protected:
00133   BinaryMask3DMeshSource();
00134   ~BinaryMask3DMeshSource();
00135   void PrintSelf(std::ostream& os, Indent indent) const;
00136 
00137   void GenerateData();
00138   virtual void GenerateOutputInformation(){}; // do nothing
00139   
00140 private:
00141   BinaryMask3DMeshSource(const Self&); //purposely not implemented
00142   void operator=(const Self&); //purposely not implemented
00143 
00144   typedef typename InputImageType::SizeType InputImageSizeType;
00145 
00146   void CreateMesh();
00147   void XFlip ( unsigned char *tp );  // 7 kinds of transfermation
00148   void YFlip ( unsigned char *tp );
00149   void ZFlip ( unsigned char *tp );
00150   void XRotation ( unsigned char *tp );
00151   void YRotation ( unsigned char *tp );
00152   void ZRotation ( unsigned char *tp );
00153   void inverse ( unsigned char *tp );
00154   void InitializeLUT(); // initialize the look up table before the mesh construction
00155   void AddCells( unsigned char celltype, unsigned char celltran, int index );
00156   void AddNodes( int index, unsigned char *nodesid, unsigned long *globalnodesid, unsigned long **currentrowtmp, unsigned long **currentframetmp );
00157   void CellTransfer( unsigned char *nodesid, unsigned char celltran );
00158   unsigned long SearchThroughLastRow( int index, int start, int end );
00159   unsigned long SearchThroughLastFrame( int index, int start, int end );
00160 
00161   unsigned char m_LUT[256][2]; // the two lookup tables
00162 
00163   unsigned long m_LastVoxel[14];
00164   unsigned long m_CurrentVoxel[14];
00165 
00166   unsigned long **m_LastRow;
00167   unsigned long **m_LastFrame;
00168   unsigned long **m_CurrentRow;
00169   unsigned long **m_CurrentFrame;
00170 
00171   unsigned short m_CurrentRowIndex;
00172   unsigned short m_CurrentFrameIndex;
00173   unsigned short m_LastRowNum;
00174   unsigned short m_LastFrameNum;
00175   unsigned short m_CurrentRowNum;
00176   unsigned short m_CurrentFrameNum;
00177   unsigned char  m_AvailableNodes[14];
00178 
00179   double m_LocationOffset[14][3];
00180 
00181   unsigned long m_NumberOfNodes;
00182   unsigned long m_NumberOfCells;
00183   int m_NodeLimit;
00184   int m_CellLimit;
00185   int m_ImageWidth;
00186   int m_ImageHeight;
00187   int m_ImageDepth;
00188   int m_ColFlag;
00189   int m_RowFlag;
00190   int m_FrameFlag;
00191   int m_LastRowIndex;
00192   int m_LastVoxelIndex;
00193   int m_LastFrameIndex;
00194   unsigned char m_PointFound;
00195   unsigned char m_ObjectValue;
00196 };
00197 
00198 } // end namespace itk
00199 
00200 #ifndef ITK_MANUAL_INSTANTIATION
00201 #include "itkBinaryMask3DMeshSource.txx"
00202 #endif
00203 
00204 #endif

Generated at Tue Mar 29 23:46:58 2005 for ITK by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2000