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 =========================================================================*/
29 #ifndef vtkImageStencilIterator_h
30 #define vtkImageStencilIterator_h
31 
33 
34 template<class DType>
35 class VTKIMAGINGCORE_EXPORT vtkImageStencilIterator :
37 {
38 public:
40 
44  {
45  this->Increment = 0;
46  this->BasePointer = nullptr;
47  this->Pointer = nullptr;
48  this->SpanEndPointer = nullptr;
49  }
51 
53 
63  vtkImageStencilData *stencil=nullptr,
64  const int extent[6] = nullptr,
65  vtkAlgorithm *algorithm=nullptr,
66  int threadId=0)
67  : vtkImagePointDataIterator(image, extent, stencil, algorithm, threadId)
68  {
69  this->BasePointer = static_cast<DType *>(
70  vtkImagePointDataIterator::GetVoidPointer(image, 0, &this->Increment));
71  this->UpdatePointer();
72  }
74 
76 
80  vtkImageStencilData *stencil=nullptr,
81  const int extent[6] = nullptr,
82  vtkAlgorithm *algorithm=nullptr,
83  int threadId=0)
84  {
86  image, extent, stencil, algorithm, threadId);
87  this->BasePointer = static_cast<DType *>(
88  vtkImagePointDataIterator::GetVoidPointer(image, 0, &this->Increment));
89  this->UpdatePointer();
90  }
92 
94 
99  void NextSpan()
100  {
102  this->UpdatePointer();
103  }
105 
109  bool IsAtEnd()
110  {
111  return this->vtkImagePointDataIterator::IsAtEnd();
112  }
113 
117  DType *BeginSpan()
118  {
119  return this->Pointer;
120  }
121 
125  DType *EndSpan()
126  {
127  return this->SpanEndPointer;
128  }
129 
130 protected:
131 
133 
137  {
138  this->Pointer = this->BasePointer + this->Id*this->Increment;
139  this->SpanEndPointer = this->BasePointer + this->SpanEnd*this->Increment;
140  }
142 
143  // The pointer must be incremented by this amount for each pixel.
145 
146  // Pointers
147  DType *BasePointer; // pointer to the first voxel
148  DType *Pointer; // current iterator position within data
149  DType *SpanEndPointer; // end of current span
150 };
151 
152 #ifndef vtkImageStencilIterator_cxx
153 #ifdef _MSC_VER
154 #pragma warning (push)
155 // The following is needed when the vtkImageStencilIterator template
156 // class is declared dllexport and is used within vtkImagingCore
157 #pragma warning (disable: 4910) // extern and dllexport incompatible
158 #endif
160  extern template class VTKIMAGINGCORE_EXPORT vtkImageStencilIterator
161 )
162 #ifdef _MSC_VER
163 #pragma warning (pop)
164 #endif
165 #endif
166 
167 #endif
168 // VTK-HeaderTest-Exclude: vtkImageStencilIterator.h
vtkImageStencilIterator
an image region iterator
Definition: vtkImageStencilIterator.h:35
vtkImagePointDataIterator
iterate over point data in an image.
Definition: vtkImagePointDataIterator.h:45
vtkImageStencilIterator::IsAtEnd
bool IsAtEnd()
Test if the iterator has completed iterating over the entire extent.
Definition: vtkImageStencilIterator.h:109
vtkAlgorithm
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:59
vtkX3D::image
Definition: vtkX3D.h:374
vtkImagePointDataIterator::IsAtEnd
bool IsAtEnd()
Test if the iterator has completed iterating over the entire extent.
Definition: vtkImagePointDataIterator.h:88
vtkImagePointDataIterator::NextSpan
void NextSpan()
Move the iterator to the beginning of the next span.
vtkImageStencilIterator::Increment
int Increment
Definition: vtkImageStencilIterator.h:144
vtkImageStencilIterator::BeginSpan
DType * BeginSpan()
Return a pointer to the beginning of the current span.
Definition: vtkImageStencilIterator.h:117
vtkImageStencilIterator::NextSpan
void NextSpan()
Move the iterator to the beginning of the next span.
Definition: vtkImageStencilIterator.h:99
vtkExternTemplateMacro
#define vtkExternTemplateMacro(decl)
A macro to declare extern templates for all numerical types.
Definition: vtkType.h:415
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
vtkImagePointDataIterator::Initialize
void Initialize(vtkImageData *image, const int extent[6]=nullptr, vtkImageStencilData *stencil=nullptr, vtkAlgorithm *algorithm=nullptr, int threadId=0)
Initialize an iterator.
vtkImageStencilIterator::vtkImageStencilIterator
vtkImageStencilIterator()
Default constructor, its use must be followed by Initialize().
Definition: vtkImageStencilIterator.h:43
vtkImageStencilIterator::vtkImageStencilIterator
vtkImageStencilIterator(vtkImageData *image, vtkImageStencilData *stencil=nullptr, const int extent[6]=nullptr, vtkAlgorithm *algorithm=nullptr, int threadId=0)
Create an iterator for the given image, with several options.
Definition: vtkImageStencilIterator.h:62
vtkImageStencilIterator::BasePointer
DType * BasePointer
Definition: vtkImageStencilIterator.h:147
vtkImagePointDataIterator.h
vtkImageStencilData
efficient description of an image stencil
Definition: vtkImageStencilData.h:37
vtkImagePointDataIterator::GetVoidPointer
static void * GetVoidPointer(vtkImageData *image, vtkIdType i=0, int *pixelIncrement=nullptr)
Get a void pointer and pixel increment for the given point Id.
vtkImageStencilIterator::SpanEndPointer
DType * SpanEndPointer
Definition: vtkImageStencilIterator.h:149
vtkImageStencilIterator::EndSpan
DType * EndSpan()
Return a pointer to the end of the current span.
Definition: vtkImageStencilIterator.h:125
vtkImageStencilIterator::Initialize
void Initialize(vtkImageData *image, vtkImageStencilData *stencil=nullptr, const int extent[6]=nullptr, vtkAlgorithm *algorithm=nullptr, int threadId=0)
Initialize an iterator.
Definition: vtkImageStencilIterator.h:79
vtkX3D::extent
Definition: vtkX3D.h:345
vtkImageStencilIterator::UpdatePointer
void UpdatePointer()
Update the pointer (called automatically when a new span begins).
Definition: vtkImageStencilIterator.h:136
vtkImageStencilIterator::Pointer
DType * Pointer
Definition: vtkImageStencilIterator.h:148