VTK  9.4.20241114
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
34VTK_ABI_NAMESPACE_BEGIN
35class vtkDataArray;
36class vtkMatrix4x4;
37class vtkPoints;
38
39class VTKCOMMONTRANSFORMS_EXPORT VTK_MARSHALAUTO vtkAbstractTransform : public vtkObject
40{
41public:
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
213 vtkDataArray* inNms, vtkDataArray* outNms, vtkDataArray* inVrs, vtkDataArray* outVrs,
214 int nOptionalVectors = 0, vtkDataArray** inVrsArr = nullptr,
215 vtkDataArray** outVrsArr = nullptr);
216
225 vtkAbstractTransform* GetInverse();
226
233 void SetInverse(vtkAbstractTransform* transform);
234
238 virtual void Inverse() = 0;
239
243 void DeepCopy(vtkAbstractTransform*);
244
251 void Update();
252
254
258 virtual void InternalTransformPoint(const float in[3], float out[3]) = 0;
259 virtual void InternalTransformPoint(const double in[3], double out[3]) = 0;
261
263
269 virtual void InternalTransformDerivative(
270 const float in[3], float out[3], float derivative[3][3]) = 0;
271 virtual void InternalTransformDerivative(
272 const double in[3], double out[3], double derivative[3][3]) = 0;
274
278 virtual VTK_NEWINSTANCE vtkAbstractTransform* MakeTransform() = 0;
279
288 virtual int CircuitCheck(vtkAbstractTransform* transform);
289
293 vtkMTimeType GetMTime() override;
294
298 void Modified() override;
299
304 void UnRegister(vtkObjectBase* O) override;
305
306protected:
309
313 virtual void InternalUpdate() {}
314
319
320 float InternalFloatPoint[3];
321 double InternalDoublePoint[3];
322
323private:
324 class vtkInternals;
325
326 vtkInternals* Internals;
327
329 void operator=(const vtkAbstractTransform&) = delete;
330};
331
332//-------------------------------------------------------------------------
333// A simple data structure to hold both a transform and its inverse.
334// One of ForwardTransform or InverseTransform might be nullptr,
335// and must be acquired by calling GetInverse() on the other.
337{
338public:
339 vtkTransformPair() = default;
340
343
345 {
347 this->ForwardTransform = this->InverseTransform;
348 this->InverseTransform = tmp;
349 }
350};
351
352// .NAME vtkTransformConcatenation - store a series of transformations.
353// .SECTION Description
354// A helper class (not derived from vtkObject) to store a series of
355// transformations in a pipelined concatenation.
356class VTKCOMMONTRANSFORMS_EXPORT vtkTransformConcatenation
357{
358public:
360 void Delete() { delete this; }
361
366
370 void Concatenate(const double elements[16]);
371
373
376 void SetPreMultiplyFlag(vtkTypeBool flag) { this->PreMultiplyFlag = flag; }
377 vtkTypeBool GetPreMultiplyFlag() { return this->PreMultiplyFlag; }
379
381
384 void Translate(double x, double y, double z);
385 void Rotate(double angle, double x, double y, double z);
386 void Scale(double x, double y, double z);
388
392 void Inverse();
393
397 vtkTypeBool GetInverseFlag() { return this->InverseFlag; }
398
402 void Identity();
403
404 // copy the list
406
410 int GetNumberOfTransforms() { return this->NumberOfTransforms; }
411
417 int GetNumberOfPreTransforms() { return this->NumberOfPreTransforms; }
418
422 int GetNumberOfPostTransforms() { return this->NumberOfTransforms - this->NumberOfPreTransforms; }
423
428
433
434 void PrintSelf(ostream& os, vtkIndent indent);
435
436protected:
439
442
447
452
453private:
455 void operator=(const vtkTransformConcatenation&) = delete;
456};
457
458// .NAME vtkTransformConcatenationStack - Store a stack of concatenations.
459// .SECTION Description
460// A helper class (not derived from vtkObject) to store a stack of
461// concatenations.
462class VTKCOMMONTRANSFORMS_EXPORT vtkTransformConcatenationStack
463{
464public:
466 void Delete() { delete this; }
467
473
479
481
482protected:
485
489
490private:
492 void operator=(const vtkTransformConcatenationStack&) = delete;
493};
494
495VTK_ABI_NAMESPACE_END
496#endif
superclass for all geometric transformations
void TransformPoint(const float in[3], float out[3])
Apply the transformation to a coordinate.
void TransformNormalAtPoint(const float point[3], const float in[3], float out[3])
Apply the transformation to a normal at the specified vertex.
void TransformVectorAtPoint(const float point[3], const float in[3], float out[3])
Apply the transformation to a 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 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.
double * TransformDoublePoint(double x, double y, double z)
Apply the transformation to a double-precision (x,y,z) coordinate.
double * TransformDoubleVectorAtPoint(const double point[3], const double vector[3])
Apply the transformation to a double-precision vector at the specified vertex.
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.
double * TransformPoint(double x, double y, double z)
Apply the transformation to a double-precision coordinate.
double * TransformPoint(const double point[3])
double * TransformDoublePoint(const double point[3])
Apply the transformation to a double-precision (x,y,z) coordinate.
void TransformPoint(const double in[3], double out[3])
Apply the transformation to a double-precision coordinate.
double * TransformVectorAtPoint(const double point[3], const double vector[3])
float * TransformFloatPoint(const float point[3])
Apply the transformation to an (x,y,z) coordinate.
void TransformNormalAtPoint(const double point[3], const double in[3], double out[3])
Apply the transformation to a normal at the specified vertex.
float * TransformFloatPoint(float x, float y, float z)
Apply the transformation to an (x,y,z) coordinate.
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.
float * TransformFloatNormalAtPoint(const float point[3], const float normal[3])
Apply the transformation to a single-precision 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 * TransformNormalAtPoint(const double point[3], const double normal[3])
abstract superclass for arrays of numeric data
a simple class to control print indentation
Definition vtkIndent.h:108
represent and manipulate 4x4 transformation matrices
abstract base class for most VTK objects
abstract base class for most VTK objects
Definition vtkObject.h:162
represent and manipulate 3D points
Definition vtkPoints.h:139
void Push(vtkTransformConcatenation **concat)
push will move 'concat' onto the stack, and make 'concat' a copy of its previous self
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)
static vtkTransformConcatenationStack * New()
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
vtkAbstractTransform * GetTransform(int i)
get one of the transforms
void Inverse()
invert the concatenation
void SetPreMultiplyFlag(vtkTypeBool flag)
set/get the PreMultiply flag
int GetNumberOfPostTransforms()
the number of transforms that were post-concatenated.
vtkMTimeType GetMaxMTime()
get maximum MTime of all transforms
vtkAbstractTransform * PreMatrixTransform
static vtkTransformConcatenation * New()
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
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
int vtkTypeBool
Definition vtkABI.h:64
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:270
#define VTK_SIZEHINT(...)
#define VTK_MARSHAL_EXCLUDE_REASON_IS_INTERNAL
#define VTK_MARSHALAUTO
#define VTK_MARSHALEXCLUDE(reason)
#define VTK_NEWINSTANCE