VTK  9.7.1
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 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
33 
34 VTK_ABI_NAMESPACE_BEGIN
35 class vtkDataArray;
36 class vtkMatrix4x4;
37 class vtkPoints;
38 
39 class VTKCOMMONTRANSFORMS_EXPORT VTK_MARSHALAUTO vtkAbstractTransform : public vtkObject
40 {
41 public:
43  void PrintSelf(ostream& os, vtkIndent indent) override;
44 
49  void TransformPoint(const float in[3], float out[3])
50  {
51  this->Update();
52  this->InternalTransformPoint(in, out);
53  }
54 
59  void TransformPoint(const double in[3], double out[3])
60  {
61  this->Update();
62  this->InternalTransformPoint(in, out);
63  }
64 
69  double* TransformPoint(double x, double y, double z) VTK_SIZEHINT(3)
70  {
71  return this->TransformDoublePoint(x, y, z);
72  }
73  double* TransformPoint(const double point[3]) VTK_SIZEHINT(3)
74  {
75  return this->TransformPoint(point[0], point[1], point[2]);
76  }
77 
79 
83  float* TransformFloatPoint(float x, float y, float z) VTK_SIZEHINT(3)
84  {
85  this->InternalFloatPoint[0] = x;
86  this->InternalFloatPoint[1] = y;
87  this->InternalFloatPoint[2] = z;
88  this->TransformPoint(this->InternalFloatPoint, this->InternalFloatPoint);
89  return this->InternalFloatPoint;
90  }
91  float* TransformFloatPoint(const float point[3]) VTK_SIZEHINT(3)
92  {
93  return this->TransformFloatPoint(point[0], point[1], point[2]);
94  }
96 
98 
102  double* TransformDoublePoint(double x, double y, double z) VTK_SIZEHINT(3)
103  {
104  this->InternalDoublePoint[0] = x;
105  this->InternalDoublePoint[1] = y;
106  this->InternalDoublePoint[2] = z;
107  this->TransformPoint(this->InternalDoublePoint, this->InternalDoublePoint);
108  return this->InternalDoublePoint;
109  }
110  double* TransformDoublePoint(const double point[3]) VTK_SIZEHINT(3)
111  {
112  return this->TransformDoublePoint(point[0], point[1], point[2]);
113  }
115 
117 
122  void TransformNormalAtPoint(const float point[3], const float in[3], float out[3]);
123  void TransformNormalAtPoint(const double point[3], const double in[3], double out[3]);
125 
126  double* TransformNormalAtPoint(const double point[3], const double normal[3]) VTK_SIZEHINT(3)
127  {
128  this->TransformNormalAtPoint(point, normal, this->InternalDoublePoint);
129  return this->InternalDoublePoint;
130  }
131 
133 
138  double* TransformDoubleNormalAtPoint(const double point[3], const double normal[3])
139  VTK_SIZEHINT(3)
140  {
141  this->TransformNormalAtPoint(point, normal, this->InternalDoublePoint);
142  return this->InternalDoublePoint;
143  }
145 
147 
152  float* TransformFloatNormalAtPoint(const float point[3], const float normal[3]) VTK_SIZEHINT(3)
153  {
154  this->TransformNormalAtPoint(point, normal, this->InternalFloatPoint);
155  return this->InternalFloatPoint;
156  }
158 
160 
165  void TransformVectorAtPoint(const float point[3], const float in[3], float out[3]);
166  void TransformVectorAtPoint(const double point[3], const double in[3], double out[3]);
168 
169  double* TransformVectorAtPoint(const double point[3], const double vector[3]) VTK_SIZEHINT(3)
170  {
171  this->TransformVectorAtPoint(point, vector, this->InternalDoublePoint);
172  return this->InternalDoublePoint;
173  }
174 
176 
181  double* TransformDoubleVectorAtPoint(const double point[3], const double vector[3])
182  VTK_SIZEHINT(3)
183  {
184  this->TransformVectorAtPoint(point, vector, this->InternalDoublePoint);
185  return this->InternalDoublePoint;
186  }
188 
190 
195  float* TransformFloatVectorAtPoint(const float point[3], const float vector[3]) VTK_SIZEHINT(3)
196  {
197  this->TransformVectorAtPoint(point, vector, this->InternalFloatPoint);
198  return this->InternalFloatPoint;
199  }
201 
206  virtual void TransformPoints(vtkPoints* inPts, vtkPoints* outPts);
207 
212  virtual void TransformPointsNormalsVectors(vtkPoints* inPts, vtkPoints* outPts,
213  vtkDataArray* inNms, vtkDataArray* outNms, vtkDataArray* inVrs, vtkDataArray* outVrs,
214  int nOptionalVectors = 0, vtkDataArray** inVrsArr = nullptr,
215  vtkDataArray** outVrsArr = nullptr);
216 
221  virtual void TransformVectors(vtkDataArray* inArray, vtkDataArray* outArray);
222 
236  virtual void TransformNormals(vtkDataArray* inArray, vtkDataArray* outArray);
237 
246  vtkAbstractTransform* GetInverse();
247 
254  void SetInverse(vtkAbstractTransform* transform);
255 
259  virtual void Inverse() = 0;
260 
264  void DeepCopy(vtkAbstractTransform*);
265 
272  void Update();
273 
275 
279  virtual void InternalTransformPoint(const float in[3], float out[3]) = 0;
280  virtual void InternalTransformPoint(const double in[3], double out[3]) = 0;
282 
284 
290  virtual void InternalTransformDerivative(
291  const float in[3], float out[3], float derivative[3][3]) = 0;
292  virtual void InternalTransformDerivative(
293  const double in[3], double out[3], double derivative[3][3]) = 0;
295 
299  virtual VTK_NEWINSTANCE vtkAbstractTransform* MakeTransform() = 0;
300 
309  virtual int CircuitCheck(vtkAbstractTransform* transform);
310 
314  vtkMTimeType GetMTime() override;
315 
319  void Modified() override;
320 
325  void UnRegister(vtkObjectBase* O) override;
326 
327 protected:
328  vtkAbstractTransform();
329  ~vtkAbstractTransform() override;
330 
334  virtual void InternalUpdate() {}
335 
340 
341  float InternalFloatPoint[3];
342  double InternalDoublePoint[3];
343 
344 private:
345  class vtkInternals;
346 
347  vtkInternals* Internals;
348 
350  void operator=(const vtkAbstractTransform&) = delete;
351 };
352 
353 //-------------------------------------------------------------------------
354 // A simple data structure to hold both a transform and its inverse.
355 // One of ForwardTransform or InverseTransform might be nullptr,
356 // and must be acquired by calling GetInverse() on the other.
358 {
359 public:
360  vtkTransformPair() = default;
361 
364 
366  {
368  this->ForwardTransform = this->InverseTransform;
369  this->InverseTransform = tmp;
370  }
371 };
372 
373 // .NAME vtkTransformConcatenation - store a series of transformations.
374 // .SECTION Description
375 // A helper class (not derived from vtkObject) to store a series of
376 // transformations in a pipelined concatenation.
377 class VTKCOMMONTRANSFORMS_EXPORT vtkTransformConcatenation
378 {
379 public:
381  void Delete() { delete this; }
382 
386  void Concatenate(vtkAbstractTransform* transform);
387 
391  void Concatenate(const double elements[16]);
392 
394 
397  void SetPreMultiplyFlag(vtkTypeBool flag) { this->PreMultiplyFlag = flag; }
398  vtkTypeBool GetPreMultiplyFlag() { return this->PreMultiplyFlag; }
400 
402 
405  void Translate(double x, double y, double z);
406  void Rotate(double angle, double x, double y, double z);
407  void Scale(double x, double y, double z);
409 
413  void Inverse();
414 
418  vtkTypeBool GetInverseFlag() { return this->InverseFlag; }
419 
423  void Identity();
424 
425  // copy the list
426  void DeepCopy(vtkTransformConcatenation* transform);
427 
431  int GetNumberOfTransforms() { return this->NumberOfTransforms; }
432 
438  int GetNumberOfPreTransforms() { return this->NumberOfPreTransforms; }
439 
443  int GetNumberOfPostTransforms() { return this->NumberOfTransforms - this->NumberOfPreTransforms; }
444 
448  vtkAbstractTransform* GetTransform(int i);
449 
453  vtkMTimeType GetMaxMTime();
454 
455  void PrintSelf(ostream& os, vtkIndent indent);
456 
457 protected:
460 
463 
468 
473 
474 private:
476  void operator=(const vtkTransformConcatenation&) = delete;
477 };
478 
479 // .NAME vtkTransformConcatenationStack - Store a stack of concatenations.
480 // .SECTION Description
481 // A helper class (not derived from vtkObject) to store a stack of
482 // concatenations.
483 class VTKCOMMONTRANSFORMS_EXPORT vtkTransformConcatenationStack
484 {
485 public:
487  void Delete() { delete this; }
488 
493  void Pop(vtkTransformConcatenation** concat);
494 
499  void Push(vtkTransformConcatenation** concat);
500 
501  void DeepCopy(vtkTransformConcatenationStack* stack);
502 
503 protected:
506 
510 
511 private:
513  void operator=(const vtkTransformConcatenationStack&) = delete;
514 };
515 
516 VTK_ABI_NAMESPACE_END
517 #endif
static vtkTransformConcatenation * New()
void TransformPoint(const float in[3], float out[3])
Apply the transformation to a coordinate.
vtkAbstractTransform * PostMatrixTransform
double * TransformVectorAtPoint(const double point[3], const double vector[3])
abstract base class for most VTK objects
Definition: vtkObject.h:52
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:31
vtkAbstractTransform * InverseTransform
int GetNumberOfPreTransforms()
the number of transforms that were pre-concatenated (note that whenever Inverse() is called...
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTransformConcatenation ** StackBottom
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
int GetNumberOfPostTransforms()
the number of transforms that were post-concatenated.
float * TransformFloatNormalAtPoint(const float point[3], const float normal[3])
Apply the transformation to a single-precision normal at the specified vertex.
double * TransformPoint(double x, double y, double z)
Apply the transformation to a double-precision coordinate.
float * TransformFloatPoint(const float point[3])
Apply the transformation to an (x,y,z) coordinate.
double * TransformPoint(const double point[3])
vtkAbstractTransform * ForwardTransform
vtkTypeBool GetPreMultiplyFlag()
set/get the PreMultiply flag
int vtkTypeBool
Definition: vtkABI.h:64
virtual void InternalDeepCopy(vtkAbstractTransform *)
Perform any subclass-specific DeepCopy.
vtkAbstractTransform * PreMatrixTransform
void SetPreMultiplyFlag(vtkTypeBool flag)
set/get the PreMultiply flag
vtkTypeBool GetInverseFlag()
get the inverse flag
a simple class to control print indentation
Definition: vtkIndent.h:28
vtkTransformPair()=default
double * TransformDoublePoint(double x, double y, double z)
Apply the transformation to a double-precision (x,y,z) coordinate.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
superclass for all geometric transformations
double * TransformDoublePoint(const double point[3])
Apply the transformation to a double-precision (x,y,z) coordinate.
float * TransformFloatVectorAtPoint(const float point[3], const float vector[3])
Apply the transformation to a single-precision vector at the specified vertex.
abstract base class for most VTK objects
Definition: vtkObjectBase.h:68
#define VTK_SIZEHINT(...)
#define VTK_NEWINSTANCE
#define VTK_MARSHALEXCLUDE(reason)
vtkTransformPair * TransformList
double * TransformDoubleVectorAtPoint(const double point[3], const double vector[3])
Apply the transformation to a double-precision vector at the specified vertex.
int GetNumberOfTransforms()
the number of stored transforms
double * TransformDoubleNormalAtPoint(const double point[3], const double normal[3])
Apply the transformation to a double-precision normal at the specified vertex.
#define VTK_MARSHALAUTO
double * TransformNormalAtPoint(const double point[3], const double normal[3])
vtkTransformConcatenation ** Stack
float * TransformFloatPoint(float x, float y, float z)
Apply the transformation to an (x,y,z) coordinate.
static vtkTransformConcatenationStack * New()
represent and manipulate 3D points
Definition: vtkPoints.h:30
void TransformPoint(const double in[3], double out[3])
Apply the transformation to a double-precision coordinate.
#define VTK_MARSHAL_EXCLUDE_REASON_IS_INTERNAL