VTK  9.2.5
vtkImagePointIterator.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkImagePointIterator.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=========================================================================*/
34#ifndef vtkImagePointIterator_h
35#define vtkImagePointIterator_h
36
38
39class VTKIMAGINGCORE_EXPORT vtkImagePointIterator : public vtkImagePointDataIterator
40{
41public:
46
56 vtkImagePointIterator(vtkImageData* image, const int extent[6] = nullptr,
57 vtkImageStencilData* stencil = nullptr, vtkAlgorithm* algorithm = nullptr, int threadId = 0);
58
62 void Initialize(vtkImageData* image, const int extent[6] = nullptr,
63 vtkImageStencilData* stencil = nullptr, vtkAlgorithm* algorithm = nullptr, int threadId = 0);
64
66
71 void NextSpan()
72 {
74 this->UpdatePosition();
75 }
77
79
84 void Next()
85 {
86 if (++(this->Id) == this->SpanEnd)
87 {
88 this->NextSpan();
89 }
90 else
91 {
92 this->Index[0]++;
93 this->Position[0] = this->Origin[0] + this->Index[0] * this->Spacing[0];
94 }
95 }
97
102
106 double* GetPosition() VTK_SIZEHINT(3) { return this->Position; }
107
109
112 void GetPosition(double x[3])
113 {
114 x[0] = this->Position[0];
115 x[1] = this->Position[1];
116 x[2] = this->Position[2];
117 }
119
121
124 void GetPosition(float x[3])
125 {
126 x[0] = this->Position[0];
127 x[1] = this->Position[1];
128 x[2] = this->Position[2];
129 }
131
132protected:
134
138 {
139 this->Position[0] = this->Origin[0] + this->Index[0] * this->Spacing[0];
140 this->Position[1] = this->Origin[1] + this->Index[1] * this->Spacing[1];
141 this->Position[2] = this->Origin[2] + this->Index[2] * this->Spacing[2];
142 }
144
145 double Origin[3];
146 double Spacing[3];
147 double Position[3];
148};
149
150#endif
151// VTK-HeaderTest-Exclude: vtkImagePointIterator.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.
iterate over all data points in an image.
double * GetPosition()
Get the current position.
bool IsAtEnd()
Test if the iterator has completed iterating over the entire extent.
void GetPosition(double x[3])
Get the current position and place it in the provided array.
void Next()
Move to the next position (rather than directly to the next span).
void UpdatePosition()
Helper method to update the position coordinate from the index.
vtkImagePointIterator()
Default constructor, its use must be followed by Initialize().
void Initialize(vtkImageData *image, const int extent[6]=nullptr, vtkImageStencilData *stencil=nullptr, vtkAlgorithm *algorithm=nullptr, int threadId=0)
Initialize an iterator.
vtkImagePointIterator(vtkImageData *image, const int extent[6]=nullptr, vtkImageStencilData *stencil=nullptr, vtkAlgorithm *algorithm=nullptr, int threadId=0)
Create an iterator for the given image, with several options.
void GetPosition(float x[3])
Get the current position and place it in the provided array.
void NextSpan()
Move the iterator to the beginning of the next span.
efficient description of an image stencil
#define VTK_SIZEHINT(...)