VTK  9.2.6
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 
39 class VTKIMAGINGCORE_EXPORT vtkImagePointIterator : public vtkImagePointDataIterator
40 {
41 public:
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 
101  bool IsAtEnd() { return this->vtkImagePointDataIterator::IsAtEnd(); }
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 
132 protected:
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
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:62
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:53
#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.