VTK  9.0.1
vtkImagePointDataIterator.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkImagePointDataIterator.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 vtkImagePointDataIterator_h
32 #define vtkImagePointDataIterator_h
33 
34 #include "vtkImagingCoreModule.h" // for export macro
35 #include "vtkSystemIncludes.h"
36 
37 class vtkDataArray;
38 class vtkImageData;
40 class vtkAlgorithm;
41 
42 class VTKIMAGINGCORE_EXPORT vtkImagePointDataIterator
43 {
44 public:
49 
60  vtkImageStencilData* stencil = nullptr, vtkAlgorithm* algorithm = nullptr, int threadId = 0)
61  {
62  this->Initialize(image, extent, stencil, algorithm, threadId);
63  }
64 
68  void Initialize(vtkImageData* image, const int extent[6] = nullptr,
69  vtkImageStencilData* stencil = nullptr, vtkAlgorithm* algorithm = nullptr, int threadId = 0);
70 
76  void NextSpan();
77 
81  bool IsAtEnd() { return (this->Id == this->End); }
82 
87  bool IsInStencil() { return this->InStencil; }
88 
90 
93  void GetIndex(int result[3])
94  {
95  result[0] = this->Index[0];
96  result[1] = this->Index[1];
97  result[2] = this->Index[2];
98  }
100 
104  const int* GetIndex() VTK_SIZEHINT(3) { return this->Index; }
105 
109  vtkIdType GetId() { return this->Id; }
110 
114  vtkIdType SpanEndId() { return this->SpanEnd; }
115 
120  static void* GetVoidPointer(vtkImageData* image, vtkIdType i = 0, int* pixelIncrement = nullptr);
121 
127  static void* GetVoidPointer(vtkDataArray* array, vtkIdType i = 0, int* pixelIncrement = nullptr);
128 
129 protected:
133  void SetSpanState(int idX);
134 
140  void ReportProgress();
141 
142  vtkIdType Id; // the current point Id
143  vtkIdType SpanEnd; // end of current span
144  vtkIdType RowEnd; // end of current row
145  vtkIdType SliceEnd; // end of current slice
146  vtkIdType End; // end of data
147 
148  // Increments
149  vtkIdType RowIncrement; // to same position in next row
150  vtkIdType SliceIncrement; // to same position in next slice
151  vtkIdType RowEndIncrement; // from end of row to start of next row
152  vtkIdType SliceEndIncrement; // from end of slice to start of next slice
153 
154  // The extent, adjusted for the stencil
155  int Extent[6];
156 
157  // Index-related items
158  int Index[3];
159  int StartY;
160 
161  // Stencil-related items
163  bool InStencil;
169 
170  // Progress-related items
174  int ThreadId;
175 };
176 
177 #endif
178 // 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:338
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:62
efficient description of an image stencil
topologically and geometrically regular array of data
Definition: vtkImageData.h:41
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:49
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.