VTK  9.0.2
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 class vtkDataArray;
46 class vtkMatrix4x4;
47 class vtkPoints;
49 
50 class VTKCOMMONTRANSFORMS_EXPORT vtkAbstractTransform : public vtkObject
51 {
52 public:
54  void PrintSelf(ostream& os, vtkIndent indent) override;
55 
60  void TransformPoint(const float in[3], float out[3])
61  {
62  this->Update();
63  this->InternalTransformPoint(in, out);
64  }
65 
70  void TransformPoint(const double in[3], double out[3])
71  {
72  this->Update();
73  this->InternalTransformPoint(in, out);
74  }
75 
80  double* TransformPoint(double x, double y, double z) VTK_SIZEHINT(3)
81  {
82  return this->TransformDoublePoint(x, y, z);
83  }
84  double* TransformPoint(const double point[3]) VTK_SIZEHINT(3)
85  {
86  return this->TransformPoint(point[0], point[1], point[2]);
87  }
88 
90 
94  float* TransformFloatPoint(float x, float y, float z) VTK_SIZEHINT(3)
95  {
96  this->InternalFloatPoint[0] = x;
97  this->InternalFloatPoint[1] = y;
98  this->InternalFloatPoint[2] = z;
99  this->TransformPoint(this->InternalFloatPoint, this->InternalFloatPoint);
100  return this->InternalFloatPoint;
101  }
102  float* TransformFloatPoint(const float point[3]) VTK_SIZEHINT(3)
103  {
104  return this->TransformFloatPoint(point[0], point[1], point[2]);
105  }
107 
109 
113  double* TransformDoublePoint(double x, double y, double z) VTK_SIZEHINT(3)
114  {
115  this->InternalDoublePoint[0] = x;
116  this->InternalDoublePoint[1] = y;
117  this->InternalDoublePoint[2] = z;
118  this->TransformPoint(this->InternalDoublePoint, this->InternalDoublePoint);
119  return this->InternalDoublePoint;
120  }
121  double* TransformDoublePoint(const double point[3]) VTK_SIZEHINT(3)
122  {
123  return this->TransformDoublePoint(point[0], point[1], point[2]);
124  }
126 
128 
133  void TransformNormalAtPoint(const float point[3], const float in[3], float out[3]);
134  void TransformNormalAtPoint(const double point[3], const double in[3], double out[3]);
136 
137  double* TransformNormalAtPoint(const double point[3], const double normal[3]) VTK_SIZEHINT(3)
138  {
139  this->TransformNormalAtPoint(point, normal, this->InternalDoublePoint);
140  return this->InternalDoublePoint;
141  }
142 
144 
149  double* TransformDoubleNormalAtPoint(const double point[3], const double normal[3])
150  VTK_SIZEHINT(3)
151  {
152  this->TransformNormalAtPoint(point, normal, this->InternalDoublePoint);
153  return this->InternalDoublePoint;
154  }
156 
158 
163  float* TransformFloatNormalAtPoint(const float point[3], const float normal[3]) VTK_SIZEHINT(3)
164  {
165  this->TransformNormalAtPoint(point, normal, this->InternalFloatPoint);
166  return this->InternalFloatPoint;
167  }
169 
171 
176  void TransformVectorAtPoint(const float point[3], const float in[3], float out[3]);
177  void TransformVectorAtPoint(const double point[3], const double in[3], double out[3]);
179 
180  double* TransformVectorAtPoint(const double point[3], const double vector[3]) VTK_SIZEHINT(3)
181  {
182  this->TransformVectorAtPoint(point, vector, this->InternalDoublePoint);
183  return this->InternalDoublePoint;
184  }
185 
187 
192  double* TransformDoubleVectorAtPoint(const double point[3], const double vector[3])
193  VTK_SIZEHINT(3)
194  {
195  this->TransformVectorAtPoint(point, vector, this->InternalDoublePoint);
196  return this->InternalDoublePoint;
197  }
199 
201 
206  float* TransformFloatVectorAtPoint(const float point[3], const float vector[3]) VTK_SIZEHINT(3)
207  {
208  this->TransformVectorAtPoint(point, vector, this->InternalFloatPoint);
209  return this->InternalFloatPoint;
210  }
212 
217  virtual void TransformPoints(vtkPoints* inPts, vtkPoints* outPts);
218 
223  virtual void TransformPointsNormalsVectors(vtkPoints* inPts, vtkPoints* outPts,
224  vtkDataArray* inNms, vtkDataArray* outNms, vtkDataArray* inVrs, vtkDataArray* outVrs,
225  int nOptionalVectors = 0, vtkDataArray** inVrsArr = nullptr,
226  vtkDataArray** outVrsArr = nullptr);
227 
236 
243 
247  virtual void Inverse() = 0;
248 
253 
260  void Update();
261 
263 
267  virtual void InternalTransformPoint(const float in[3], float out[3]) = 0;
268  virtual void InternalTransformPoint(const double in[3], double out[3]) = 0;
270 
272 
279  const float in[3], float out[3], float derivative[3][3]) = 0;
281  const double in[3], double out[3], double derivative[3][3]) = 0;
283 
288 
297  virtual int CircuitCheck(vtkAbstractTransform* transform);
298 
302  vtkMTimeType GetMTime() override;
303 
308  void UnRegister(vtkObjectBase* O) override;
309 
310 protected:
313 
317  virtual void InternalUpdate() {}
318 
323 
324  float InternalFloatPoint[3];
325  double InternalDoublePoint[3];
326 
327 private:
328  // We need to record the time of the last update, and we also need
329  // to do mutex locking so updates don't collide. These are private
330  // because Update() is not virtual.
331  // If DependsOnInverse is set, then this transform object will
332  // check its inverse on every update, and update itself accordingly
333  // if necessary.
334 
335  vtkTimeStamp UpdateTime;
336  vtkSimpleCriticalSection* UpdateMutex;
337  vtkSimpleCriticalSection* InverseMutex;
338  int DependsOnInverse;
339 
340  // MyInverse is a transform which is the inverse of this one.
341 
342  vtkAbstractTransform* MyInverse;
343 
344  int InUnRegister;
345 
346 private:
348  void operator=(const vtkAbstractTransform&) = delete;
349 };
350 
351 //-------------------------------------------------------------------------
352 // A simple data structure to hold both a transform and its inverse.
353 // One of ForwardTransform or InverseTransform might be nullptr,
354 // and must be acquired by calling GetInverse() on the other.
356 {
357 public:
359 
362 
364  {
366  this->ForwardTransform = this->InverseTransform;
367  this->InverseTransform = tmp;
368  }
369 };
370 
371 // .NAME vtkTransformConcatenation - store a series of transformations.
372 // .SECTION Description
373 // A helper class (not derived from vtkObject) to store a series of
374 // transformations in a pipelined concatenation.
375 class VTKCOMMONTRANSFORMS_EXPORT vtkTransformConcatenation
376 {
377 public:
379  void Delete() { delete this; }
380 
385 
389  void Concatenate(const double elements[16]);
390 
392 
395  void SetPreMultiplyFlag(int flag) { this->PreMultiplyFlag = flag; }
396  int GetPreMultiplyFlag() { return this->PreMultiplyFlag; }
398 
400 
403  void Translate(double x, double y, double z);
404  void Rotate(double angle, double x, double y, double z);
405  void Scale(double x, double y, double z);
407 
411  void Inverse();
412 
416  int GetInverseFlag() { return this->InverseFlag; }
417 
421  void Identity();
422 
423  // copy the list
425 
429  int GetNumberOfTransforms() { return this->NumberOfTransforms; }
430 
436  int GetNumberOfPreTransforms() { return this->NumberOfPreTransforms; }
437 
441  int GetNumberOfPostTransforms() { return this->NumberOfTransforms - this->NumberOfPreTransforms; }
442 
447 
452 
453  void PrintSelf(ostream& os, vtkIndent indent);
454 
455 protected:
458 
461 
466 
471 
472 private:
474  void operator=(const vtkTransformConcatenation&) = delete;
475 };
476 
477 // .NAME vtkTransformConcatenationStack - Store a stack of concatenations.
478 // .SECTION Description
479 // A helper class (not derived from vtkObject) to store a stack of
480 // concatenations.
481 class VTKCOMMONTRANSFORMS_EXPORT vtkTransformConcatenationStack
482 {
483 public:
485  void Delete() { delete this; }
486 
492 
498 
500 
501 protected:
504 
508 
509 private:
511  void operator=(const vtkTransformConcatenationStack&) = delete;
512 };
513 
514 #endif
superclass for all geometric transformations
double * TransformPoint(const double point[3])
double * TransformDoublePoint(double x, double y, double z)
Apply the transformation to a double-precision (x,y,z) coordinate.
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.
float * TransformFloatPoint(const float point[3])
double * TransformDoublePoint(const double point[3])
void TransformVectorAtPoint(const float point[3], const float in[3], float out[3])
Apply the transformation to a vector at the specified vertex.
virtual int CircuitCheck(vtkAbstractTransform *transform)
Check for self-reference.
double * TransformVectorAtPoint(const double point[3], const double vector[3])
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
float * TransformFloatPoint(float x, float y, float z)
Apply the transformation to an (x,y,z) coordinate.
void UnRegister(vtkObjectBase *O) override
Needs a special UnRegister() implementation to avoid circular references.
void Update()
Update the transform to account for any changes which have been made.
vtkAbstractTransform * GetInverse()
Get the inverse of this transform.
float * TransformFloatNormalAtPoint(const float point[3], const float normal[3])
Apply the transformation to a single-precision normal at the specified vertex.
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.
~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 * TransformDoubleVectorAtPoint(const double point[3], const double vector[3])
Apply the transformation to a double-precision 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 TransformPoint(const double in[3], double out[3])
Apply the transformation to a double-precision coordinate.
void TransformNormalAtPoint(const double point[3], const double in[3], double out[3])
double * TransformDoubleNormalAtPoint(const double point[3], const double normal[3])
Apply the transformation to a double-precision normal at the specified vertex.
double * TransformPoint(double x, double y, double z)
Apply the transformation to a double-precision 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.
double * TransformNormalAtPoint(const double point[3], const double normal[3])
virtual vtkAbstractTransform * MakeTransform()=0
Make another transform of the same type.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:50
a simple class to control print indentation
Definition: vtkIndent.h:34
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:36
abstract base class for most VTK objects
Definition: vtkObjectBase.h:64
abstract base class for most VTK objects
Definition: vtkObject.h:63
represent and manipulate 3D points
Definition: vtkPoints.h:34
Critical section locking class.
record modification and/or execution time
Definition: vtkTimeStamp.h:33
void Push(vtkTransformConcatenation **concat)
push will move 'concat' onto the stack, and make 'concat' a copy of its previous self
static vtkTransformConcatenationStack * New()
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)
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
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 * GetTransform(int i)
get one of the transforms
vtkAbstractTransform * PreMatrixTransform
void Translate(double x, double y, double z)
the three basic linear transformations
void Scale(double x, double y, double z)
static vtkTransformConcatenation * New()
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:242
@ vector
Definition: vtkX3D.h:243
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:293
#define VTK_SIZEHINT(...)
#define VTK_NEWINSTANCE