VTK  9.2.6
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
34template <class DType>
35class VTKIMAGINGCORE_EXPORT vtkImageStencilIterator : public vtkImagePointDataIterator
36{
37public:
39
43 {
44 this->Increment = 0;
45 this->BasePointer = nullptr;
46 this->Pointer = nullptr;
47 this->SpanEndPointer = nullptr;
48 }
50
52
62 const int extent[6] = nullptr, vtkAlgorithm* algorithm = nullptr, int threadId = 0)
63 : vtkImagePointDataIterator(image, extent, stencil, algorithm, threadId)
64 {
65 this->BasePointer =
66 static_cast<DType*>(vtkImagePointDataIterator::GetVoidPointer(image, 0, &this->Increment));
67 this->UpdatePointer();
68 }
70
72
75 void Initialize(vtkImageData* image, vtkImageStencilData* stencil = nullptr,
76 const int extent[6] = nullptr, vtkAlgorithm* algorithm = nullptr, int threadId = 0)
77 {
78 this->vtkImagePointDataIterator::Initialize(image, extent, stencil, algorithm, threadId);
79 this->BasePointer =
80 static_cast<DType*>(vtkImagePointDataIterator::GetVoidPointer(image, 0, &this->Increment));
81 this->UpdatePointer();
82 }
84
86
91 void NextSpan()
92 {
94 this->UpdatePointer();
95 }
97
102
106 DType* BeginSpan() { return this->Pointer; }
107
111 DType* EndSpan() { return this->SpanEndPointer; }
112
113protected:
115
119 {
120 this->Pointer = this->BasePointer + this->Id * this->Increment;
121 this->SpanEndPointer = this->BasePointer + this->SpanEnd * this->Increment;
122 }
124
125 // The pointer must be incremented by this amount for each pixel.
127
128 // Pointers
129 DType* BasePointer; // pointer to the first voxel
130 DType* Pointer; // current iterator position within data
131 DType* SpanEndPointer; // end of current span
132};
133
134#ifndef vtkImageStencilIterator_cxx
135#ifdef _MSC_VER
136#pragma warning(push)
137// The following is needed when the vtkImageStencilIterator template
138// class is declared dllexport and is used within vtkImagingCore
139#pragma warning(disable : 4910) // extern and dllexport incompatible
140#endif
141vtkExternTemplateMacro(extern template class VTKIMAGINGCORE_EXPORT vtkImageStencilIterator);
142#ifdef _MSC_VER
143#pragma warning(pop)
144#endif
145#endif
146
147#endif
148// VTK-HeaderTest-Exclude: vtkImageStencilIterator.h
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:63
topologically and geometrically regular array of data
Definition: vtkImageData.h:54
iterate over point data in an image.
void NextSpan()
Move the iterator to the beginning of the next span.
bool IsAtEnd()
Test if the iterator has completed iterating over the entire extent.
static void * GetVoidPointer(vtkImageData *image, vtkIdType i=0, int *pixelIncrement=nullptr)
Get a void pointer and pixel increment for the given point Id.
void Initialize(vtkImageData *image, const int extent[6]=nullptr, vtkImageStencilData *stencil=nullptr, vtkAlgorithm *algorithm=nullptr, int threadId=0)
Initialize an iterator.
efficient description of an image stencil
an image region iterator
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.
DType * BeginSpan()
Return a pointer to the beginning of the current span.
void NextSpan()
Move the iterator to the beginning of the next span.
void UpdatePointer()
Update the pointer (called automatically when a new span begins).
DType * EndSpan()
Return a pointer to the end of the current span.
bool IsAtEnd()
Test if the iterator has completed iterating over the entire extent.
void Initialize(vtkImageData *image, vtkImageStencilData *stencil=nullptr, const int extent[6]=nullptr, vtkAlgorithm *algorithm=nullptr, int threadId=0)
Initialize an iterator.
vtkImageStencilIterator()
Default constructor, its use must be followed by Initialize().
#define vtkExternTemplateMacro(decl)
A macro to declare extern templates for all numerical types.
Definition: vtkType.h:395