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: 2009-06-28 19:17:37 $
00007   Version:   $Revision: 1.19 $
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 template <class TInputImage, class TOutputMesh>
00072 class ITK_EXPORT BinaryMask3DMeshSource : public ImageToMeshFilter< TInputImage, TOutputMesh >
00073 {
00074 public:
00076   typedef BinaryMask3DMeshSource                        Self;
00077   typedef ImageToMeshFilter< TInputImage, TOutputMesh > Superclass;
00078   typedef SmartPointer<Self>                            Pointer;
00079   typedef SmartPointer<const Self>                      ConstPointer;
00080 
00082   itkNewMacro(Self);  
00083 
00085   itkTypeMacro(BinaryMask3DMeshSource, ImageToMeshFilter);
00086 
00088   typedef TOutputMesh                           OutputMeshType;
00089   typedef typename OutputMeshType::MeshTraits   OMeshTraits;
00090   typedef typename OutputMeshType::PointType    OPointType;
00091   typedef typename OMeshTraits::PixelType       OPixelType;  
00092 
00094   typedef typename OutputMeshType::Pointer                OutputMeshPointer;
00095   typedef typename OutputMeshType::CellTraits             CellTraits;
00096   typedef typename OutputMeshType::PointsContainerPointer PointsContainerPointer;
00097   typedef typename OutputMeshType::PointsContainer        PointsContainer;
00098   typedef typename OutputMeshType::CellsContainerPointer  CellsContainerPointer;
00099   typedef typename OutputMeshType::CellsContainer         CellsContainer;
00100   typedef CovariantVector<double, 2>                      doubleVector;
00101   typedef CovariantVector<int, 2>                         intVector;
00102 
00105   typedef CellInterface<OPixelType, CellTraits>  TCellInterface;
00106   typedef TriangleCell<TCellInterface>           TriCell;
00107   typedef typename TriCell::SelfAutoPointer      TriCellAutoPointer;
00108 
00110   typedef TInputImage                              InputImageType;
00111   typedef typename InputImageType::Pointer         InputImagePointer;
00112   typedef typename InputImageType::ConstPointer    InputImageConstPointer;
00113   typedef typename InputImageType::PixelType       InputPixelType;
00114   typedef typename InputImageType::SpacingType     SpacingType;
00115   typedef typename InputImageType::PointType       OriginType;
00116 
00118   typedef typename InputImageType::IndexType       InputImageIndexType;
00119 
00120   typedef ImageRegionConstIterator< InputImageType > InputImageIterator;
00121   
00122   itkSetMacro(ObjectValue, InputPixelType);
00123 
00124   itkGetConstMacro(NumberOfNodes, unsigned long);
00125   itkGetConstMacro(NumberOfCells, unsigned long);
00126 
00128   virtual void SetInput( const InputImageType * inputImage );
00129 
00130 
00131 protected:
00132   BinaryMask3DMeshSource();
00133   ~BinaryMask3DMeshSource();
00134   void PrintSelf(std::ostream& os, Indent indent) const;
00135 
00136   void GenerateData();
00137   virtual void GenerateOutputInformation(){}; // do nothing
00138   
00139 private:
00140   BinaryMask3DMeshSource(const Self&); //purposely not implemented
00141   void operator=(const Self&); //purposely not implemented
00142 
00143   typedef typename InputImageType::SizeType InputImageSizeType;
00144 
00145   void CreateMesh();
00146   void XFlip ( unsigned char *tp );  // 7 kinds of transformation
00147   void YFlip ( unsigned char *tp );
00148   void ZFlip ( unsigned char *tp );
00149   void XRotation ( unsigned char *tp );
00150   void YRotation ( unsigned char *tp );
00151   void ZRotation ( unsigned char *tp );
00152   void inverse ( unsigned char *tp );
00153   void InitializeLUT(); // initialize the look up table before the mesh construction
00154   void AddCells( unsigned char celltype, unsigned char celltran, int index );
00155   void AddNodes( int index, unsigned char *nodesid, unsigned long *globalnodesid, unsigned long **currentrowtmp, unsigned long **currentframetmp );
00156   void CellTransfer( unsigned char *nodesid, unsigned char celltran );
00157   unsigned long SearchThroughLastRow( int index, int start, int end );
00158   unsigned long SearchThroughLastFrame( int index, int start, int end );
00159 
00160   unsigned char m_LUT[256][2]; // the two lookup tables
00161 
00162   unsigned long m_LastVoxel[14];
00163   unsigned long m_CurrentVoxel[14];
00164 
00165   unsigned long **m_LastRow;
00166   unsigned long **m_LastFrame;
00167   unsigned long **m_CurrentRow;
00168   unsigned long **m_CurrentFrame;
00169 
00170   unsigned short m_CurrentRowIndex;
00171   unsigned short m_CurrentFrameIndex;
00172   unsigned short m_LastRowNum;
00173   unsigned short m_LastFrameNum;
00174   unsigned short m_CurrentRowNum;
00175   unsigned short m_CurrentFrameNum;
00176   unsigned char  m_AvailableNodes[14];
00177 
00178   double m_LocationOffset[14][3];
00179 
00180   unsigned long m_NumberOfNodes;
00181   unsigned long m_NumberOfCells;
00182 
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 
00195   unsigned char  m_PointFound;
00196   InputPixelType m_ObjectValue;
00197 };
00198 
00199 } // end namespace itk
00200 
00201 #ifndef ITK_MANUAL_INSTANTIATION
00202 #include "itkBinaryMask3DMeshSource.txx"
00203 #endif
00204 
00205 #endif
00206 

Generated at Tue Sep 15 02:15:38 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000