VTK  9.3.20240327
vtkAbstractTransform.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
27 #ifndef vtkAbstractTransform_h
28 #define vtkAbstractTransform_h
29 
30 #include "vtkCommonTransformsModule.h" // For export macro
31 #include "vtkObject.h"
32 
33 VTK_ABI_NAMESPACE_BEGIN
34 class vtkDataArray;
35 class vtkMatrix4x4;
36 class vtkPoints;
37 
38 class VTKCOMMONTRANSFORMS_EXPORT vtkAbstractTransform : public vtkObject
39 {
40 public:
42  void PrintSelf(ostream& os, vtkIndent indent) override;
43 
48  void TransformPoint(const float in[3], float out[3])
49  {
50  this->Update();
51  this->InternalTransformPoint(in, out);
52  }
53 
58  void TransformPoint(const double in[3], double out[3])
59  {
60  this->Update();
61  this->InternalTransformPoint(in, out);
62  }
63 
68  double* TransformPoint(double x, double y, double z) VTK_SIZEHINT(3)
69  {
70  return this->TransformDoublePoint(x, y, z);
71  }
72  double* TransformPoint(const double point[3]) VTK_SIZEHINT(3)
73  {
74  return this->TransformPoint(point[0], point[1], point[2]);
75  }
76 
78 
82  float* TransformFloatPoint(float x, float y, float z) VTK_SIZEHINT(3)
83  {
84  this->InternalFloatPoint[0] = x;
85  this->InternalFloatPoint[1] = y;
86  this->InternalFloatPoint[2] = z;
87  this->TransformPoint(this->InternalFloatPoint, this->InternalFloatPoint);
88  return this->InternalFloatPoint;
89  }
90  float* TransformFloatPoint(const float point[3]) VTK_SIZEHINT(3)
91  {
92  return this->TransformFloatPoint(point[0], point[1], point[2]);
93  }
95 
97 
101  double* TransformDoublePoint(double x, double y, double z) VTK_SIZEHINT(3)
102  {
103  this->InternalDoublePoint[0] = x;
104  this->InternalDoublePoint[1] = y;
105  this->InternalDoublePoint[2] = z;
106  this->TransformPoint(this->InternalDoublePoint, this->InternalDoublePoint);
107  return this->InternalDoublePoint;
108  }
109  double* TransformDoublePoint(const double point[3]) VTK_SIZEHINT(3)
110  {
111  return this->TransformDoublePoint(point[0], point[1], point[2]);
112  }
114 
116 
121  void TransformNormalAtPoint(const float point[3], const float in[3], float out[3]);
122  void TransformNormalAtPoint(const double point[3], const double in[3], double out[3]);
124 
125  double* TransformNormalAtPoint(const double point[3], const double normal[3]) VTK_SIZEHINT(3)
126  {
127  this->TransformNormalAtPoint(point, normal, this->InternalDoublePoint);
128  return this->InternalDoublePoint;
129  }
130 
132 
137  double* TransformDoubleNormalAtPoint(const double point[3], const double normal[3])
138  VTK_SIZEHINT(3)
139  {
140  this->TransformNormalAtPoint(point, normal, this->InternalDoublePoint);
141  return this->InternalDoublePoint;
142  }
144 
146 
151  float* TransformFloatNormalAtPoint(const float point[3], const float normal[3]) VTK_SIZEHINT(3)
152  {
153  this->TransformNormalAtPoint(point, normal, this->InternalFloatPoint);
154  return this->InternalFloatPoint;
155  }
157 
159 
164  void TransformVectorAtPoint(const float point[3], const float in[3], float out[3]);
165  void TransformVectorAtPoint(const double point[3], const double in[3], double out[3]);
167 
168  double* TransformVectorAtPoint(const double point[3], const double vector[3]) VTK_SIZEHINT(3)
169  {
170  this->TransformVectorAtPoint(point, vector, this->InternalDoublePoint);
171  return this->InternalDoublePoint;
172  }
173 
175 
180  double* TransformDoubleVectorAtPoint(const double point[3], const double vector[3])
181  VTK_SIZEHINT(3)
182  {
183  this->TransformVectorAtPoint(point, vector, this->InternalDoublePoint);
184  return this->InternalDoublePoint;
185  }
187 
189 
194  float* TransformFloatVectorAtPoint(const float point[3], const float vector[3]) VTK_SIZEHINT(3)
195  {
196  this->TransformVectorAtPoint(point, vector, this->InternalFloatPoint);
197  return this->InternalFloatPoint;
198  }
200 
205  virtual void TransformPoints(vtkPoints* inPts, vtkPoints* outPts);
206 
211  virtual void TransformPointsNormalsVectors(vtkPoints* inPts, vtkPoints* outPts,
212  vtkDataArray* inNms, vtkDataArray* outNms, vtkDataArray* inVrs, vtkDataArray* outVrs,
213  int nOptionalVectors = 0, vtkDataArray** inVrsArr = nullptr,
214  vtkDataArray** outVrsArr = nullptr);
215 
224 
231 
235  virtual void Inverse() = 0;
236 
241 
248  void Update();
249 
251 
255  virtual void InternalTransformPoint(const float in[3], float out[3]) = 0;
256  virtual void InternalTransformPoint(const double in[3], double out[3]) = 0;
258 
260 
267  const float in[3], float out[3], float derivative[3][3]) = 0;
269  const double in[3], double out[3], double derivative[3][3]) = 0;
271 
276 
285  virtual int CircuitCheck(vtkAbstractTransform* transform);
286 
290  vtkMTimeType GetMTime() override;
291 
296  void UnRegister(vtkObjectBase* O) override;
297 
298 protected:
301 
305  virtual void InternalUpdate() {}
306 
311 
312  float InternalFloatPoint[3];
313  double InternalDoublePoint[3];
314 
315 private:
316  class vtkInternals;
317 
318  vtkInternals* Internals;
319 
321  void operator=(const vtkAbstractTransform&) = delete;
322 };
323 
324 //-------------------------------------------------------------------------
325 // A simple data structure to hold both a transform and its inverse.
326 // One of ForwardTransform or InverseTransform might be nullptr,
327 // and must be acquired by calling GetInverse() on the other.
329 {
330 public:
331  vtkTransformPair() = default;
332 
335 
337  {
339  this->ForwardTransform = this->InverseTransform;
340  this->InverseTransform = tmp;
341  }
342 };
343 
344 // .NAME vtkTransformConcatenation - store a series of transformations.
345 // .SECTION Description
346 // A helper class (not derived from vtkObject) to store a series of
347 // transformations in a pipelined concatenation.
348 class VTKCOMMONTRANSFORMS_EXPORT vtkTransformConcatenation
349 {
350 public:
352  void Delete() { delete this; }
353 
358 
362  void Concatenate(const double elements[16]);
363 
365 
368  void SetPreMultiplyFlag(vtkTypeBool flag) { this->PreMultiplyFlag = flag; }
369  vtkTypeBool GetPreMultiplyFlag() { return this->PreMultiplyFlag; }
371 
373 
376  void Translate(double x, double y, double z);
377  void Rotate(double angle, double x, double y, double z);
378  void Scale(double x, double y, double z);
380 
384  void Inverse();
385 
389  vtkTypeBool GetInverseFlag() { return this->InverseFlag; }
390 
394  void Identity();
395 
396  // copy the list
398 
402  int GetNumberOfTransforms() { return this->NumberOfTransforms; }
403 
409  int GetNumberOfPreTransforms() { return this->NumberOfPreTransforms; }
410 
414  int GetNumberOfPostTransforms() { return this->NumberOfTransforms - this->NumberOfPreTransforms; }
415 
420 
425 
426  void PrintSelf(ostream& os, vtkIndent indent);
427 
428 protected:
431 
434 
439 
444 
445 private:
447  void operator=(const vtkTransformConcatenation&) = delete;
448 };
449 
450 // .NAME vtkTransformConcatenationStack - Store a stack of concatenations.
451 // .SECTION Description
452 // A helper class (not derived from vtkObject) to store a stack of
453 // concatenations.
454 class VTKCOMMONTRANSFORMS_EXPORT vtkTransformConcatenationStack
455 {
456 public:
458  void Delete() { delete this; }
459 
465 
471 
473 
474 protected:
477 
481 
482 private:
484  void operator=(const vtkTransformConcatenationStack&) = delete;
485 };
486 
487 VTK_ABI_NAMESPACE_END
488 #endif
superclass for all geometric transformations
double * TransformPoint(const double point[3])
double * TransformDoublePoint(double x, double y, double z)
Apply the transformation to a double-precision (x,y,z) coordinate.
void TransformPoint(const float in[3], float out[3])
Apply the transformation to a coordinate.
virtual void InternalTransformPoint(const float in[3], float out[3])=0
This will calculate the transformation without calling Update.
void TransformNormalAtPoint(const float point[3], const float in[3], float out[3])
Apply the transformation to a normal at the specified vertex.
float * TransformFloatPoint(const float point[3])
Apply the transformation to an (x,y,z) coordinate.
double * TransformDoublePoint(const double point[3])
Apply the transformation to a double-precision (x,y,z) coordinate.
void TransformVectorAtPoint(const float point[3], const float in[3], float out[3])
Apply the transformation to a vector at the specified vertex.
virtual int CircuitCheck(vtkAbstractTransform *transform)
Check for self-reference.
double * TransformVectorAtPoint(const double point[3], const double vector[3])
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void TransformPoints(vtkPoints *inPts, vtkPoints *outPts)
Apply the transformation to a series of points, and append the results to outPts.
virtual void InternalTransformPoint(const double in[3], double out[3])=0
This will calculate the transformation without calling Update.
float * TransformFloatPoint(float x, float y, float z)
Apply the transformation to an (x,y,z) coordinate.
void UnRegister(vtkObjectBase *O) override
Needs a special UnRegister() implementation to avoid circular references.
void Update()
Update the transform to account for any changes which have been made.
vtkAbstractTransform * GetInverse()
Get the inverse of this transform.
float * TransformFloatNormalAtPoint(const float point[3], const float normal[3])
Apply the transformation to a single-precision normal at the specified vertex.
virtual void InternalTransformDerivative(const double in[3], double out[3], double derivative[3][3])=0
This will transform a point and, at the same time, calculate a 3x3 Jacobian matrix that provides the ...
virtual void InternalDeepCopy(vtkAbstractTransform *)
Perform any subclass-specific DeepCopy.
void TransformVectorAtPoint(const double point[3], const double in[3], double out[3])
Apply the transformation to a vector at the specified vertex.
void SetInverse(vtkAbstractTransform *transform)
Set a transformation that this transform will be the inverse of.
virtual void Inverse()=0
Invert the transformation.
~vtkAbstractTransform() override
virtual void InternalTransformDerivative(const float in[3], float out[3], float derivative[3][3])=0
This will transform a point and, at the same time, calculate a 3x3 Jacobian matrix that provides the ...
double * TransformDoubleVectorAtPoint(const double point[3], const double vector[3])
Apply the transformation to a double-precision vector at the specified vertex.
float * TransformFloatVectorAtPoint(const float point[3], const float vector[3])
Apply the transformation to a single-precision vector at the specified vertex.
void TransformPoint(const double in[3], double out[3])
Apply the transformation to a double-precision coordinate.
void TransformNormalAtPoint(const double point[3], const double in[3], double out[3])
Apply the transformation to a normal at the specified vertex.
double * TransformDoubleNormalAtPoint(const double point[3], const double normal[3])
Apply the transformation to a double-precision normal at the specified vertex.
double * TransformPoint(double x, double y, double z)
Apply the transformation to a double-precision coordinate.
void DeepCopy(vtkAbstractTransform *)
Copy this transform from another of the same type.
virtual void InternalUpdate()
Perform any subclass-specific Update.
vtkMTimeType GetMTime() override
Override GetMTime necessary because of inverse transforms.
virtual void TransformPointsNormalsVectors(vtkPoints *inPts, vtkPoints *outPts, vtkDataArray *inNms, vtkDataArray *outNms, vtkDataArray *inVrs, vtkDataArray *outVrs, int nOptionalVectors=0, vtkDataArray **inVrsArr=nullptr, vtkDataArray **outVrsArr=nullptr)
Apply the transformation to a combination of points, normals and vectors.
double * TransformNormalAtPoint(const double point[3], const double normal[3])
virtual vtkAbstractTransform * MakeTransform()=0
Make another transform of the same type.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:154
a simple class to control print indentation
Definition: vtkIndent.h:108
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:140
abstract base class for most VTK objects
Definition: vtkObjectBase.h:83
abstract base class for most VTK objects
Definition: vtkObject.h:161
represent and manipulate 3D points
Definition: vtkPoints.h:138
void Push(vtkTransformConcatenation **concat)
push will move 'concat' onto the stack, and make 'concat' a copy of its previous self
static vtkTransformConcatenationStack * New()
vtkTransformConcatenation ** Stack
void Pop(vtkTransformConcatenation **concat)
pop will pop delete 'concat', then pop the top item on the stack onto 'concat'.
vtkTransformConcatenation ** StackBottom
void DeepCopy(vtkTransformConcatenationStack *stack)
vtkTypeBool GetInverseFlag()
get the inverse flag
int GetNumberOfPreTransforms()
the number of transforms that were pre-concatenated (note that whenever Inverse() is called,...
void DeepCopy(vtkTransformConcatenation *transform)
void Concatenate(vtkAbstractTransform *transform)
add a transform to the list according to Pre/PostMultiply semantics
void Identity()
identity simply clears the transform list
int GetNumberOfTransforms()
the number of stored transforms
void Concatenate(const double elements[16])
concatenate with a matrix according to Pre/PostMultiply semantics
vtkTypeBool GetPreMultiplyFlag()
set/get the PreMultiply flag
void Inverse()
invert the concatenation
void SetPreMultiplyFlag(vtkTypeBool flag)
set/get the PreMultiply flag
int GetNumberOfPostTransforms()
the number of transforms that were post-concatenated.
vtkTransformPair * TransformList
vtkMTimeType GetMaxMTime()
get maximum MTime of all transforms
vtkAbstractTransform * GetTransform(int i)
get one of the transforms
vtkAbstractTransform * PreMatrixTransform
void Translate(double x, double y, double z)
the three basic linear transformations
void Scale(double x, double y, double z)
the three basic linear transformations
static vtkTransformConcatenation * New()
void PrintSelf(ostream &os, vtkIndent indent)
vtkAbstractTransform * PostMatrixTransform
void Rotate(double angle, double x, double y, double z)
the three basic linear transformations
vtkTransformPair()=default
vtkAbstractTransform * ForwardTransform
vtkAbstractTransform * InverseTransform
@ point
Definition: vtkX3D.h:236
@ vector
Definition: vtkX3D.h:237
int vtkTypeBool
Definition: vtkABI.h:64
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270
#define VTK_SIZEHINT(...)
#define VTK_NEWINSTANCE