VTK  9.4.20241221
vtkImageStencilIterator.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
17#ifndef vtkImageStencilIterator_h
18#define vtkImageStencilIterator_h
19
21
22VTK_ABI_NAMESPACE_BEGIN
23template <class DType>
24class VTKIMAGINGCORE_EXPORT vtkImageStencilIterator : public vtkImagePointDataIterator
25{
26public:
28
32 {
33 this->Increment = 0;
34 this->BasePointer = nullptr;
35 this->Pointer = nullptr;
36 this->SpanEndPointer = nullptr;
37 }
39
41
51 const int extent[6] = nullptr, vtkAlgorithm* algorithm = nullptr, int threadId = 0)
52 : vtkImagePointDataIterator(image, extent, stencil, algorithm, threadId)
53 {
54 this->BasePointer =
55 static_cast<DType*>(vtkImagePointDataIterator::GetVoidPointer(image, 0, &this->Increment));
56 this->UpdatePointer();
57 }
59
61
64 void Initialize(vtkImageData* image, vtkImageStencilData* stencil = nullptr,
65 const int extent[6] = nullptr, vtkAlgorithm* algorithm = nullptr, int threadId = 0)
66 {
67 this->vtkImagePointDataIterator::Initialize(image, extent, stencil, algorithm, threadId);
68 this->BasePointer =
69 static_cast<DType*>(vtkImagePointDataIterator::GetVoidPointer(image, 0, &this->Increment));
70 this->UpdatePointer();
71 }
73
75
80 void NextSpan()
81 {
83 this->UpdatePointer();
84 }
86
91
95 DType* BeginSpan() { return this->Pointer; }
96
100 DType* EndSpan() { return this->SpanEndPointer; }
101
102protected:
104
108 {
109 this->Pointer = this->BasePointer + this->Id * this->Increment;
110 this->SpanEndPointer = this->BasePointer + this->SpanEnd * this->Increment;
111 }
113
114 // The pointer must be incremented by this amount for each pixel.
116
117 // Pointers
118 DType* BasePointer; // pointer to the first voxel
119 DType* Pointer; // current iterator position within data
120 DType* SpanEndPointer; // end of current span
121};
122
123#ifndef vtkImageStencilIterator_cxx
124#ifdef _MSC_VER
125#pragma warning(push)
126// The following is needed when the vtkImageStencilIterator template
127// class is declared dllexport and is used within vtkImagingCore
128#pragma warning(disable : 4910) // extern and dllexport incompatible
129#endif
130vtkExternTemplateMacro(extern template class VTKIMAGINGCORE_EXPORT vtkImageStencilIterator);
131#ifdef _MSC_VER
132#pragma warning(pop)
133#endif
134#endif
135
136VTK_ABI_NAMESPACE_END
137#endif
138// VTK-HeaderTest-Exclude: vtkImageStencilIterator.h
Superclass for all sources, filters, and sinks in VTK.
topologically and geometrically regular array of data
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:410