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 =========================================================================*/
34 #ifndef vtkImagePointDataIterator_h
35 #define vtkImagePointDataIterator_h
36 
37 #include "vtkSystemIncludes.h"
38 #include "vtkImagingCoreModule.h" // for export macro
39 
40 class vtkDataArray;
41 class vtkImageData;
43 class vtkAlgorithm;
44 
45 class VTKIMAGINGCORE_EXPORT vtkImagePointDataIterator
46 {
47 public:
52 
63  const int extent[6] = nullptr,
64  vtkImageStencilData *stencil=nullptr,
65  vtkAlgorithm *algorithm=nullptr,
66  int threadId=0)
67  {
68  this->Initialize(image, extent, stencil, algorithm, threadId);
69  }
70 
74  void Initialize(vtkImageData *image, const int extent[6] = nullptr,
75  vtkImageStencilData *stencil=nullptr,
76  vtkAlgorithm *algorithm=nullptr, int threadId=0);
77 
83  void NextSpan();
84 
88  bool IsAtEnd()
89  {
90  return (this->Id == this->End);
91  }
92 
97  bool IsInStencil()
98  {
99  return this->InStencil;
100  }
101 
103 
106  void GetIndex(int result[3])
107  {
108  result[0] = this->Index[0];
109  result[1] = this->Index[1];
110  result[2] = this->Index[2];
111  }
113 
117  const int *GetIndex() VTK_SIZEHINT(3)
118  {
119  return this->Index;
120  }
121 
126  {
127  return this->Id;
128  }
129 
134  {
135  return this->SpanEnd;
136  }
137 
142  static void *GetVoidPointer(vtkImageData *image,
143  vtkIdType i=0,
144  int *pixelIncrement=nullptr);
145 
151  static void *GetVoidPointer(vtkDataArray *array,
152  vtkIdType i=0,
153  int *pixelIncrement=nullptr);
154 
155 protected:
156 
160  void SetSpanState(int idX);
161 
167  void ReportProgress();
168 
169  vtkIdType Id; // the current point Id
170  vtkIdType SpanEnd; // end of current span
171  vtkIdType RowEnd; // end of current row
172  vtkIdType SliceEnd; // end of current slice
173  vtkIdType End; // end of data
174 
175  // Increments
176  vtkIdType RowIncrement; // to same position in next row
177  vtkIdType SliceIncrement; // to same position in next slice
178  vtkIdType RowEndIncrement; // from end of row to start of next row
179  vtkIdType SliceEndIncrement; // from end of slice to start of next slice
180 
181  // The extent, adjusted for the stencil
182  int Extent[6];
183 
184  // Index-related items
185  int Index[3];
186  int StartY;
187 
188  // Stencil-related items
190  bool InStencil;
196 
197  // Progress-related items
201  int ThreadId;
202 };
203 
204 #endif
205 // 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:59
efficient description of an image stencil
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
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.