VTK
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
45class vtkDataArray;
46class vtkMatrix4x4;
47class vtkPoints;
49
50class VTKCOMMONTRANSFORMS_EXPORT vtkAbstractTransform : public vtkObject
51{
52public:
53
55 void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
56
61 void TransformPoint(const float in[3], float out[3]) {
62 this->Update(); this->InternalTransformPoint(in,out); };
63
68 void TransformPoint(const double in[3], double out[3]) {
69 this->Update(); this->InternalTransformPoint(in,out); };
70
75 double *TransformPoint(double x, double y, double z) {
76 return this->TransformDoublePoint(x,y,z); }
77 double *TransformPoint(const double point[3]) {
78 return this->TransformPoint(point[0],point[1],point[2]); };
79
81
85 float *TransformFloatPoint(float x, float y, float z) {
86 this->InternalFloatPoint[0] = x;
87 this->InternalFloatPoint[1] = y;
88 this->InternalFloatPoint[2] = z;
89 this->TransformPoint(this->InternalFloatPoint,this->InternalFloatPoint);
90 return this->InternalFloatPoint; };
91 float *TransformFloatPoint(const float point[3]) {
92 return this->TransformFloatPoint(point[0],point[1],point[2]); };
94
96
100 double *TransformDoublePoint(double x, double y, double z) {
101 this->InternalDoublePoint[0] = x;
102 this->InternalDoublePoint[1] = y;
103 this->InternalDoublePoint[2] = z;
104 this->TransformPoint(this->InternalDoublePoint,this->InternalDoublePoint);
105 return this->InternalDoublePoint; };
106 double *TransformDoublePoint(const double point[3]) {
107 return this->TransformDoublePoint(point[0],point[1],point[2]); };
109
111
116 void TransformNormalAtPoint(const float point[3], const float in[3],
117 float out[3]);
118 void TransformNormalAtPoint(const double point[3], const double in[3],
119 double out[3]);
121
122 double *TransformNormalAtPoint(const double point[3],
123 const double normal[3]) {
124 this->TransformNormalAtPoint(point,normal,this->InternalDoublePoint);
125 return this->InternalDoublePoint; };
126
128
133 double *TransformDoubleNormalAtPoint(const double point[3],
134 const double normal[3]) {
135 this->TransformNormalAtPoint(point,normal,this->InternalDoublePoint);
136 return this->InternalDoublePoint; };
138
140
145 float *TransformFloatNormalAtPoint(const float point[3],
146 const float normal[3]) {
147 this->TransformNormalAtPoint(point,normal,this->InternalFloatPoint);
148 return this->InternalFloatPoint; };
150
152
157 void TransformVectorAtPoint(const float point[3], const float in[3],
158 float out[3]);
159 void TransformVectorAtPoint(const double point[3], const double in[3],
160 double out[3]);
162
163 double *TransformVectorAtPoint(const double point[3],
164 const double vector[3]) {
165 this->TransformVectorAtPoint(point,vector,this->InternalDoublePoint);
166 return this->InternalDoublePoint; };
167
169
174 double *TransformDoubleVectorAtPoint(const double point[3],
175 const double vector[3]) {
176 this->TransformVectorAtPoint(point,vector,this->InternalDoublePoint);
177 return this->InternalDoublePoint; };
179
181
186 float *TransformFloatVectorAtPoint(const float point[3],
187 const float vector[3]) {
188 this->TransformVectorAtPoint(point,vector,this->InternalFloatPoint);
189 return this->InternalFloatPoint; };
191
196 virtual void TransformPoints(vtkPoints *inPts, vtkPoints *outPts);
197
203 vtkPoints *outPts,
204 vtkDataArray *inNms,
205 vtkDataArray *outNms,
206 vtkDataArray *inVrs,
207 vtkDataArray *outVrs);
208
217
224
228 virtual void Inverse() = 0;
229
234
241 void Update();
242
244
248 virtual void InternalTransformPoint(const float in[3], float out[3]) = 0;
249 virtual void InternalTransformPoint(const double in[3], double out[3]) = 0;
251
253
259 virtual void InternalTransformDerivative(const float in[3], float out[3],
260 float derivative[3][3]) = 0;
261 virtual void InternalTransformDerivative(const double in[3], double out[3],
262 double derivative[3][3]) = 0;
264
269
278 virtual int CircuitCheck(vtkAbstractTransform *transform);
279
283 vtkMTimeType GetMTime() VTK_OVERRIDE;
284
289 void UnRegister(vtkObjectBase *O) VTK_OVERRIDE;
290
291protected:
293 ~vtkAbstractTransform() VTK_OVERRIDE;
294
298 virtual void InternalUpdate() {}
299
304
305 float InternalFloatPoint[3];
306 double InternalDoublePoint[3];
307
308private:
309
310 // We need to record the time of the last update, and we also need
311 // to do mutex locking so updates don't collide. These are private
312 // because Update() is not virtual.
313 // If DependsOnInverse is set, then this transform object will
314 // check its inverse on every update, and update itself accordingly
315 // if necessary.
316
317 vtkTimeStamp UpdateTime;
318 vtkSimpleCriticalSection *UpdateMutex;
319 vtkSimpleCriticalSection *InverseMutex;
320 int DependsOnInverse;
321
322 // MyInverse is a transform which is the inverse of this one.
323
324 vtkAbstractTransform *MyInverse;
325
326 int InUnRegister;
327
328private:
329 vtkAbstractTransform(const vtkAbstractTransform&) VTK_DELETE_FUNCTION;
330 void operator=(const vtkAbstractTransform&) VTK_DELETE_FUNCTION;
331};
332
333//-------------------------------------------------------------------------
334// A simple data structure to hold both a transform and its inverse.
335// One of ForwardTransform or InverseTransform might be NULL,
336// and must be acquired by calling GetInverse() on the other.
338{
339public:
341
344
347 this->ForwardTransform = this->InverseTransform;
348 this->InverseTransform = tmp; };
349};
350
351// .NAME vtkTransformConcatenation - store a series of transformations.
352// .SECTION Description
353// A helper class (not derived from vtkObject) to store a series of
354// transformations in a pipelined concatenation.
355class VTKCOMMONTRANSFORMS_EXPORT vtkTransformConcatenation
356{
357public:
359 return new vtkTransformConcatenation(); };
360 void Delete() { delete this; };
361
366
370 void Concatenate(const double elements[16]);
371
373
376 void SetPreMultiplyFlag(int flag) { this->PreMultiplyFlag = flag; };
377 int 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 int 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
423 return this->NumberOfTransforms-this->NumberOfPreTransforms; };
424
429
434
435 void PrintSelf(ostream& os, vtkIndent indent);
436
437protected:
440
443
448
453};
454
455// .NAME vtkTransformConcatenationStack - Store a stack of concatenations.
456// .SECTION Description
457// A helper class (not derived from vtkObject) to store a stack of
458// concatenations.
459class VTKCOMMONTRANSFORMS_EXPORT vtkTransformConcatenationStack
460{
461public:
463 {
465 }
466 void Delete()
467 {
468 delete this;
469 }
470
476
482
484
485protected:
488
492};
493
494#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.
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
virtual void TransformPointsNormalsVectors(vtkPoints *inPts, vtkPoints *outPts, vtkDataArray *inNms, vtkDataArray *outNms, vtkDataArray *inVrs, vtkDataArray *outVrs)
Apply the transformation to a combination of points, normals and vectors.
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 VTK_NEWINSTANCE vtkAbstractTransform * MakeTransform()=0
Make another transform of the same type.
virtual void InternalTransformDerivative(const double in[3], double out[3], double derivative[3][3])=0
virtual void InternalDeepCopy(vtkAbstractTransform *)
Perform any subclass-specific DeepCopy.
void TransformVectorAtPoint(const double point[3], const double in[3], double out[3])
void SetInverse(vtkAbstractTransform *transform)
Set a transformation that this transform will be the inverse of.
virtual void Inverse()=0
Invert the transformation.
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])
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])
void TransformNormalAtPoint(const double point[3], const double in[3], double out[3])
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.
vtkMTimeType GetMTime() override
Override GetMTime necessary because of inverse transforms.
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:55
a simple class to control print indentation
Definition: vtkIndent.h:40
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:42
abstract base class for most VTK objects
Definition: vtkObjectBase.h:66
abstract base class for most VTK objects
Definition: vtkObject.h:60
represent and manipulate 3D points
Definition: vtkPoints.h:40
Critical section locking class.
record modification and/or execution time
Definition: vtkTimeStamp.h:36
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 Iverse() 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
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)
void PrintSelf(ostream &os, vtkIndent indent)
vtkAbstractTransform * PostMatrixTransform
void Rotate(double angle, double x, double y, double z)
vtkAbstractTransform * ForwardTransform
vtkAbstractTransform * InverseTransform
@ point
Definition: vtkX3D.h:236
@ vector
Definition: vtkX3D.h:237
virtual void Update()
Updates the extensions string.
vtkTypeUInt64 vtkMTimeType
Definition: vtkType.h:248
#define VTK_NEWINSTANCE