VTK  9.3.1
vtkImagePointIterator.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
22 #ifndef vtkImagePointIterator_h
23 #define vtkImagePointIterator_h
24 
26 
27 VTK_ABI_NAMESPACE_BEGIN
28 class VTKIMAGINGCORE_EXPORT vtkImagePointIterator : public vtkImagePointDataIterator
29 {
30 public:
35 
45  vtkImagePointIterator(vtkImageData* image, const int extent[6] = nullptr,
46  vtkImageStencilData* stencil = nullptr, vtkAlgorithm* algorithm = nullptr, int threadId = 0);
47 
51  void Initialize(vtkImageData* image, const int extent[6] = nullptr,
52  vtkImageStencilData* stencil = nullptr, vtkAlgorithm* algorithm = nullptr, int threadId = 0);
53 
55 
60  void NextSpan()
61  {
63  this->UpdatePosition();
64  }
66 
68 
73  void Next()
74  {
75  if (++(this->Id) == this->SpanEnd)
76  {
77  this->NextSpan();
78  }
79  else
80  {
81  this->Index[0]++;
82  this->Position[0] = this->Origin[0] + this->Index[0] * this->Spacing[0];
83  }
84  }
86 
90  bool IsAtEnd() { return this->vtkImagePointDataIterator::IsAtEnd(); }
91 
95  double* GetPosition() VTK_SIZEHINT(3) { return this->Position; }
96 
98 
101  void GetPosition(double x[3])
102  {
103  x[0] = this->Position[0];
104  x[1] = this->Position[1];
105  x[2] = this->Position[2];
106  }
108 
110 
113  void GetPosition(float x[3])
114  {
115  x[0] = this->Position[0];
116  x[1] = this->Position[1];
117  x[2] = this->Position[2];
118  }
120 
121 protected:
123 
127  {
128  this->Position[0] = this->Origin[0] + this->Index[0] * this->Spacing[0];
129  this->Position[1] = this->Origin[1] + this->Index[1] * this->Spacing[1];
130  this->Position[2] = this->Origin[2] + this->Index[2] * this->Spacing[2];
131  }
133 
134  double Origin[3];
135  double Spacing[3];
136  double Position[3];
137 };
138 
139 VTK_ABI_NAMESPACE_END
140 #endif
141 // VTK-HeaderTest-Exclude: vtkImagePointIterator.h
bool IsAtEnd()
Test if the iterator has completed iterating over the entire extent.
void UpdatePosition()
Helper method to update the position coordinate from the index.
iterate over point data in an image.
void Next()
Move to the next position (rather than directly to the next span).
double * GetPosition()
Get the current position.
void NextSpan()
Move the iterator to the beginning of the next span.
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:51
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
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
#define VTK_SIZEHINT(...)
iterate over all data points in an image.
bool IsAtEnd()
Test if the iterator has completed iterating over the entire extent.
void GetPosition(float x[3])
Get the current position and place it in the provided array.
void GetPosition(double 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.