VTK
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 "vtkSystemIncludes.h"
35 #include "vtkImagingCoreModule.h" // for export macro
36 
37 class vtkDataArray;
38 class vtkImageData;
40 class vtkAlgorithm;
41 
42 class VTKIMAGINGCORE_EXPORT vtkImagePointDataIterator
43 {
44 public:
49 
60  const int extent[6] = nullptr,
61  vtkImageStencilData *stencil=nullptr,
62  vtkAlgorithm *algorithm=nullptr,
63  int threadId=0)
64  {
65  this->Initialize(image, extent, stencil, algorithm, threadId);
66  }
67 
71  void Initialize(vtkImageData *image, const int extent[6] = nullptr,
72  vtkImageStencilData *stencil=nullptr,
73  vtkAlgorithm *algorithm=nullptr, int threadId=0);
74 
80  void NextSpan();
81 
85  bool IsAtEnd()
86  {
87  return (this->Id == this->End);
88  }
89 
94  bool IsInStencil()
95  {
96  return this->InStencil;
97  }
98 
100 
103  void GetIndex(int result[3])
104  {
105  result[0] = this->Index[0];
106  result[1] = this->Index[1];
107  result[2] = this->Index[2];
108  }
110 
114  const int *GetIndex() VTK_SIZEHINT(3)
115  {
116  return this->Index;
117  }
118 
123  {
124  return this->Id;
125  }
126 
131  {
132  return this->SpanEnd;
133  }
134 
139  static void *GetVoidPointer(vtkImageData *image,
140  vtkIdType i=0,
141  int *pixelIncrement=nullptr);
142 
148  static void *GetVoidPointer(vtkDataArray *array,
149  vtkIdType i=0,
150  int *pixelIncrement=nullptr);
151 
152 protected:
153 
157  void SetSpanState(int idX);
158 
164  void ReportProgress();
165 
166  vtkIdType Id; // the current point Id
167  vtkIdType SpanEnd; // end of current span
168  vtkIdType RowEnd; // end of current row
169  vtkIdType SliceEnd; // end of current slice
170  vtkIdType End; // end of data
171 
172  // Increments
173  vtkIdType RowIncrement; // to same position in next row
174  vtkIdType SliceIncrement; // to same position in next slice
175  vtkIdType RowEndIncrement; // from end of row to start of next row
176  vtkIdType SliceEndIncrement; // from end of slice to start of next slice
177 
178  // The extent, adjusted for the stencil
179  int Extent[6];
180 
181  // Index-related items
182  int Index[3];
183  int StartY;
184 
185  // Stencil-related items
187  bool InStencil;
193 
194  // Progress-related items
198  int ThreadId;
199 };
200 
201 #endif
202 // 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:347
Superclass for all sources, filters, and sinks in VTK.
Definition: vtkAlgorithm.h:53
efficient description of an image stencil
topologically and geometrically regular array of data
Definition: vtkImageData.h:39
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
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.