VTK  9.3.1
vtkImagePointDataIterator.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 vtkImagePointDataIterator_h
23 #define vtkImagePointDataIterator_h
24 
25 #include "vtkImagingCoreModule.h" // for export macro
26 #include "vtkSystemIncludes.h"
27 
28 VTK_ABI_NAMESPACE_BEGIN
29 class vtkDataArray;
30 class vtkImageData;
32 class vtkAlgorithm;
33 
34 class VTKIMAGINGCORE_EXPORT vtkImagePointDataIterator
35 {
36 public:
41 
52  vtkImageStencilData* stencil = nullptr, vtkAlgorithm* algorithm = nullptr, int threadId = 0)
53  {
54  this->Initialize(image, extent, stencil, algorithm, threadId);
55  }
56 
60  void Initialize(vtkImageData* image, const int extent[6] = nullptr,
61  vtkImageStencilData* stencil = nullptr, vtkAlgorithm* algorithm = nullptr, int threadId = 0);
62 
68  void NextSpan();
69 
73  bool IsAtEnd() { return (this->Id == this->End); }
74 
79  bool IsInStencil() { return this->InStencil; }
80 
82 
85  void GetIndex(int result[3])
86  {
87  result[0] = this->Index[0];
88  result[1] = this->Index[1];
89  result[2] = this->Index[2];
90  }
92 
96  const int* GetIndex() VTK_SIZEHINT(3) { return this->Index; }
97 
101  vtkIdType GetId() { return this->Id; }
102 
106  vtkIdType SpanEndId() { return this->SpanEnd; }
107 
112  static void* GetVoidPointer(vtkImageData* image, vtkIdType i = 0, int* pixelIncrement = nullptr);
113 
119  static void* GetVoidPointer(vtkDataArray* array, vtkIdType i = 0, int* pixelIncrement = nullptr);
120 
121 protected:
125  void SetSpanState(int idX);
126 
132  void ReportProgress();
133 
134  vtkIdType Id; // the current point Id
135  vtkIdType SpanEnd; // end of current span
136  vtkIdType RowEnd; // end of current row
137  vtkIdType SliceEnd; // end of current slice
138  vtkIdType End; // end of data
139 
140  // Increments
141  vtkIdType RowIncrement; // to same position in next row
142  vtkIdType SliceIncrement; // to same position in next slice
143  vtkIdType RowEndIncrement; // from end of row to start of next row
144  vtkIdType SliceEndIncrement; // from end of slice to start of next slice
145 
146  // The extent, adjusted for the stencil
147  int Extent[6];
148 
149  // Index-related items
150  int Index[3];
151  int StartY;
152 
153  // Stencil-related items
155  bool InStencil;
161 
162  // Progress-related items
166  int ThreadId;
167 };
168 
169 VTK_ABI_NAMESPACE_END
170 #endif
171 // VTK-HeaderTest-Exclude: vtkImagePointDataIterator.h
vtkImagePointDataIterator(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.
iterate over point data in an image.
int vtkIdType
Definition: vtkType.h:315
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:51
efficient description of an image stencil
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
vtkIdType SpanEndId()
Get the end of the span.
#define VTK_SIZEHINT(...)
bool IsAtEnd()
Test if the iterator has completed iterating over the entire extent.
void GetIndex(int result[3])
Get the index at the beginning of the current span.
vtkIdType GetId()
Get the point Id at the beginning of the current span.
const int * GetIndex()
Get the index at the beginning of the current span.
bool IsInStencil()
Check if the iterator is within the region specified by the stencil.