VTK  9.0.1
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 =========================================================================*/
31 #ifndef vtkImagePointIterator_h
32 #define vtkImagePointIterator_h
33 
35 
36 class VTKIMAGINGCORE_EXPORT vtkImagePointIterator : public vtkImagePointDataIterator
37 {
38 public:
43 
53  vtkImagePointIterator(vtkImageData* image, const int extent[6] = nullptr,
54  vtkImageStencilData* stencil = nullptr, vtkAlgorithm* algorithm = nullptr, int threadId = 0);
55 
59  void Initialize(vtkImageData* image, const int extent[6] = nullptr,
60  vtkImageStencilData* stencil = nullptr, vtkAlgorithm* algorithm = nullptr, int threadId = 0);
61 
63 
68  void NextSpan()
69  {
71  this->UpdatePosition();
72  }
74 
76 
81  void Next()
82  {
83  if (++(this->Id) == this->SpanEnd)
84  {
85  this->NextSpan();
86  }
87  else
88  {
89  this->Index[0]++;
90  this->Position[0] = this->Origin[0] + this->Index[0] * this->Spacing[0];
91  }
92  }
94 
98  bool IsAtEnd() { return this->vtkImagePointDataIterator::IsAtEnd(); }
99 
103  double* GetPosition() VTK_SIZEHINT(3) { return this->Position; }
104 
106 
109  void GetPosition(double x[3])
110  {
111  x[0] = this->Position[0];
112  x[1] = this->Position[1];
113  x[2] = this->Position[2];
114  }
116 
118 
121  void GetPosition(float x[3])
122  {
123  x[0] = this->Position[0];
124  x[1] = this->Position[1];
125  x[2] = this->Position[2];
126  }
128 
129 protected:
131 
135  {
136  this->Position[0] = this->Origin[0] + this->Index[0] * this->Spacing[0];
137  this->Position[1] = this->Origin[1] + this->Index[1] * this->Spacing[1];
138  this->Position[2] = this->Origin[2] + this->Index[2] * this->Spacing[2];
139  }
141 
142  double Origin[3];
143  double Spacing[3];
144  double Position[3];
145 };
146 
147 #endif
148 // VTK-HeaderTest-Exclude: vtkImagePointIterator.h
vtkImagePointIterator::UpdatePosition
void UpdatePosition()
Helper method to update the position coordinate from the index.
Definition: vtkImagePointIterator.h:134
vtkImagePointDataIterator
iterate over point data in an image.
Definition: vtkImagePointDataIterator.h:42
vtkAlgorithm
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:62
vtkX3D::image
@ image
Definition: vtkX3D.h:380
vtkImagePointDataIterator::IsAtEnd
bool IsAtEnd()
Test if the iterator has completed iterating over the entire extent.
Definition: vtkImagePointDataIterator.h:81
vtkImagePointDataIterator::NextSpan
void NextSpan()
Move the iterator to the beginning of the next span.
vtkImagePointIterator::NextSpan
void NextSpan()
Move the iterator to the beginning of the next span.
Definition: vtkImagePointIterator.h:68
vtkImagePointIterator::GetPosition
void GetPosition(double x[3])
Get the current position and place it in the provided array.
Definition: vtkImagePointIterator.h:109
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:45
vtkImagePointIterator::Next
void Next()
Move to the next position (rather than directly to the next span).
Definition: vtkImagePointIterator.h:81
vtkImagePointIterator::GetPosition
double * GetPosition()
Get the current position.
Definition: vtkImagePointIterator.h:103
vtkImagePointIterator::GetPosition
void GetPosition(float x[3])
Get the current position and place it in the provided array.
Definition: vtkImagePointIterator.h:121
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:41
vtkImagePointDataIterator::Initialize
void Initialize(vtkImageData *image, const int extent[6]=nullptr, vtkImageStencilData *stencil=nullptr, vtkAlgorithm *algorithm=nullptr, int threadId=0)
Initialize an iterator.
vtkImagePointIterator
iterate over all data points in an image.
Definition: vtkImagePointIterator.h:36
vtkImagePointDataIterator.h
vtkImageStencilData
efficient description of an image stencil
Definition: vtkImageStencilData.h:33
vtkX3D::extent
@ extent
Definition: vtkX3D.h:351
vtkImagePointIterator::IsAtEnd
bool IsAtEnd()
Test if the iterator has completed iterating over the entire extent.
Definition: vtkImagePointIterator.h:98