VTK  9.1.0
vtkAbstractTransform.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkAbstractTransform.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
39#ifndef vtkAbstractTransform_h
40#define vtkAbstractTransform_h
41
42#include "vtkCommonTransformsModule.h" // For export macro
43#include "vtkObject.h"
44
45#include <mutex> // for std::mutex
46
47class vtkDataArray;
48class vtkMatrix4x4;
49class vtkPoints;
50
51class VTKCOMMONTRANSFORMS_EXPORT vtkAbstractTransform : public vtkObject
52{
53public:
55 void PrintSelf(ostream& os, vtkIndent indent) override;
56
61 void TransformPoint(const float in[3], float out[3])
62 {
63 this->Update();
64 this->InternalTransformPoint(in, out);
65 }
66
71 void TransformPoint(const double in[3], double out[3])
72 {
73 this->Update();
74 this->InternalTransformPoint(in, out);
75 }
76
81 double* TransformPoint(double x, double y, double z) VTK_SIZEHINT(3)
82 {
83 return this->TransformDoublePoint(x, y, z);
84 }
85 double* TransformPoint(const double point[3]) VTK_SIZEHINT(3)
86 {
87 return this->TransformPoint(point[0], point[1], point[2]);
88 }
89
91
95 float* TransformFloatPoint(float x, float y, float z) VTK_SIZEHINT(3)
96 {
97 this->InternalFloatPoint[0] = x;
98 this->InternalFloatPoint[1] = y;
99 this->InternalFloatPoint[2] = z;
100 this->TransformPoint(this->InternalFloatPoint, this->InternalFloatPoint);
101 return this->InternalFloatPoint;
102 }
103 float* TransformFloatPoint(const float point[3]) VTK_SIZEHINT(3)
104 {
105 return this->TransformFloatPoint(point[0], point[1], point[2]);
106 }
108
110
114 double* TransformDoublePoint(double x, double y, double z) VTK_SIZEHINT(3)
115 {
116 this->InternalDoublePoint[0] = x;
117 this->InternalDoublePoint[1] = y;
118 this->InternalDoublePoint[2] = z;
119 this->TransformPoint(this->InternalDoublePoint, this->InternalDoublePoint);
120 return this->InternalDoublePoint;
121 }
122 double* TransformDoublePoint(const double point[3]) VTK_SIZEHINT(3)
123 {
124 return this->TransformDoublePoint(point[0], point[1], point[2]);
125 }
127
129
134 void TransformNormalAtPoint(const float point[3], const float in[3], float out[3]);
135 void TransformNormalAtPoint(const double point[3], const double in[3], double out[3]);
137
138 double* TransformNormalAtPoint(const double point[3], const double normal[3]) VTK_SIZEHINT(3)
139 {
140 this->TransformNormalAtPoint(point, normal, this->InternalDoublePoint);
141 return this->InternalDoublePoint;
142 }
143
145
150 double* TransformDoubleNormalAtPoint(const double point[3], const double normal[3])
151 VTK_SIZEHINT(3)
152 {
153 this->TransformNormalAtPoint(point, normal, this->InternalDoublePoint);
154 return this->InternalDoublePoint;
155 }
157
159
164 float* TransformFloatNormalAtPoint(const float point[3], const float normal[3]) VTK_SIZEHINT(3)
165 {
166 this->TransformNormalAtPoint(point, normal, this->InternalFloatPoint);
167 return this->InternalFloatPoint;
168 }
170
172
177 void TransformVectorAtPoint(const float point[3], const float in[3], float out[3]);
178 void TransformVectorAtPoint(const double point[3], const double in[3], double out[3]);
180
181 double* TransformVectorAtPoint(const double point[3], const double vector[3]) VTK_SIZEHINT(3)
182 {
183 this->TransformVectorAtPoint(point, vector, this->InternalDoublePoint);
184 return this->InternalDoublePoint;
185 }
186
188
193 double* TransformDoubleVectorAtPoint(const double point[3], const double vector[3])
194 VTK_SIZEHINT(3)
195 {
196 this->TransformVectorAtPoint(point, vector, this->InternalDoublePoint);
197 return this->InternalDoublePoint;
198 }
200
202
207 float* TransformFloatVectorAtPoint(const float point[3], const float vector[3]) VTK_SIZEHINT(3)
208 {
209 this->TransformVectorAtPoint(point, vector, this->InternalFloatPoint);
210 return this->InternalFloatPoint;
211 }
213
218 virtual void TransformPoints(vtkPoints* inPts, vtkPoints* outPts);
219
225 vtkDataArray* inNms, vtkDataArray* outNms, vtkDataArray* inVrs, vtkDataArray* outVrs,
226 int nOptionalVectors = 0, vtkDataArray** inVrsArr = nullptr,
227 vtkDataArray** outVrsArr = nullptr);
228
237
244
248 virtual void Inverse() = 0;
249
254
261 void Update();
262
264
268 virtual void InternalTransformPoint(const float in[3], float out[3]) = 0;
269 virtual void InternalTransformPoint(const double in[3], double out[3]) = 0;
271
273
280 const float in[3], float out[3], float derivative[3][3]) = 0;
282 const double in[3], double out[3], double derivative[3][3]) = 0;
284
289
298 virtual int CircuitCheck(vtkAbstractTransform* transform);
299
304
309 void UnRegister(vtkObjectBase* O) override;
310
311protected:
314
318 virtual void InternalUpdate() {}
319
324
325 float InternalFloatPoint[3];
326 double InternalDoublePoint[3];
327
328private:
329 // We need to record the time of the last update, and we also need
330 // to do mutex locking so updates don't collide. These are private
331 // because Update() is not virtual.
332 // If DependsOnInverse is set, then this transform object will
333 // check its inverse on every update, and update itself accordingly
334 // if necessary.
335
336 vtkTimeStamp UpdateTime;
337 std::mutex UpdateMutex;
338 std::mutex InverseMutex;
339 int DependsOnInverse;
340
341 // MyInverse is a transform which is the inverse of this one.
342
343 vtkAbstractTransform* MyInverse;
344
345 int InUnRegister;
346
347private:
349 void operator=(const vtkAbstractTransform&) = delete;
350};
351
352//-------------------------------------------------------------------------
353// A simple data structure to hold both a transform and its inverse.
354// One of ForwardTransform or InverseTransform might be nullptr,
355// and must be acquired by calling GetInverse() on the other.
357{
358public:
359 vtkTransformPair() = default;
360
363
365 {
367 this->ForwardTransform = this->InverseTransform;
368 this->InverseTransform = tmp;
369 }
370};
371
372// .NAME vtkTransformConcatenation - store a series of transformations.
373// .SECTION Description
374// A helper class (not derived from vtkObject) to store a series of
375// transformations in a pipelined concatenation.
376class VTKCOMMONTRANSFORMS_EXPORT vtkTransformConcatenation
377{
378public:
380 void Delete() { delete this; }
381
386
390 void Concatenate(const double elements[16]);
391
393
396 void SetPreMultiplyFlag(int flag) { this->PreMultiplyFlag = flag; }
397 int GetPreMultiplyFlag() { return this->PreMultiplyFlag; }
399
401
404 void Translate(double x, double y, double z);
405 void Rotate(double angle, double x, double y, double z);
406 void Scale(double x, double y, double z);
408
412 void Inverse();
413
417 int GetInverseFlag() { return this->InverseFlag; }
418
422 void Identity();
423
424 // copy the list
426
430 int GetNumberOfTransforms() { return this->NumberOfTransforms; }
431
437 int GetNumberOfPreTransforms() { return this->NumberOfPreTransforms; }
438
442 int GetNumberOfPostTransforms() { return this->NumberOfTransforms - this->NumberOfPreTransforms; }
443
448
453
454 void PrintSelf(ostream& os, vtkIndent indent);
455
456protected:
459
462
467
472
473private:
475 void operator=(const vtkTransformConcatenation&) = delete;
476};
477
478// .NAME vtkTransformConcatenationStack - Store a stack of concatenations.
479// .SECTION Description
480// A helper class (not derived from vtkObject) to store a stack of
481// concatenations.
482class VTKCOMMONTRANSFORMS_EXPORT vtkTransformConcatenationStack
483{
484public:
486 void Delete() { delete this; }
487
493
499
501
502protected:
505
509
510private:
512 void operator=(const vtkTransformConcatenationStack&) = delete;
513};
514
515#endif
superclass for all geometric transformations
void TransformPoint(const float in[3], float out[3])
Apply the transformation to a coordinate.
virtual void InternalTransformPoint(const float in[3], float out[3])=0
This will calculate the transformation without calling Update.
void TransformNormalAtPoint(const float point[3], const float in[3], float out[3])
Apply the transformation to a normal at the specified vertex.
virtual vtkAbstractTransform * MakeTransform()=0
Make another transform of the same type.
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.
virtual int CircuitCheck(vtkAbstractTransform *transform)
Check for self-reference.
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.
virtual void InternalTransformPoint(const double in[3], double out[3])=0
This will calculate the transformation without calling Update.
void UnRegister(vtkObjectBase *O) override
Needs a special UnRegister() implementation to avoid circular references.
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.
void Update()
Update the transform to account for any changes which have been made.
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 ...
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.
void SetInverse(vtkAbstractTransform *transform)
Set a transformation that this transform will be the inverse of.
virtual void Inverse()=0
Invert the transformation.
~vtkAbstractTransform() override
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 ...
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])
vtkAbstractTransform * GetInverse()
Get the inverse of this transform.
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.
void DeepCopy(vtkAbstractTransform *)
Copy this transform from another of the same type.
virtual void InternalUpdate()
Perform any subclass-specific Update.
vtkMTimeType GetMTime() override
Override GetMTime necessary because of inverse transforms.
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
Definition: vtkDataArray.h:159
a simple class to control print indentation
Definition: vtkIndent.h:113
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:145
abstract base class for most VTK objects
Definition: vtkObjectBase.h:70
abstract base class for most VTK objects
Definition: vtkObject.h:82
represent and manipulate 3D points
Definition: vtkPoints.h:143
record modification and/or execution time
Definition: vtkTimeStamp.h:52
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()
int GetNumberOfPreTransforms()
the number of transforms that were pre-concatenated (note that whenever Inverse() is called,...
void DeepCopy(vtkTransformConcatenation *transform)
void SetPreMultiplyFlag(int flag)
set/get the PreMultiply flag
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
int GetPreMultiplyFlag()
set/get the PreMultiply flag
vtkAbstractTransform * GetTransform(int i)
get one of the transforms
void Inverse()
invert the concatenation
int GetNumberOfPostTransforms()
the number of transforms that were post-concatenated.
vtkTransformPair * TransformList
vtkMTimeType GetMaxMTime()
get maximum MTime of all transforms
int GetInverseFlag()
get the inverse flag
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
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
#define VTK_SIZEHINT(...)
#define VTK_NEWINSTANCE