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

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