VTK: Common/Transforms/vtkAbstractTransform.h Source File

| 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:
41 vtkTypeMacro(vtkAbstractTransform, vtkObject);
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:
299 vtkAbstractTransform();
300 ~vtkAbstractTransform() override;
301
305 virtual void InternalUpdate() {}
306
310 virtual void InternalDeepCopy(vtkAbstractTransform*) {}
311
312 float InternalFloatPoint[3];
313 double InternalDoublePoint[3];
314
315 private:
316 class vtkInternals;
317
318 vtkInternals* Internals;
319
320 vtkAbstractTransform(const vtkAbstractTransform&) = delete;
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.
328 class vtkTransformPair
329 {
330 public:
331 vtkTransformPair() = default;
332
333 vtkAbstractTransform* ForwardTransform;
334 vtkAbstractTransform* InverseTransform;
335
336 void SwapForwardInverse()
337 {
338 vtkAbstractTransform* tmp = this->ForwardTransform;
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:
351 static vtkTransformConcatenation* New() { return new vtkTransformConcatenation(); }
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:
429 vtkTransformConcatenation();
430 ~vtkTransformConcatenation();
431
432 vtkTypeBool InverseFlag;
433 vtkTypeBool PreMultiplyFlag;
434
435 vtkMatrix4x4* PreMatrix;
436 vtkMatrix4x4* PostMatrix;
437 vtkAbstractTransform* PreMatrixTransform;
438 vtkAbstractTransform* PostMatrixTransform;
439
440 int NumberOfTransforms;
441 int NumberOfPreTransforms;
442 int MaxNumberOfTransforms;
443 vtkTransformPair* TransformList;
444
445 private:
446 vtkTransformConcatenation(const vtkTransformConcatenation&) = delete;
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:
457 static vtkTransformConcatenationStack* New() { return new vtkTransformConcatenationStack(); }
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:
475 vtkTransformConcatenationStack();
476 ~vtkTransformConcatenationStack();
477
478 int StackSize;
479 vtkTransformConcatenation** Stack;
480 vtkTransformConcatenation** StackBottom;
481
482 private:
483 vtkTransformConcatenationStack(const vtkTransformConcatenationStack&) = delete;
484 void operator=(const vtkTransformConcatenationStack&) = delete;
485 };
486
487 VTK_ABI_NAMESPACE_END
488 #endif
vtkAbstractTransform
superclass for all geometric transformations
Definition: vtkAbstractTransform.h:39
vtkAbstractTransform::TransformPoint
double * TransformPoint(const double point[3])
Definition: vtkAbstractTransform.h:72
vtkAbstractTransform::TransformDoublePoint
double * TransformDoublePoint(double x, double y, double z)
Apply the transformation to a double-precision (x,y,z) coordinate.
Definition: vtkAbstractTransform.h:101
vtkAbstractTransform::TransformPoint
void TransformPoint(const float in[3], float out[3])
Apply the transformation to a coordinate.
Definition: vtkAbstractTransform.h:48
vtkAbstractTransform::InternalTransformPoint
virtual void InternalTransformPoint(const float in[3], float out[3])=0
This will calculate the transformation without calling Update.
vtkAbstractTransform::TransformNormalAtPoint
void TransformNormalAtPoint(const float point[3], const float in[3], float out[3])
Apply the transformation to a normal at the specified vertex.
vtkAbstractTransform::TransformFloatPoint
float * TransformFloatPoint(const float point[3])
Apply the transformation to an (x,y,z) coordinate.
Definition: vtkAbstractTransform.h:90
vtkAbstractTransform::TransformDoublePoint
double * TransformDoublePoint(const double point[3])
Apply the transformation to a double-precision (x,y,z) coordinate.
Definition: vtkAbstractTransform.h:109
vtkAbstractTransform::TransformVectorAtPoint
void TransformVectorAtPoint(const float point[3], const float in[3], float out[3])
Apply the transformation to a vector at the specified vertex.
vtkAbstractTransform::CircuitCheck
virtual int CircuitCheck(vtkAbstractTransform *transform)
Check for self-reference.
vtkAbstractTransform::TransformVectorAtPoint
double * TransformVectorAtPoint(const double point[3], const double vector[3])
Definition: vtkAbstractTransform.h:168
vtkAbstractTransform::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkAbstractTransform::TransformPoints
virtual void TransformPoints(vtkPoints *inPts, vtkPoints *outPts)
Apply the transformation to a series of points, and append the results to outPts.
vtkAbstractTransform::InternalTransformPoint
virtual void InternalTransformPoint(const double in[3], double out[3])=0
This will calculate the transformation without calling Update.
vtkAbstractTransform::TransformFloatPoint
float * TransformFloatPoint(float x, float y, float z)
Apply the transformation to an (x,y,z) coordinate.
Definition: vtkAbstractTransform.h:82
vtkAbstractTransform::vtkAbstractTransform
vtkAbstractTransform()
vtkAbstractTransform::UnRegister
void UnRegister(vtkObjectBase *O) override
Needs a special UnRegister() implementation to avoid circular references.
vtkAbstractTransform::Update
void Update()
Update the transform to account for any changes which have been made.
vtkAbstractTransform::GetInverse
vtkAbstractTransform * GetInverse()
Get the inverse of this transform.
vtkAbstractTransform::TransformFloatNormalAtPoint
float * TransformFloatNormalAtPoint(const float point[3], const float normal[3])
Apply the transformation to a single-precision normal at the specified vertex.
Definition: vtkAbstractTransform.h:151
vtkAbstractTransform::InternalTransformDerivative
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 ...
vtkAbstractTransform::InternalDeepCopy
virtual void InternalDeepCopy(vtkAbstractTransform *)
Perform any subclass-specific DeepCopy.
Definition: vtkAbstractTransform.h:310
vtkAbstractTransform::TransformVectorAtPoint
void TransformVectorAtPoint(const double point[3], const double in[3], double out[3])
Apply the transformation to a vector at the specified vertex.
vtkAbstractTransform::SetInverse
void SetInverse(vtkAbstractTransform *transform)
Set a transformation that this transform will be the inverse of.
vtkAbstractTransform::Inverse
virtual void Inverse()=0
Invert the transformation.
vtkAbstractTransform::~vtkAbstractTransform
~vtkAbstractTransform() override
vtkAbstractTransform::InternalTransformDerivative
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 ...
vtkAbstractTransform::TransformDoubleVectorAtPoint
double * TransformDoubleVectorAtPoint(const double point[3], const double vector[3])
Apply the transformation to a double-precision vector at the specified vertex.
Definition: vtkAbstractTransform.h:180
vtkAbstractTransform::TransformFloatVectorAtPoint
float * TransformFloatVectorAtPoint(const float point[3], const float vector[3])
Apply the transformation to a single-precision vector at the specified vertex.
Definition: vtkAbstractTransform.h:194
vtkAbstractTransform::TransformPoint
void TransformPoint(const double in[3], double out[3])
Apply the transformation to a double-precision coordinate.
Definition: vtkAbstractTransform.h:58
vtkAbstractTransform::TransformNormalAtPoint
void TransformNormalAtPoint(const double point[3], const double in[3], double out[3])
Apply the transformation to a normal at the specified vertex.
vtkAbstractTransform::TransformDoubleNormalAtPoint
double * TransformDoubleNormalAtPoint(const double point[3], const double normal[3])
Apply the transformation to a double-precision normal at the specified vertex.
Definition: vtkAbstractTransform.h:137
vtkAbstractTransform::TransformPoint
double * TransformPoint(double x, double y, double z)
Apply the transformation to a double-precision coordinate.
Definition: vtkAbstractTransform.h:68
vtkAbstractTransform::DeepCopy
void DeepCopy(vtkAbstractTransform *)
Copy this transform from another of the same type.
vtkAbstractTransform::InternalUpdate
virtual void InternalUpdate()
Perform any subclass-specific Update.
Definition: vtkAbstractTransform.h:305
vtkAbstractTransform::GetMTime
vtkMTimeType GetMTime() override
Override GetMTime necessary because of inverse transforms.
vtkAbstractTransform::TransformPointsNormalsVectors
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.
vtkAbstractTransform::TransformNormalAtPoint
double * TransformNormalAtPoint(const double point[3], const double normal[3])
Definition: vtkAbstractTransform.h:125
vtkAbstractTransform::MakeTransform
virtual vtkAbstractTransform * MakeTransform()=0
Make another transform of the same type.
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:40
vtkObjectBase
abstract base class for most VTK objects
Definition: vtkObjectBase.h:72
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:61
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:38
vtkTransformConcatenationStack
Definition: vtkAbstractTransform.h:455
vtkTransformConcatenationStack::Push
void Push(vtkTransformConcatenation **concat)
push will move 'concat' onto the stack, and make 'concat' a copy of its previous self
vtkTransformConcatenationStack::New
static vtkTransformConcatenationStack * New()
Definition: vtkAbstractTransform.h:457
vtkTransformConcatenationStack::Stack
vtkTransformConcatenation ** Stack
Definition: vtkAbstractTransform.h:479
vtkTransformConcatenationStack::Delete
void Delete()
Definition: vtkAbstractTransform.h:458
vtkTransformConcatenationStack::vtkTransformConcatenationStack
vtkTransformConcatenationStack()
vtkTransformConcatenationStack::~vtkTransformConcatenationStack
~vtkTransformConcatenationStack()
vtkTransformConcatenationStack::Pop
void Pop(vtkTransformConcatenation **concat)
pop will pop delete 'concat', then pop the top item on the stack onto 'concat'.
vtkTransformConcatenationStack::StackSize
int StackSize
Definition: vtkAbstractTransform.h:478
vtkTransformConcatenationStack::StackBottom
vtkTransformConcatenation ** StackBottom
Definition: vtkAbstractTransform.h:480
vtkTransformConcatenationStack::DeepCopy
void DeepCopy(vtkTransformConcatenationStack *stack)
vtkTransformConcatenation
Definition: vtkAbstractTransform.h:349
vtkTransformConcatenation::PreMatrix
vtkMatrix4x4 * PreMatrix
Definition: vtkAbstractTransform.h:435
vtkTransformConcatenation::GetInverseFlag
vtkTypeBool GetInverseFlag()
get the inverse flag
Definition: vtkAbstractTransform.h:389
vtkTransformConcatenation::GetNumberOfPreTransforms
int GetNumberOfPreTransforms()
the number of transforms that were pre-concatenated (note that whenever Inverse() is called,...
Definition: vtkAbstractTransform.h:409
vtkTransformConcatenation::~vtkTransformConcatenation
~vtkTransformConcatenation()
vtkTransformConcatenation::DeepCopy
void DeepCopy(vtkTransformConcatenation *transform)
vtkTransformConcatenation::Concatenate
void Concatenate(vtkAbstractTransform *transform)
add a transform to the list according to Pre/PostMultiply semantics
vtkTransformConcatenation::Identity
void Identity()
identity simply clears the transform list
vtkTransformConcatenation::PreMultiplyFlag
vtkTypeBool PreMultiplyFlag
Definition: vtkAbstractTransform.h:433
vtkTransformConcatenation::GetNumberOfTransforms
int GetNumberOfTransforms()
the number of stored transforms
Definition: vtkAbstractTransform.h:402
vtkTransformConcatenation::MaxNumberOfTransforms
int MaxNumberOfTransforms
Definition: vtkAbstractTransform.h:442
vtkTransformConcatenation::PostMatrix
vtkMatrix4x4 * PostMatrix
Definition: vtkAbstractTransform.h:436
vtkTransformConcatenation::Concatenate
void Concatenate(const double elements[16])
concatenate with a matrix according to Pre/PostMultiply semantics
vtkTransformConcatenation::vtkTransformConcatenation
vtkTransformConcatenation()
vtkTransformConcatenation::GetPreMultiplyFlag
vtkTypeBool GetPreMultiplyFlag()
set/get the PreMultiply flag
Definition: vtkAbstractTransform.h:369
vtkTransformConcatenation::InverseFlag
vtkTypeBool InverseFlag
Definition: vtkAbstractTransform.h:432
vtkTransformConcatenation::NumberOfPreTransforms
int NumberOfPreTransforms
Definition: vtkAbstractTransform.h:441
vtkTransformConcatenation::Inverse
void Inverse()
invert the concatenation
vtkTransformConcatenation::Delete
void Delete()
Definition: vtkAbstractTransform.h:352
vtkTransformConcatenation::SetPreMultiplyFlag
void SetPreMultiplyFlag(vtkTypeBool flag)
set/get the PreMultiply flag
Definition: vtkAbstractTransform.h:368
vtkTransformConcatenation::GetNumberOfPostTransforms
int GetNumberOfPostTransforms()
the number of transforms that were post-concatenated.
Definition: vtkAbstractTransform.h:414
vtkTransformConcatenation::TransformList
vtkTransformPair * TransformList
Definition: vtkAbstractTransform.h:443
vtkTransformConcatenation::GetMaxMTime
vtkMTimeType GetMaxMTime()
get maximum MTime of all transforms
vtkTransformConcatenation::GetTransform
vtkAbstractTransform * GetTransform(int i)
get one of the transforms
vtkTransformConcatenation::PreMatrixTransform
vtkAbstractTransform * PreMatrixTransform
Definition: vtkAbstractTransform.h:437
vtkTransformConcatenation::Translate
void Translate(double x, double y, double z)
the three basic linear transformations
vtkTransformConcatenation::Scale
void Scale(double x, double y, double z)
the three basic linear transformations
vtkTransformConcatenation::New
static vtkTransformConcatenation * New()
Definition: vtkAbstractTransform.h:351
vtkTransformConcatenation::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
vtkTransformConcatenation::PostMatrixTransform
vtkAbstractTransform * PostMatrixTransform
Definition: vtkAbstractTransform.h:438
vtkTransformConcatenation::Rotate
void Rotate(double angle, double x, double y, double z)
the three basic linear transformations
vtkTransformConcatenation::NumberOfTransforms
int NumberOfTransforms
Definition: vtkAbstractTransform.h:440
vtkTransformPair
Definition: vtkAbstractTransform.h:329
vtkTransformPair::vtkTransformPair
vtkTransformPair()=default
vtkTransformPair::ForwardTransform
vtkAbstractTransform * ForwardTransform
Definition: vtkAbstractTransform.h:333
vtkTransformPair::InverseTransform
vtkAbstractTransform * InverseTransform
Definition: vtkAbstractTransform.h:334
vtkTransformPair::SwapForwardInverse
void SwapForwardInverse()
Definition: vtkAbstractTransform.h:336
vtkX3D::point
@ point
Definition: vtkX3D.h:236
vtkX3D::vector
@ vector
Definition: vtkX3D.h:237
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:64
vtkObject.h
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:36
VTK_NEWINSTANCE
#define VTK_NEWINSTANCE
Definition: vtkWrappingHints.h:32