00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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
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(){};
00139
00140 private:
00141 BinaryMask3DMeshSource(const Self&);
00142 void operator=(const Self&);
00143
00144 typedef typename InputImageType::SizeType InputImageSizeType;
00145
00146 void CreateMesh();
00147 void XFlip ( unsigned char *tp );
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();
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];
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 }
00199
00200 #ifndef ITK_MANUAL_INSTANTIATION
00201 #include "itkBinaryMask3DMeshSource.txx"
00202 #endif
00203
00204 #endif