VTK
vtkImageStencilIterator.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkImageStencilIterator.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
26 #ifndef vtkImageStencilIterator_h
27 #define vtkImageStencilIterator_h
28 
30 
31 template<class DType>
32 class VTKIMAGINGCORE_EXPORT vtkImageStencilIterator :
34 {
35 public:
37 
41  {
42  this->Increment = 0;
43  this->BasePointer = 0;
44  this->Pointer = 0;
45  this->SpanEndPointer = 0;
46  }
48 
50 
60  vtkImageStencilData *stencil=0,
61  const int extent[6] = 0,
62  vtkAlgorithm *algorithm=0,
63  int threadId=0)
64  : vtkImagePointDataIterator(image, extent, stencil, algorithm, threadId)
65  {
66  this->BasePointer = static_cast<DType *>(
67  vtkImagePointDataIterator::GetVoidPointer(image, 0, &this->Increment));
68  this->UpdatePointer();
69  }
71 
73 
77  vtkImageStencilData *stencil=0,
78  const int extent[6] = 0,
79  vtkAlgorithm *algorithm=0,
80  int threadId=0)
81  {
83  image, extent, stencil, algorithm, threadId);
84  this->BasePointer = static_cast<DType *>(
85  vtkImagePointDataIterator::GetVoidPointer(image, 0, &this->Increment));
86  this->UpdatePointer();
87  }
89 
91 
96  void NextSpan()
97  {
99  this->UpdatePointer();
100  }
102 
106  bool IsAtEnd()
107  {
108  return this->vtkImagePointDataIterator::IsAtEnd();
109  }
110 
114  DType *BeginSpan()
115  {
116  return this->Pointer;
117  }
118 
122  DType *EndSpan()
123  {
124  return this->SpanEndPointer;
125  }
126 
127 protected:
128 
130 
134  {
135  this->Pointer = this->BasePointer + this->Id*this->Increment;
136  this->SpanEndPointer = this->BasePointer + this->SpanEnd*this->Increment;
137  }
139 
140  // The pointer must be incremented by this amount for each pixel.
142 
143  // Pointers
144  DType *BasePointer; // pointer to the first voxel
145  DType *Pointer; // current iterator position within data
146  DType *SpanEndPointer; // end of current span
147 };
148 
149 #ifndef vtkImageStencilIterator_cxx
150 #ifdef _MSC_VER
151 #pragma warning (push)
152 // The following is needed when the vtkImageStencilIterator template
153 // class is declared dllexport and is used within vtkImagingCore
154 #pragma warning (disable: 4910) // extern and dllexport incompatible
155 #endif
157  extern template class VTKIMAGINGCORE_EXPORT vtkImageStencilIterator
158 )
159 #ifdef _MSC_VER
160 #pragma warning (pop)
161 #endif
162 #endif
163 
164 #endif
165 // VTK-HeaderTest-Exclude: vtkImageStencilIterator.h
DType * EndSpan()
Return a pointer to the end of the current span.
iterate over point data in an image.
void Initialize(vtkImageData *image, const int extent[6]=0, vtkImageStencilData *stencil=0, vtkAlgorithm *algorithm=0, int threadId=0)
Initialize an iterator.
bool IsAtEnd()
Test if the iterator has completed iterating over the entire extent.
void NextSpan()
Move the iterator to the beginning of the next span.
an image region iterator
DType * BeginSpan()
Return a pointer to the beginning of the current span.
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:53
#define vtkExternTemplateMacro(decl)
A macro to declare extern templates for all numerical types.
Definition: vtkType.h:411
efficient description of an image stencil
topologically and geometrically regular array of data
Definition: vtkImageData.h:39
void Initialize(vtkImageData *image, vtkImageStencilData *stencil=0, const int extent[6]=0, vtkAlgorithm *algorithm=0, int threadId=0)
Initialize an iterator.
bool IsAtEnd()
Test if the iterator has completed iterating over the entire extent.
vtkImageStencilIterator()
Default constructor, its use must be followed by Initialize().
void UpdatePointer()
Update the pointer (called automatically when a new span begins).
static void * GetVoidPointer(vtkImageData *image, vtkIdType i=0, int *pixelIncrement=0)
Get a void pointer and pixel increment for the given point Id.
vtkImageStencilIterator(vtkImageData *image, vtkImageStencilData *stencil=0, const int extent[6]=0, vtkAlgorithm *algorithm=0, int threadId=0)
Create an iterator for the given image, with several options.
void NextSpan()
Move the iterator to the beginning of the next span.