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 
101  int GetComponentOffset() { return this->ComponentOffset; }
103 
105 
110  int GetComponentCount() { return this->ComponentCount; }
112 
115  int ComputeNumberOfComponents(int inputComponents);
116 
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 
179  const double matrix[16], const int extent[6], int checkExtent[6],
182  const float matrix[16], const int extent[6], int checkExtent[6],
185 
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 
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 
246  void (**doublefunc)(
247  vtkInterpolationWeights *, int, int, int, double *, int));
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 
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 
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
vtkgl::z
GLdouble GLdouble z
Definition: vtkgl.h:11754
vtkGetVector6Macro
#define vtkGetVector6Macro(name, type)
Definition: vtkSetGet.h:380
vtkgl::data
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: vtkgl.h:11339
vtkAbstractImageInterpolator::BorderMode
int BorderMode
Definition: vtkAbstractImageInterpolator.h:262
vtkAbstractImageInterpolator::FreePrecomputedWeights
virtual void FreePrecomputedWeights(vtkInterpolationWeights *&weights)
vtkgl::weights
const GLbyte * weights
Definition: vtkgl.h:12766
vtkAbstractImageInterpolator::GetInterpolationFunc
virtual void GetInterpolationFunc(void(**floatfunc)(vtkInterpolationInfo *, const float[3], float *))
vtkAbstractImageInterpolator::ComponentCount
int ComponentCount
Definition: vtkAbstractImageInterpolator.h:264
vtkAbstractImageInterpolator::SetComponentCount
void SetComponentCount(int count)
vtkX3D::component
@ component
Definition: vtkX3D.h:175
vtkAbstractImageInterpolator::GetRowInterpolationFunc
virtual void GetRowInterpolationFunc(void(**doublefunc)(vtkInterpolationWeights *, int, int, int, double *, int))
vtkAbstractImageInterpolator::ComponentOffset
int ComponentOffset
Definition: vtkAbstractImageInterpolator.h:263
vtkgl::count
GLuint GLuint GLsizei count
Definition: vtkgl.h:11315
vtkAbstractImageInterpolator::SetTolerance
void SetTolerance(double tol)
vtkgl::obj
GLsizei GLsizei GLuint * obj
Definition: vtkgl.h:11994
vtkAbstractImageInterpolator::vtkAbstractImageInterpolator
vtkAbstractImageInterpolator()
vtkAbstractImageInterpolator::GetTolerance
double GetTolerance()
Definition: vtkAbstractImageInterpolator.h:92
vtkAbstractImageInterpolator::SetComponentOffset
void SetComponentOffset(int offset)
vtkAbstractImageInterpolator::InterpolationFuncFloat
void(* InterpolationFuncFloat)(vtkInterpolationInfo *info, const float point[3], float *outPtr)
Definition: vtkAbstractImageInterpolator.h:271
vtkInterpolationInfo
Definition: vtkImageInterpolatorInternals.h:26
vtkAbstractImageInterpolator::InterpolationFuncDouble
void(* InterpolationFuncDouble)(vtkInterpolationInfo *info, const double point[3], double *outPtr)
Definition: vtkAbstractImageInterpolator.h:269
vtkTypeMacro
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:642
vtkgl::n
GLclampd n
Definition: vtkgl.h:14370
vtkAbstractImageInterpolator::ComputeNumberOfComponents
int ComputeNumberOfComponents(int inputComponents)
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
VTK_IMAGE_BORDER_MIRROR
#define VTK_IMAGE_BORDER_MIRROR
Definition: vtkAbstractImageInterpolator.h:37
vtkAbstractImageInterpolator::GetNumberOfComponents
int GetNumberOfComponents()
vtkgl::x
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
vtkAbstractImageInterpolator::PrintSelf
virtual void PrintSelf(ostream &os, vtkIndent indent)
vtkAbstractImageInterpolator::CheckBoundsIJK
bool CheckBoundsIJK(const double x[3])
Definition: vtkAbstractImageInterpolator.h:299
vtkAbstractImageInterpolator::InternalDeepCopy
virtual void InternalDeepCopy(vtkAbstractImageInterpolator *obj)=0
vtkAbstractImageInterpolator::StructuredBoundsFloat
float StructuredBoundsFloat[6]
Definition: vtkAbstractImageInterpolator.h:255
vtkAbstractImageInterpolator::OutValue
double OutValue
Definition: vtkAbstractImageInterpolator.h:260
vtkAbstractImageInterpolator::ReleaseData
virtual void ReleaseData()
vtkAbstractImageInterpolator::DeepCopy
void DeepCopy(vtkAbstractImageInterpolator *obj)
vtkX3D::point
@ point
Definition: vtkX3D.h:236
vtkAbstractImageInterpolator::~vtkAbstractImageInterpolator
~vtkAbstractImageInterpolator()
vtkGetVector3Macro
#define vtkGetVector3Macro(name, type)
Definition: vtkSetGet.h:304
vtkgl::value
GLsizei const GLfloat * value
Definition: vtkgl.h:12021
VTK_IMAGE_BORDER_CLAMP
#define VTK_IMAGE_BORDER_CLAMP
Definition: vtkAbstractImageInterpolator.h:35
vtkAbstractImageInterpolator::GetComponentCount
int GetComponentCount()
Definition: vtkAbstractImageInterpolator.h:110
vtkAbstractImageInterpolator::SetBorderMode
void SetBorderMode(int mode)
vtkAbstractImageInterpolator::SetBorderModeToRepeat
void SetBorderModeToRepeat()
Definition: vtkAbstractImageInterpolator.h:148
vtkAbstractImageInterpolator::ComputeSupportSize
virtual void ComputeSupportSize(const double matrix[16], int support[3])=0
vtkAbstractImageInterpolator::RowInterpolationFuncDouble
void(* RowInterpolationFuncDouble)(vtkInterpolationWeights *weights, int idX, int idY, int idZ, double *outPtr, int n)
Definition: vtkAbstractImageInterpolator.h:274
vtkAbstractImageInterpolator::Update
void Update()
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkAbstractImageInterpolator::InterpolateIJK
void InterpolateIJK(const double point[3], double *value)
Definition: vtkAbstractImageInterpolator.h:287
vtkAbstractImageInterpolator::InternalUpdate
virtual void InternalUpdate()=0
vtkgl::offset
GLintptr offset
Definition: vtkgl.h:11844
vtkAbstractImageInterpolator::Initialize
virtual void Initialize(vtkDataObject *data)
vtkObject.h
VTK_IMAGE_BORDER_REPEAT
#define VTK_IMAGE_BORDER_REPEAT
Definition: vtkAbstractImageInterpolator.h:36
vtkAbstractImageInterpolator::InterpolateRow
void InterpolateRow(vtkInterpolationWeights *&weights, int xIdx, int yIdx, int zIdx, double *value, int n)
Definition: vtkAbstractImageInterpolator.h:315
vtkAbstractImageInterpolator::Tolerance
double Tolerance
Definition: vtkAbstractImageInterpolator.h:261
vtkAbstractImageInterpolator::SetBorderModeToMirror
void SetBorderModeToMirror()
Definition: vtkAbstractImageInterpolator.h:150
vtkAbstractImageInterpolator::GetOutValue
double GetOutValue()
Definition: vtkAbstractImageInterpolator.h:84
vtkX3D::info
@ info
Definition: vtkX3D.h:376
vtkAbstractImageInterpolator::SetBorderModeToClamp
void SetBorderModeToClamp()
Definition: vtkAbstractImageInterpolator.h:146
vtkAbstractImageInterpolator::Scalars
vtkDataArray * Scalars
Definition: vtkAbstractImageInterpolator.h:253
vtkAbstractImageInterpolator::Interpolate
bool Interpolate(const double point[3], double *value)
vtkgl::y
GLint GLint GLint GLint GLint GLint y
Definition: vtkgl.h:11318
vtkAbstractImageInterpolator::PrecomputeWeightsForExtent
virtual void PrecomputeWeightsForExtent(const float matrix[16], const int extent[6], int checkExtent[6], vtkInterpolationWeights *&weights)
vtkInterpolationWeights
Definition: vtkImageInterpolatorInternals.h:39
vtkAbstractImageInterpolator::IsSeparable
virtual bool IsSeparable()=0
vtkgl::matrix
GLuint GLenum matrix
Definition: vtkgl.h:16451
vtkAbstractImageInterpolator::Interpolate
double Interpolate(double x, double y, double z, int component)
vtkAbstractImageInterpolator::GetInterpolationFunc
virtual void GetInterpolationFunc(void(**doublefunc)(vtkInterpolationInfo *, const double[3], double *))
vtkImagingCoreModule.h
vtkAbstractImageInterpolator::InterpolationInfo
vtkInterpolationInfo * InterpolationInfo
Definition: vtkAbstractImageInterpolator.h:267
vtkX3D::extent
@ extent
Definition: vtkX3D.h:345
vtkgl::void
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
vtkAbstractImageInterpolator::SetOutValue
void SetOutValue(double outValue)
VTKIMAGINGCORE_EXPORT
#define VTKIMAGINGCORE_EXPORT
Definition: vtkImagingCoreModule.h:15
vtkAbstractImageInterpolator::GetComponentOffset
int GetComponentOffset()
Definition: vtkAbstractImageInterpolator.h:101
vtkAbstractImageInterpolator
interpolate data values from images
Definition: vtkAbstractImageInterpolator.h:46
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:65
vtkAbstractImageInterpolator::PrecomputeWeightsForExtent
virtual void PrecomputeWeightsForExtent(const double matrix[16], const int extent[6], int checkExtent[6], vtkInterpolationWeights *&weights)
vtkgl::mode
GLenum mode
Definition: vtkgl.h:12325
vtkAbstractImageInterpolator::RowInterpolationFuncFloat
void(* RowInterpolationFuncFloat)(vtkInterpolationWeights *weights, int idX, int idY, int idZ, float *outPtr, int n)
Definition: vtkAbstractImageInterpolator.h:277
vtkAbstractImageInterpolator::StructuredBoundsDouble
double StructuredBoundsDouble[6]
Definition: vtkAbstractImageInterpolator.h:254
vtkAbstractImageInterpolator::GetRowInterpolationFunc
virtual void GetRowInterpolationFunc(void(**floatfunc)(vtkInterpolationWeights *, int, int, int, float *, int))
vtkAbstractImageInterpolator::GetBorderModeAsString
const char * GetBorderModeAsString()
vtkAbstractImageInterpolator::GetBorderMode
int GetBorderMode()
Definition: vtkAbstractImageInterpolator.h:152