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: 2003/09/10 14:28:28 $
00007   Version:   $Revision: 1.9 $
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 "itkMeshSource.h"
00023 #include "itkVector.h"
00024 #include "itkCellInterface.h"
00025 #include "itkTriangleCell.h"
00026 #include "itkCovariantVector.h"
00027 #include "itkDefaultStaticMeshTraits.h"
00028 #include "itkImageRegionIterator.h"
00029 
00030 namespace itk
00031 {
00032 
00071 template <class TOutputMesh>
00072 class ITK_EXPORT BinaryMask3DMeshSource : public MeshSource<TOutputMesh>
00073 {
00074 public:
00076   typedef BinaryMask3DMeshSource         Self;
00077   typedef MeshSource<TOutputMesh>  Superclass;
00078   typedef SmartPointer<Self>  Pointer;
00079   typedef SmartPointer<const Self>  ConstPointer;
00080 
00082   itkNewMacro(Self);  
00083 
00085   itkTypeMacro(BinaryMask3DMeshSource, MeshSource);
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 Image<unsigned short, 3> BinaryImageType;
00111   typedef typename BinaryImageType::Pointer         BinaryImagePointer;
00112      
00114   typedef typename BinaryImageType::IndexType       BinaryImageIndexType;
00115 
00116   typedef ImageRegionIterator<BinaryImageType> BinaryImageIterator;
00117 
00118   itkSetMacro(BinaryImage, BinaryImageType::Pointer);
00119   itkSetMacro(ObjectValue, unsigned char);
00120 
00121   itkGetMacro(NumberOfNodes, unsigned long);
00122   itkGetMacro(NumberOfCells, unsigned long);
00123 
00124 protected:
00125   BinaryMask3DMeshSource();
00126   ~BinaryMask3DMeshSource();
00127   void PrintSelf(std::ostream& os, Indent indent) const;
00128 
00129   void GenerateData();
00130 
00131 private:
00132   BinaryMask3DMeshSource(const Self&); //purposely not implemented
00133   void operator=(const Self&); //purposely not implemented
00134 
00135   typedef typename BinaryImageType::SizeType BinaryImageSizeType;
00136 
00137   void CreateMesh();
00138   void XFlip ( unsigned char *tp );  // 7 kinds of transfermation
00139   void YFlip ( unsigned char *tp );
00140   void ZFlip ( unsigned char *tp );
00141   void XRotation ( unsigned char *tp );
00142   void YRotation ( unsigned char *tp );
00143   void ZRotation ( unsigned char *tp );
00144   void inverse ( unsigned char *tp );
00145   void InitializeLUT(); // initialize the look up table before the mesh construction
00146   void AddCells( unsigned char celltype, unsigned char celltran, int index );
00147   void AddNodes( int index, unsigned char *nodesid, unsigned long *globalnodesid, unsigned long **currentrowtmp, unsigned long **currentframetmp );
00148   void CellTransfer( unsigned char *nodesid, unsigned char celltran );
00149   unsigned long SearchThroughLastRow( int index, int start, int end );
00150   unsigned long SearchThroughLastFrame( int index, int start, int end );
00151 
00152   unsigned char m_LUT[256][2]; // the two lookup tables
00153 
00154   unsigned long m_LastVoxel[14];
00155   unsigned long m_CurrentVoxel[14];
00156 
00157   unsigned long **m_LastRow;
00158   unsigned long **m_LastFrame;
00159   unsigned long **m_CurrentRow;
00160   unsigned long **m_CurrentFrame;
00161 
00162   unsigned short m_CurrentRowIndex;
00163   unsigned short m_CurrentFrameIndex;
00164   unsigned short m_LastRowNum;
00165   unsigned short m_LastFrameNum;
00166   unsigned short m_CurrentRowNum;
00167   unsigned short m_CurrentFrameNum;
00168   unsigned char  m_AvailableNodes[14];
00169 
00170   double m_LocationOffset[14][3];
00171 
00172   unsigned long m_NumberOfNodes;
00173   unsigned long m_NumberOfCells;
00174   int m_NodeLimit;
00175   int m_CellLimit;
00176   int m_ImageWidth;
00177   int m_ImageHeight;
00178   int m_ImageDepth;
00179   int m_ColFlag;
00180   int m_RowFlag;
00181   int m_FrameFlag;
00182   int m_LastRowIndex;
00183   int m_LastVoxelIndex;
00184   int m_LastFrameIndex;
00185   unsigned char m_PointFound;
00186   unsigned char m_ObjectValue;
00187 
00188   BinaryImageType::Pointer m_BinaryImage;
00189 };
00190 
00191 } // end namespace itk
00192 #ifndef ITK_MANUAL_INSTANTIATION
00193 #include "itkBinaryMask3DMeshSource.txx"
00194 #endif
00195 #endif

Generated at Sun Jan 25 13:19:29 2004 for ITK by doxygen 1.3.3 written by Dimitri van Heesch, © 1997-2000