VTK  9.3.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 
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 
223  vtkAbstractTransform* GetInverse();
224 
230  void SetInverse(vtkAbstractTransform* transform);
231 
235  virtual void Inverse() = 0;
236 
240  void DeepCopy(vtkAbstractTransform*);
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 
266  virtual void InternalTransformDerivative(
267  const float in[3], float out[3], float derivative[3][3]) = 0;
268  virtual void InternalTransformDerivative(
269  const double in[3], double out[3], double derivative[3][3]) = 0;
271 
275  virtual VTK_NEWINSTANCE vtkAbstractTransform* MakeTransform() = 0;
276 
285  virtual int CircuitCheck(vtkAbstractTransform* transform);
286 
290  vtkMTimeType GetMTime() override;
291 
296  void UnRegister(vtkObjectBase* O) override;
297 
298 protected:
300  ~vtkAbstractTransform() override;
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 
357  void Concatenate(vtkAbstractTransform* transform);
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
397  void DeepCopy(vtkTransformConcatenation* transform);
398 
402  int GetNumberOfTransforms() { return this->NumberOfTransforms; }
403 
409  int GetNumberOfPreTransforms() { return this->NumberOfPreTransforms; }
410 
414  int GetNumberOfPostTransforms() { return this->NumberOfTransforms - this->NumberOfPreTransforms; }
415 
419  vtkAbstractTransform* GetTransform(int i);
420 
424  vtkMTimeType GetMaxMTime();
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 
464  void Pop(vtkTransformConcatenation** concat);
465 
470  void Push(vtkTransformConcatenation** concat);
471 
472  void DeepCopy(vtkTransformConcatenationStack* stack);
473 
474 protected:
477 
481 
482 private:
484  void operator=(const vtkTransformConcatenationStack&) = delete;
485 };
486 
487 VTK_ABI_NAMESPACE_END
488 #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:51
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:30
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:270
int GetNumberOfPostTransforms()
the number of transforms that were post-concatenated.
virtual void InternalUpdate()
Perform any subclass-specific Update.
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
virtual void UnRegister(vtkObjectBase *o)
Decrease the reference count (release by another object).
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
virtual vtkMTimeType GetMTime()
Return this object's modified time.
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:62
#define VTK_SIZEHINT(...)
#define VTK_NEWINSTANCE
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.
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:28
void TransformPoint(const double in[3], double out[3])
Apply the transformation to a double-precision coordinate.