VTK
vtkGridTransform.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkGridTransform.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 =========================================================================*/
28 #ifndef vtkGridTransform_h
29 #define vtkGridTransform_h
30 
31 #include "vtkFiltersHybridModule.h" // For export macro
32 #include "vtkWarpTransform.h"
33 
34 class vtkAlgorithmOutput;
35 class vtkGridTransformConnectionHolder;
36 class vtkImageData;
37 
38 #define VTK_GRID_NEAREST VTK_NEAREST_INTERPOLATION
39 #define VTK_GRID_LINEAR VTK_LINEAR_INTERPOLATION
40 #define VTK_GRID_CUBIC VTK_CUBIC_INTERPOLATION
41 
42 class VTKFILTERSHYBRID_EXPORT vtkGridTransform : public vtkWarpTransform
43 {
44 public:
45  static vtkGridTransform *New();
47  void PrintSelf(ostream& os, vtkIndent indent) override;
48 
50 
57  virtual void SetDisplacementGridConnection(vtkAlgorithmOutput*);
58  virtual void SetDisplacementGridData(vtkImageData*);
59  virtual vtkImageData* GetDisplacementGrid();
61 
63 
68  vtkSetMacro(DisplacementScale,double);
69  vtkGetMacro(DisplacementScale,double);
71 
73 
78  vtkSetMacro(DisplacementShift,double);
79  vtkGetMacro(DisplacementShift,double);
81 
83 
88  void SetInterpolationMode(int mode);
89  vtkGetMacro(InterpolationMode,int);
91  { this->SetInterpolationMode(VTK_NEAREST_INTERPOLATION); };
93  { this->SetInterpolationMode(VTK_LINEAR_INTERPOLATION); };
95  { this->SetInterpolationMode(VTK_CUBIC_INTERPOLATION); };
96  const char *GetInterpolationModeAsString();
98 
103 
107  vtkMTimeType GetMTime() override;
108 
109 protected:
111  ~vtkGridTransform() override;
112 
116  void InternalUpdate() override;
117 
121  void InternalDeepCopy(vtkAbstractTransform *transform) override;
122 
124 
127  void ForwardTransformPoint(const float in[3], float out[3]) override;
128  void ForwardTransformPoint(const double in[3], double out[3]) override;
130 
131  void ForwardTransformDerivative(const float in[3], float out[3],
132  float derivative[3][3]) override;
133  void ForwardTransformDerivative(const double in[3], double out[3],
134  double derivative[3][3]) override;
135 
136  void InverseTransformPoint(const float in[3], float out[3]) override;
137  void InverseTransformPoint(const double in[3], double out[3]) override;
138 
139  void InverseTransformDerivative(const float in[3], float out[3],
140  float derivative[3][3]) override;
141  void InverseTransformDerivative(const double in[3], double out[3],
142  double derivative[3][3]) override;
143 
144  void (*InterpolationFunction)(double point[3], double displacement[3],
145  double derivatives[3][3],
146  void *gridPtr, int gridType,
147  int inExt[6], vtkIdType inInc[3]);
148 
152 
153  void *GridPointer;
155  double GridSpacing[3];
156  double GridOrigin[3];
157  int GridExtent[6];
158  vtkIdType GridIncrements[3];
159 
160 private:
161  vtkGridTransform(const vtkGridTransform&) = delete;
162  void operator=(const vtkGridTransform&) = delete;
163 
164  vtkGridTransformConnectionHolder* ConnectionHolder;
165 };
166 
167 //----------------------------------------------------------------------------
169 {
170  switch (this->InterpolationMode)
171  {
172  case VTK_GRID_NEAREST:
173  return "NearestNeighbor";
174  case VTK_GRID_LINEAR:
175  return "Linear";
176  case VTK_GRID_CUBIC:
177  return "Cubic";
178  default:
179  return "";
180  }
181 }
182 
183 #endif
184 
185 
186 
187 
188 
virtual void ForwardTransformPoint(const float in[3], float out[3])=0
If the InverseFlag is set to 0, then a call to InternalTransformPoint results in a call to ForwardTra...
virtual void InverseTransformPoint(const float in[3], float out[3])
If the InverseFlag is set to 1, then a call to InternalTransformPoint results in a call to InverseTra...
vtkMTimeType GetMTime() override
Override GetMTime necessary because of inverse transforms.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:302
#define VTK_LINEAR_INTERPOLATION
virtual void InverseTransformDerivative(const float in[3], float out[3], float derivative[3][3])
Calculate the inverse transform as well as the derivative of the forward transform (that's correct: t...
virtual void InternalUpdate()
Perform any subclass-specific Update.
virtual vtkAbstractTransform * MakeTransform()=0
Make another transform of the same type.
#define VTK_GRID_LINEAR
int vtkIdType
Definition: vtkType.h:347
#define VTK_CUBIC_INTERPOLATION
Proxy object to connect input/output ports.
void SetInterpolationModeToLinear()
Set interpolation mode for sampling the grid.
virtual void ForwardTransformDerivative(const float in[3], float out[3], float derivative[3][3])=0
Calculate the forward transform as well as the derivative.
virtual void InternalDeepCopy(vtkAbstractTransform *)
Perform any subclass-specific DeepCopy.
void SetInterpolationModeToNearestNeighbor()
Set interpolation mode for sampling the grid.
const char * GetInterpolationModeAsString()
Set interpolation mode for sampling the grid.
#define VTK_GRID_CUBIC
a simple class to control print indentation
Definition: vtkIndent.h:33
topologically and geometrically regular array of data
Definition: vtkImageData.h:39
superclass for all geometric transformations
superclass for nonlinear geometric transformations
#define VTK_GRID_NEAREST
void SetInterpolationModeToCubic()
Set interpolation mode for sampling the grid.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
#define VTK_NEAREST_INTERPOLATION
a nonlinear warp transformation