VTK
vtkAbstractImageInterpolator.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkAbstractImageInterpolator.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 =========================================================================*/
29 #ifndef vtkAbstractImageInterpolator_h
30 #define vtkAbstractImageInterpolator_h
31 
32 #include "vtkImagingCoreModule.h" // For export macro
33 #include "vtkObject.h"
34 
35 #define VTK_IMAGE_BORDER_CLAMP 0
36 #define VTK_IMAGE_BORDER_REPEAT 1
37 #define VTK_IMAGE_BORDER_MIRROR 2
38 
39 class vtkDataObject;
40 class vtkImageData;
41 class vtkDataArray;
44 
46 {
47 public:
49  virtual void PrintSelf(ostream& os, vtkIndent indent);
50 
53  virtual void Initialize(vtkDataObject *data);
54 
56  virtual void ReleaseData();
57 
61 
65  void Update();
66 
72  double Interpolate(double x, double y, double z, int component);
73 
79  bool Interpolate(const double point[3], double *value);
80 
82 
83  void SetOutValue(double outValue);
84  double GetOutValue() { return this->OutValue; }
86 
88 
91  void SetTolerance(double tol);
92  double GetTolerance() { return this->Tolerance; }
94 
96 
100  void SetComponentOffset(int offset);
101  int GetComponentOffset() { return this->ComponentOffset; }
103 
105 
109  void SetComponentCount(int count);
110  int GetComponentCount() { return this->ComponentCount; }
112 
115  int ComputeNumberOfComponents(int inputComponents);
116 
120  int GetNumberOfComponents();
121 
123 
126  void InterpolateIJK(const double point[3], double *value);
127  void InterpolateIJK(const float point[3], float *value);
129 
131 
135  bool CheckBoundsIJK(const double x[3]);
136  bool CheckBoundsIJK(const float x[3]);
138 
140 
145  void SetBorderMode(int mode);
147  this->SetBorderMode(VTK_IMAGE_BORDER_CLAMP); }
149  this->SetBorderMode(VTK_IMAGE_BORDER_REPEAT); }
151  this->SetBorderMode(VTK_IMAGE_BORDER_MIRROR); }
152  int GetBorderMode() { return this->BorderMode; }
153  const char *GetBorderModeAsString();
155 
161  virtual void ComputeSupportSize(const double matrix[16], int support[3]) = 0;
162 
167  virtual bool IsSeparable() = 0;
168 
170 
178  virtual void PrecomputeWeightsForExtent(
179  const double matrix[16], const int extent[6], int checkExtent[6],
180  vtkInterpolationWeights *&weights);
181  virtual void PrecomputeWeightsForExtent(
182  const float matrix[16], const int extent[6], int checkExtent[6],
183  vtkInterpolationWeights *&weights);
185 
187  virtual void FreePrecomputedWeights(vtkInterpolationWeights *&weights);
188 
190 
194  void InterpolateRow(
195  vtkInterpolationWeights *&weights, int xIdx, int yIdx, int zIdx,
196  double *value, int n);
197  void InterpolateRow(
198  vtkInterpolationWeights *&weights, int xIdx, int yIdx, int zIdx,
199  float *value, int n);
201 
203 
204  vtkGetVector3Macro(Spacing, double);
206 
208 
209  vtkGetVector3Macro(Origin, double);
211 
213 
214  vtkGetVector6Macro(Extent, int);
216 
218 
220  vtkGetVector6Macro(WholeExtent, int);
222 
223 protected:
226 
228  virtual void InternalUpdate() = 0;
229 
231  virtual void InternalDeepCopy(vtkAbstractImageInterpolator *obj) = 0;
232 
234 
235  virtual void GetInterpolationFunc(
236  void (**doublefunc)(
237  vtkInterpolationInfo *, const double [3], double *));
238  virtual void GetInterpolationFunc(
239  void (**floatfunc)(
240  vtkInterpolationInfo *, const float [3], float *));
242 
244 
245  virtual void GetRowInterpolationFunc(
246  void (**doublefunc)(
247  vtkInterpolationWeights *, int, int, int, double *, int));
248  virtual void GetRowInterpolationFunc(
249  void (**floatfunc)(
250  vtkInterpolationWeights *, int, int, int, float *, int));
252 
254  double StructuredBoundsDouble[6];
255  float StructuredBoundsFloat[6];
256  int WholeExtent[6];
257  int Extent[6];
258  double Spacing[3];
259  double Origin[3];
260  double OutValue;
261  double Tolerance;
265 
266  // information needed by the interpolator funcs
268 
269  void (*InterpolationFuncDouble)(
270  vtkInterpolationInfo *info, const double point[3], double *outPtr);
271  void (*InterpolationFuncFloat)(
272  vtkInterpolationInfo *info, const float point[3], float *outPtr);
273 
274  void (*RowInterpolationFuncDouble)(
275  vtkInterpolationWeights *weights, int idX, int idY, int idZ,
276  double *outPtr, int n);
277  void (*RowInterpolationFuncFloat)(
278  vtkInterpolationWeights *weights, int idX, int idY, int idZ,
279  float *outPtr, int n);
280 
281 private:
282 
284  void operator=(const vtkAbstractImageInterpolator&); // Not implemented.
285 };
286 
288  const double point[3], double *value)
289 {
290  this->InterpolationFuncDouble(this->InterpolationInfo, point, value);
291 }
292 
294  const float point[3], float *value)
295 {
296  this->InterpolationFuncFloat(this->InterpolationInfo, point, value);
297 }
298 
299 inline bool vtkAbstractImageInterpolator::CheckBoundsIJK(const double x[3])
300 {
301  double *bounds = this->StructuredBoundsDouble;
302  return !((x[0] < bounds[0]) | (x[0] > bounds[1]) |
303  (x[1] < bounds[2]) | (x[1] > bounds[3]) |
304  (x[2] < bounds[4]) | (x[2] > bounds[5]));
305 }
306 
307 inline bool vtkAbstractImageInterpolator::CheckBoundsIJK(const float x[3])
308 {
309  float *bounds = this->StructuredBoundsFloat;
310  return !((x[0] < bounds[0]) | (x[0] > bounds[1]) |
311  (x[1] < bounds[2]) | (x[1] > bounds[3]) |
312  (x[2] < bounds[4]) | (x[2] > bounds[5]));
313 }
314 
316  vtkInterpolationWeights *&weights, int xIdx, int yIdx, int zIdx,
317  double *value, int n)
318 {
319  this->RowInterpolationFuncDouble(weights, xIdx, yIdx, zIdx, value, n);
320 }
321 
323  vtkInterpolationWeights *&weights, int xIdx, int yIdx, int zIdx,
324  float *value, int n)
325 {
326  this->RowInterpolationFuncFloat(weights, xIdx, yIdx, zIdx, value, n);
327 }
328 
329 #endif
interpolate data values from images
abstract base class for most VTK objects
Definition: vtkObject.h:61
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
virtual void Update()
#define VTK_IMAGE_BORDER_REPEAT
#define VTK_IMAGE_BORDER_CLAMP
void InterpolateIJK(const double point[3], double *value)
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:38
topologically and geometrically regular array of data
Definition: vtkImageData.h:44
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
#define VTKIMAGINGCORE_EXPORT
void(* InterpolationFuncFloat)(vtkInterpolationInfo *info, const float point[3], float *outPtr)
#define VTK_IMAGE_BORDER_MIRROR
void(* RowInterpolationFuncDouble)(vtkInterpolationWeights *weights, int idX, int idY, int idZ, double *outPtr, int n)
void(* RowInterpolationFuncFloat)(vtkInterpolationWeights *weights, int idX, int idY, int idZ, float *outPtr, int n)
general representation of visualization data
Definition: vtkDataObject.h:64
void InterpolateRow(vtkInterpolationWeights *&weights, int xIdx, int yIdx, int zIdx, double *value, int n)
void(* InterpolationFuncDouble)(vtkInterpolationInfo *info, const double point[3], double *outPtr)