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 = nullptr;
44  this->Pointer = nullptr;
45  this->SpanEndPointer = nullptr;
46  }
48 
50 
60  vtkImageStencilData *stencil=nullptr,
61  const int extent[6] = nullptr,
62  vtkAlgorithm *algorithm=nullptr,
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=nullptr,
78  const int extent[6] = nullptr,
79  vtkAlgorithm *algorithm=nullptr,
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
vtkImageStencilIterator
an image region iterator
Definition: vtkImageStencilIterator.h:32
vtkImagePointDataIterator
iterate over point data in an image.
Definition: vtkImagePointDataIterator.h:42
vtkImageStencilIterator::IsAtEnd
bool IsAtEnd()
Test if the iterator has completed iterating over the entire extent.
Definition: vtkImageStencilIterator.h:106
vtkAlgorithm
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:53
vtkX3D::image
Definition: vtkX3D.h:374
vtkImagePointDataIterator::IsAtEnd
bool IsAtEnd()
Test if the iterator has completed iterating over the entire extent.
Definition: vtkImagePointDataIterator.h:85
vtkImagePointDataIterator::NextSpan
void NextSpan()
Move the iterator to the beginning of the next span.
vtkImageStencilIterator::Increment
int Increment
Definition: vtkImageStencilIterator.h:141
vtkImageStencilIterator::BeginSpan
DType * BeginSpan()
Return a pointer to the beginning of the current span.
Definition: vtkImageStencilIterator.h:114
vtkImageStencilIterator::NextSpan
void NextSpan()
Move the iterator to the beginning of the next span.
Definition: vtkImageStencilIterator.h:96
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:39
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:40
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:59
vtkImageStencilIterator::BasePointer
DType * BasePointer
Definition: vtkImageStencilIterator.h:144
vtkImagePointDataIterator.h
vtkImageStencilData
efficient description of an image stencil
Definition: vtkImageStencilData.h:34
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:146
vtkImageStencilIterator::EndSpan
DType * EndSpan()
Return a pointer to the end of the current span.
Definition: vtkImageStencilIterator.h:122
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:76
vtkX3D::extent
Definition: vtkX3D.h:345
vtkImageStencilIterator::UpdatePointer
void UpdatePointer()
Update the pointer (called automatically when a new span begins).
Definition: vtkImageStencilIterator.h:133
vtkImageStencilIterator::Pointer
DType * Pointer
Definition: vtkImageStencilIterator.h:145