VTK  9.0.20200923
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 
235  vtkAbstractTransform* GetInverse();
236 
242  void SetInverse(vtkAbstractTransform* transform);
243 
247  virtual void Inverse() = 0;
248 
252  void DeepCopy(vtkAbstractTransform*);
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 
278  virtual void InternalTransformDerivative(
279  const float in[3], float out[3], float derivative[3][3]) = 0;
280  virtual void InternalTransformDerivative(
281  const double in[3], double out[3], double derivative[3][3]) = 0;
283 
287  virtual VTK_NEWINSTANCE vtkAbstractTransform* MakeTransform() = 0;
288 
297  virtual int CircuitCheck(vtkAbstractTransform* transform);
298 
302  vtkMTimeType GetMTime() override;
303 
308  void UnRegister(vtkObjectBase* O) override;
309 
310 protected:
312  ~vtkAbstractTransform() override;
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:
358  vtkTransformPair() = default;
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 
384  void Concatenate(vtkAbstractTransform* transform);
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
424  void DeepCopy(vtkTransformConcatenation* transform);
425 
429  int GetNumberOfTransforms() { return this->NumberOfTransforms; }
430 
436  int GetNumberOfPreTransforms() { return this->NumberOfPreTransforms; }
437 
441  int GetNumberOfPostTransforms() { return this->NumberOfTransforms - this->NumberOfPreTransforms; }
442 
446  vtkAbstractTransform* GetTransform(int i);
447 
451  vtkMTimeType GetMaxMTime();
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 
491  void Pop(vtkTransformConcatenation** concat);
492 
497  void Push(vtkTransformConcatenation** concat);
498 
499  void DeepCopy(vtkTransformConcatenationStack* stack);
500 
501 protected:
504 
508 
509 private:
511  void operator=(const vtkTransformConcatenationStack&) = delete;
512 };
513 
514 #endif
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:33
vtkTransformConcatenation::GetNumberOfPostTransforms
int GetNumberOfPostTransforms()
the number of transforms that were post-concatenated.
Definition: vtkAbstractTransform.h:441
vtkX3D::vector
Definition: vtkX3D.h:243
vtkTransformConcatenation::GetNumberOfTransforms
int GetNumberOfTransforms()
the number of stored transforms
Definition: vtkAbstractTransform.h:429
vtkAbstractTransform
superclass for all geometric transformations
Definition: vtkAbstractTransform.h:50
vtkTransformConcatenationStack::StackSize
int StackSize
Definition: vtkAbstractTransform.h:505
vtkTransformConcatenation::PreMatrixTransform
vtkAbstractTransform * PreMatrixTransform
Definition: vtkAbstractTransform.h:464
vtkTransformConcatenation::GetPreMultiplyFlag
int GetPreMultiplyFlag()
Definition: vtkAbstractTransform.h:396
vtkAbstractTransform::TransformNormalAtPoint
double * TransformNormalAtPoint(const double point[3], const double normal[3])
Definition: vtkAbstractTransform.h:137
vtkTransformConcatenation::SetPreMultiplyFlag
void SetPreMultiplyFlag(int flag)
set/get the PreMultiply flag
Definition: vtkAbstractTransform.h:395
vtkAbstractTransform::TransformVectorAtPoint
double * TransformVectorAtPoint(const double point[3], const double vector[3])
Definition: vtkAbstractTransform.h:180
vtkTransformConcatenationStack
Definition: vtkAbstractTransform.h:481
vtkTransformConcatenation::PostMatrix
vtkMatrix4x4 * PostMatrix
Definition: vtkAbstractTransform.h:463
vtkAbstractTransform::InternalUpdate
virtual void InternalUpdate()
Perform any subclass-specific Update.
Definition: vtkAbstractTransform.h:317
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:32
vtkTransformConcatenation::Delete
void Delete()
Definition: vtkAbstractTransform.h:379
vtkTransformPair::SwapForwardInverse
void SwapForwardInverse()
Definition: vtkAbstractTransform.h:363
vtkAbstractTransform::TransformFloatPoint
float * TransformFloatPoint(const float point[3])
Definition: vtkAbstractTransform.h:102
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkTransformPair::vtkTransformPair
vtkTransformPair()=default
vtkAbstractTransform::TransformFloatPoint
float * TransformFloatPoint(float x, float y, float z)
Apply the transformation to an (x,y,z) coordinate.
Definition: vtkAbstractTransform.h:94
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:49
vtkTransformConcatenation::PreMatrix
vtkMatrix4x4 * PreMatrix
Definition: vtkAbstractTransform.h:462
vtkAbstractTransform::TransformPoint
void TransformPoint(const double in[3], double out[3])
Apply the transformation to a double-precision coordinate.
Definition: vtkAbstractTransform.h:70
vtkTransformConcatenationStack::Delete
void Delete()
Definition: vtkAbstractTransform.h:485
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:192
vtkTransformConcatenation::PostMatrixTransform
vtkAbstractTransform * PostMatrixTransform
Definition: vtkAbstractTransform.h:465
vtkTransformConcatenation::NumberOfPreTransforms
int NumberOfPreTransforms
Definition: vtkAbstractTransform.h:468
vtkAbstractTransform::TransformPoint
double * TransformPoint(const double point[3])
Definition: vtkAbstractTransform.h:84
vtkX3D::point
Definition: vtkX3D.h:242
vtkTransformConcatenation::GetNumberOfPreTransforms
int GetNumberOfPreTransforms()
the number of transforms that were pre-concatenated (note that whenever Inverse() is called,...
Definition: vtkAbstractTransform.h:436
vtkTransformConcatenationStack::Stack
vtkTransformConcatenation ** Stack
Definition: vtkAbstractTransform.h:506
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:45
vtkTransformPair::InverseTransform
vtkAbstractTransform * InverseTransform
Definition: vtkAbstractTransform.h:361
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:163
vtkObject::GetMTime
virtual vtkMTimeType GetMTime()
Return this object's modified time.
vtkTransformConcatenation::GetInverseFlag
int GetInverseFlag()
get the inverse flag
Definition: vtkAbstractTransform.h:416
vtkObjectBase
abstract base class for most VTK objects
Definition: vtkObjectBase.h:69
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkAbstractTransform::TransformPoint
double * TransformPoint(double x, double y, double z)
Apply the transformation to a double-precision coordinate.
Definition: vtkAbstractTransform.h:80
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
vtkTransformConcatenation::InverseFlag
int InverseFlag
Definition: vtkAbstractTransform.h:459
vtkObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTransformConcatenation::TransformList
vtkTransformPair * TransformList
Definition: vtkAbstractTransform.h:470
vtkSimpleCriticalSection
Critical section locking class.
Definition: vtkSimpleCriticalSection.h:60
vtkTransformConcatenationStack::New
static vtkTransformConcatenationStack * New()
Definition: vtkAbstractTransform.h:484
vtkTransformPair::ForwardTransform
vtkAbstractTransform * ForwardTransform
Definition: vtkAbstractTransform.h:360
vtkObject.h
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:206
vtkTransformPair
Definition: vtkAbstractTransform.h:355
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:149
vtkTransformConcatenationStack::StackBottom
vtkTransformConcatenation ** StackBottom
Definition: vtkAbstractTransform.h:507
vtkTransformConcatenation::NumberOfTransforms
int NumberOfTransforms
Definition: vtkAbstractTransform.h:467
vtkAbstractTransform::TransformPoint
void TransformPoint(const float in[3], float out[3])
Apply the transformation to a coordinate.
Definition: vtkAbstractTransform.h:60
vtkAbstractTransform::TransformDoublePoint
double * TransformDoublePoint(const double point[3])
Definition: vtkAbstractTransform.h:121
vtkTransformConcatenation::PreMultiplyFlag
int PreMultiplyFlag
Definition: vtkAbstractTransform.h:460
VTK_NEWINSTANCE
#define VTK_NEWINSTANCE
Definition: vtkWrappingHints.h:42
vtkTransformConcatenation::MaxNumberOfTransforms
int MaxNumberOfTransforms
Definition: vtkAbstractTransform.h:469
vtkTransformConcatenation::New
static vtkTransformConcatenation * New()
Definition: vtkAbstractTransform.h:378
vtkTransformConcatenation
Definition: vtkAbstractTransform.h:375
vtkObjectBase::UnRegister
virtual void UnRegister(vtkObjectBase *o)
Decrease the reference count (release by another object).
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:285
vtkAbstractTransform::InternalDeepCopy
virtual void InternalDeepCopy(vtkAbstractTransform *)
Perform any subclass-specific DeepCopy.
Definition: vtkAbstractTransform.h:322
vtkAbstractTransform::TransformDoublePoint
double * TransformDoublePoint(double x, double y, double z)
Apply the transformation to a double-precision (x,y,z) coordinate.
Definition: vtkAbstractTransform.h:113