00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkImageStencilIterator.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00025 #ifndef __vtkImageStencilIterator_h 00026 #define __vtkImageStencilIterator_h 00027 00028 #include "vtkSystemIncludes.h" 00029 class vtkImageData; 00030 class vtkImageStencilData; 00031 class vtkAlgorithm; 00032 00033 template<class DType> 00034 class vtkImageStencilIterator 00035 { 00036 public: 00039 vtkImageStencilIterator(); 00040 00042 00045 vtkImageStencilIterator( 00046 vtkImageData *image, vtkImageStencilData *stencil, int extent[6], 00047 vtkAlgorithm *algorithm=0, int threadId=0); 00049 00051 00054 void Initialize( 00055 vtkImageData *image, vtkImageStencilData *stencil, int extent[6]); 00057 00059 00061 bool IsInStencil() 00062 { 00063 return this->InStencil; 00064 } 00066 00069 void NextSpan(); 00070 00072 00073 bool IsAtEnd() 00074 { 00075 return (this->Pointer == this->EndPointer); 00076 } 00078 00080 00081 DType *BeginSpan() 00082 { 00083 return this->Pointer; 00084 } 00086 00088 00089 DType *EndSpan() 00090 { 00091 return this->SpanEndPointer; 00092 } 00094 00095 protected: 00096 00098 void SetSpanState(int idX); 00099 00103 void ReportProgress(); 00104 00105 // Pointers 00106 DType *Pointer; // current iterator position within data 00107 DType *SpanEndPointer; // end of current span 00108 DType *RowEndPointer; // end of current row 00109 DType *SliceEndPointer; // end of current slice 00110 DType *EndPointer; // end of data 00111 00112 // Increments 00113 vtkIdType PixelIncrement; // to next pixel 00114 vtkIdType RowIncrement; // to same position in next row 00115 vtkIdType SliceIncrement; // to same position in next slice 00116 vtkIdType RowEndIncrement; // from end of row to start of next row 00117 vtkIdType SliceEndIncrement; // from end of slice to start of next slice 00118 00119 // Stencil-related items 00120 bool HasStencil; 00121 bool InStencil; 00122 int SpanSliceEndIncrement; 00123 int SpanSliceIncrement; 00124 int SpanMinX; 00125 int SpanMaxX; 00126 int SpanMinY; 00127 int SpanMaxY; 00128 int SpanMinZ; 00129 int SpanMaxZ; 00130 int SpanIndexX; 00131 int SpanIndexY; 00132 int SpanIndexZ; 00133 int *SpanCountPointer; 00134 int **SpanListPointer; 00135 00136 // Progress-related items 00137 vtkAlgorithm *Algorithm; 00138 vtkIdType Count; 00139 vtkIdType Target; 00140 }; 00141 00142 #ifdef VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION 00143 #include "vtkImageStencilIterator.txx" 00144 #endif 00145 00146 #endif