VTK  9.3.1
vtkGridTransform.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
19 #ifndef vtkGridTransform_h
20 #define vtkGridTransform_h
21 
22 #include "vtkFiltersHybridModule.h" // For export macro
23 #include "vtkWarpTransform.h"
24 
25 VTK_ABI_NAMESPACE_BEGIN
26 class vtkAlgorithmOutput;
27 class vtkGridTransformConnectionHolder;
28 class vtkImageData;
29 
30 #define VTK_GRID_NEAREST VTK_NEAREST_INTERPOLATION
31 #define VTK_GRID_LINEAR VTK_LINEAR_INTERPOLATION
32 #define VTK_GRID_CUBIC VTK_CUBIC_INTERPOLATION
33 
34 class VTKFILTERSHYBRID_EXPORT vtkGridTransform : public vtkWarpTransform
35 {
36 public:
37  static vtkGridTransform* New();
39  void PrintSelf(ostream& os, vtkIndent indent) override;
40 
42 
49  virtual void SetDisplacementGridConnection(vtkAlgorithmOutput*);
50  virtual void SetDisplacementGridData(vtkImageData*);
51  virtual vtkImageData* GetDisplacementGrid();
53 
55 
60  vtkSetMacro(DisplacementScale, double);
61  vtkGetMacro(DisplacementScale, double);
63 
65 
70  vtkSetMacro(DisplacementShift, double);
71  vtkGetMacro(DisplacementShift, double);
73 
75 
80  void SetInterpolationMode(int mode);
81  vtkGetMacro(InterpolationMode, int);
83  {
84  this->SetInterpolationMode(VTK_NEAREST_INTERPOLATION);
85  }
86  void SetInterpolationModeToLinear() { this->SetInterpolationMode(VTK_LINEAR_INTERPOLATION); }
87  void SetInterpolationModeToCubic() { this->SetInterpolationMode(VTK_CUBIC_INTERPOLATION); }
88  const char* GetInterpolationModeAsString();
90 
95 
99  vtkMTimeType GetMTime() override;
100 
101 protected:
103  ~vtkGridTransform() override;
104 
108  void InternalUpdate() override;
109 
113  void InternalDeepCopy(vtkAbstractTransform* transform) override;
114 
116 
119  void ForwardTransformPoint(const float in[3], float out[3]) override;
120  void ForwardTransformPoint(const double in[3], double out[3]) override;
122 
123  void ForwardTransformDerivative(const float in[3], float out[3], float derivative[3][3]) override;
125  const double in[3], double out[3], double derivative[3][3]) override;
126 
127  void InverseTransformPoint(const float in[3], float out[3]) override;
128  void InverseTransformPoint(const double in[3], double out[3]) override;
129 
130  void InverseTransformDerivative(const float in[3], float out[3], float derivative[3][3]) override;
132  const double in[3], double out[3], double derivative[3][3]) override;
133 
134  void (*InterpolationFunction)(double point[3], double displacement[3], double derivatives[3][3],
135  void* gridPtr, int gridType, int inExt[6], vtkIdType inInc[3]);
136 
140 
141  void* GridPointer;
143  double GridSpacing[3];
144  double GridOrigin[3];
145  int GridExtent[6];
146  vtkIdType GridIncrements[3];
147 
148 private:
149  vtkGridTransform(const vtkGridTransform&) = delete;
150  void operator=(const vtkGridTransform&) = delete;
151 
152  vtkGridTransformConnectionHolder* ConnectionHolder;
153 };
154 
155 //----------------------------------------------------------------------------
157 {
158  switch (this->InterpolationMode)
159  {
160  case VTK_GRID_NEAREST:
161  return "NearestNeighbor";
162  case VTK_GRID_LINEAR:
163  return "Linear";
164  case VTK_GRID_CUBIC:
165  return "Cubic";
166  default:
167  return "";
168  }
169 }
170 
171 VTK_ABI_NAMESPACE_END
172 #endif
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:270
#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:315
#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:28
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
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