VTK  9.3.20240424
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
299 void UnRegister(vtkObjectBase* O) override;
300
301protected:
304
308 virtual void InternalUpdate() {}
309
314
315 float InternalFloatPoint[3];
316 double InternalDoublePoint[3];
317
318private:
319 class vtkInternals;
320
321 vtkInternals* Internals;
322
324 void operator=(const vtkAbstractTransform&) = delete;
325};
326
327//-------------------------------------------------------------------------
328// A simple data structure to hold both a transform and its inverse.
329// One of ForwardTransform or InverseTransform might be nullptr,
330// and must be acquired by calling GetInverse() on the other.
332{
333public:
334 vtkTransformPair() = default;
335
338
340 {
342 this->ForwardTransform = this->InverseTransform;
343 this->InverseTransform = tmp;
344 }
345};
346
347// .NAME vtkTransformConcatenation - store a series of transformations.
348// .SECTION Description
349// A helper class (not derived from vtkObject) to store a series of
350// transformations in a pipelined concatenation.
351class VTKCOMMONTRANSFORMS_EXPORT vtkTransformConcatenation
352{
353public:
355 void Delete() { delete this; }
356
361
365 void Concatenate(const double elements[16]);
366
368
371 void SetPreMultiplyFlag(vtkTypeBool flag) { this->PreMultiplyFlag = flag; }
372 vtkTypeBool GetPreMultiplyFlag() { return this->PreMultiplyFlag; }
374
376
379 void Translate(double x, double y, double z);
380 void Rotate(double angle, double x, double y, double z);
381 void Scale(double x, double y, double z);
383
387 void Inverse();
388
392 vtkTypeBool GetInverseFlag() { return this->InverseFlag; }
393
397 void Identity();
398
399 // copy the list
401
405 int GetNumberOfTransforms() { return this->NumberOfTransforms; }
406
412 int GetNumberOfPreTransforms() { return this->NumberOfPreTransforms; }
413
417 int GetNumberOfPostTransforms() { return this->NumberOfTransforms - this->NumberOfPreTransforms; }
418
423
428
429 void PrintSelf(ostream& os, vtkIndent indent);
430
431protected:
434
437
442
447
448private:
450 void operator=(const vtkTransformConcatenation&) = delete;
451};
452
453// .NAME vtkTransformConcatenationStack - Store a stack of concatenations.
454// .SECTION Description
455// A helper class (not derived from vtkObject) to store a stack of
456// concatenations.
457class VTKCOMMONTRANSFORMS_EXPORT vtkTransformConcatenationStack
458{
459public:
461 void Delete() { delete this; }
462
468
474
476
477protected:
480
484
485private:
487 void operator=(const vtkTransformConcatenationStack&) = delete;
488};
489
490VTK_ABI_NAMESPACE_END
491#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