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 
45 class vtkDataArray;
46 class vtkMatrix4x4;
47 class vtkPoints;
49 
50 class VTKCOMMONTRANSFORMS_EXPORT vtkAbstractTransform : public vtkObject
51 {
52 public:
53 
55  void PrintSelf(ostream& os, vtkIndent indent) 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  VTK_SIZEHINT(3)
77  {
78  return this->TransformDoublePoint(x,y,z);
79  }
80  double *TransformPoint(const double point[3])
81  VTK_SIZEHINT(3)
82  {
83  return this->TransformPoint(point[0],point[1],point[2]);
84  }
85 
87 
91  float *TransformFloatPoint(float x, float y, float z)
92  VTK_SIZEHINT(3)
93  {
94  this->InternalFloatPoint[0] = x;
95  this->InternalFloatPoint[1] = y;
96  this->InternalFloatPoint[2] = z;
97  this->TransformPoint(this->InternalFloatPoint,this->InternalFloatPoint);
98  return this->InternalFloatPoint;
99  }
100  float *TransformFloatPoint(const float point[3])
101  VTK_SIZEHINT(3)
102  {
103  return this->TransformFloatPoint(point[0],point[1],point[2]);
104  }
106 
108 
112  double *TransformDoublePoint(double x, double y, double z)
113  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])
122  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],
135  float out[3]);
136  void TransformNormalAtPoint(const double point[3], const double in[3],
137  double out[3]);
139 
140  double *TransformNormalAtPoint(const double point[3],
141  const double normal[3])
142  VTK_SIZEHINT(3)
143  {
144  this->TransformNormalAtPoint(point,normal,this->InternalDoublePoint);
145  return this->InternalDoublePoint;
146  }
147 
149 
154  double *TransformDoubleNormalAtPoint(const double point[3],
155  const double normal[3])
156  VTK_SIZEHINT(3)
157  {
158  this->TransformNormalAtPoint(point,normal,this->InternalDoublePoint);
159  return this->InternalDoublePoint;
160  }
162 
164 
169  float *TransformFloatNormalAtPoint(const float point[3],
170  const float normal[3])
171  VTK_SIZEHINT(3)
172  {
173  this->TransformNormalAtPoint(point,normal,this->InternalFloatPoint);
174  return this->InternalFloatPoint;
175  }
177 
179 
184  void TransformVectorAtPoint(const float point[3], const float in[3],
185  float out[3]);
186  void TransformVectorAtPoint(const double point[3], const double in[3],
187  double out[3]);
189 
190  double *TransformVectorAtPoint(const double point[3],
191  const double vector[3])
192  VTK_SIZEHINT(3)
193  {
194  this->TransformVectorAtPoint(point,vector,this->InternalDoublePoint);
195  return this->InternalDoublePoint;
196  }
197 
199 
204  double *TransformDoubleVectorAtPoint(const double point[3],
205  const double vector[3])
206  VTK_SIZEHINT(3)
207  {
208  this->TransformVectorAtPoint(point,vector,this->InternalDoublePoint);
209  return this->InternalDoublePoint;
210  }
212 
214 
219  float *TransformFloatVectorAtPoint(const float point[3],
220  const float vector[3])
221  VTK_SIZEHINT(3)
222  {
223  this->TransformVectorAtPoint(point,vector,this->InternalFloatPoint);
224  return this->InternalFloatPoint;
225  }
227 
232  virtual void TransformPoints(vtkPoints *inPts, vtkPoints *outPts);
233 
238  virtual void TransformPointsNormalsVectors(vtkPoints *inPts,
239  vtkPoints *outPts,
240  vtkDataArray *inNms,
241  vtkDataArray *outNms,
242  vtkDataArray *inVrs,
243  vtkDataArray *outVrs,
244  int nOptionalVectors = 0,
245  vtkDataArray** inVrsArr = nullptr,
246  vtkDataArray** outVrsArr = nullptr);
247 
255  vtkAbstractTransform *GetInverse();
256 
262  void SetInverse(vtkAbstractTransform *transform);
263 
267  virtual void Inverse() = 0;
268 
272  void DeepCopy(vtkAbstractTransform *);
273 
280  void Update();
281 
283 
287  virtual void InternalTransformPoint(const float in[3], float out[3]) = 0;
288  virtual void InternalTransformPoint(const double in[3], double out[3]) = 0;
290 
292 
298  virtual void InternalTransformDerivative(const float in[3], float out[3],
299  float derivative[3][3]) = 0;
300  virtual void InternalTransformDerivative(const double in[3], double out[3],
301  double derivative[3][3]) = 0;
303 
307  virtual VTK_NEWINSTANCE vtkAbstractTransform *MakeTransform() = 0;
308 
317  virtual int CircuitCheck(vtkAbstractTransform *transform);
318 
322  vtkMTimeType GetMTime() override;
323 
328  void UnRegister(vtkObjectBase *O) override;
329 
330 protected:
332  ~vtkAbstractTransform() override;
333 
337  virtual void InternalUpdate() {}
338 
343 
344  float InternalFloatPoint[3];
345  double InternalDoublePoint[3];
346 
347 private:
348 
349  // We need to record the time of the last update, and we also need
350  // to do mutex locking so updates don't collide. These are private
351  // because Update() is not virtual.
352  // If DependsOnInverse is set, then this transform object will
353  // check its inverse on every update, and update itself accordingly
354  // if necessary.
355 
356  vtkTimeStamp UpdateTime;
357  vtkSimpleCriticalSection *UpdateMutex;
358  vtkSimpleCriticalSection *InverseMutex;
359  int DependsOnInverse;
360 
361  // MyInverse is a transform which is the inverse of this one.
362 
363  vtkAbstractTransform *MyInverse;
364 
365  int InUnRegister;
366 
367 private:
369  void operator=(const vtkAbstractTransform&) = delete;
370 };
371 
372 //-------------------------------------------------------------------------
373 // A simple data structure to hold both a transform and its inverse.
374 // One of ForwardTransform or InverseTransform might be nullptr,
375 // and must be acquired by calling GetInverse() on the other.
377 {
378 public:
380 
383 
385  vtkAbstractTransform *tmp = this->ForwardTransform;
386  this->ForwardTransform = this->InverseTransform;
387  this->InverseTransform = tmp; }
388 };
389 
390 // .NAME vtkTransformConcatenation - store a series of transformations.
391 // .SECTION Description
392 // A helper class (not derived from vtkObject) to store a series of
393 // transformations in a pipelined concatenation.
394 class VTKCOMMONTRANSFORMS_EXPORT vtkTransformConcatenation
395 {
396 public:
398  return new vtkTransformConcatenation(); }
399  void Delete() { delete this; }
400 
404  void Concatenate(vtkAbstractTransform *transform);
405 
409  void Concatenate(const double elements[16]);
410 
412 
415  void SetPreMultiplyFlag(int flag) { this->PreMultiplyFlag = flag; }
416  int GetPreMultiplyFlag() { return this->PreMultiplyFlag; }
418 
420 
423  void Translate(double x, double y, double z);
424  void Rotate(double angle, double x, double y, double z);
425  void Scale(double x, double y, double z);
427 
431  void Inverse();
432 
436  int GetInverseFlag() { return this->InverseFlag; }
437 
441  void Identity();
442 
443  // copy the list
444  void DeepCopy(vtkTransformConcatenation *transform);
445 
449  int GetNumberOfTransforms() { return this->NumberOfTransforms; }
450 
456  int GetNumberOfPreTransforms() { return this->NumberOfPreTransforms; }
457 
462  return this->NumberOfTransforms-this->NumberOfPreTransforms; }
463 
467  vtkAbstractTransform *GetTransform(int i);
468 
472  vtkMTimeType GetMaxMTime();
473 
474  void PrintSelf(ostream& os, vtkIndent indent);
475 
476 protected:
479 
482 
487 
492 
493 private:
495  = delete;
496  void operator=(const vtkTransformConcatenation&) = delete;
497 };
498 
499 // .NAME vtkTransformConcatenationStack - Store a stack of concatenations.
500 // .SECTION Description
501 // A helper class (not derived from vtkObject) to store a stack of
502 // concatenations.
503 class VTKCOMMONTRANSFORMS_EXPORT vtkTransformConcatenationStack
504 {
505 public:
507  {
508  return new vtkTransformConcatenationStack();
509  }
510  void Delete()
511  {
512  delete this;
513  }
514 
519  void Pop(vtkTransformConcatenation **concat);
520 
525  void Push(vtkTransformConcatenation **concat);
526 
527  void DeepCopy(vtkTransformConcatenationStack *stack);
528 
529 protected:
532 
536 
537 private:
539  = delete;
540  void operator=(const vtkTransformConcatenationStack&) = delete;
541 };
542 
543 #endif
void SetPreMultiplyFlag(int flag)
set/get the PreMultiply flag
static vtkTransformConcatenation * New()
void TransformPoint(const float in[3], float out[3])
Apply the transformation to a coordinate.
vtkAbstractTransform * PostMatrixTransform
double * TransformVectorAtPoint(const double point[3], const double vector[3])
abstract base class for most VTK objects
Definition: vtkObject.h:59
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
vtkAbstractTransform * InverseTransform
int GetNumberOfPreTransforms()
the number of transforms that were pre-concatenated (note that whenever Inverse() is called...
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTransformConcatenation ** StackBottom
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:302
int GetNumberOfPostTransforms()
the number of transforms that were post-concatenated.
record modification and/or execution time
Definition: vtkTimeStamp.h:35
virtual void InternalUpdate()
Perform any subclass-specific Update.
float * TransformFloatNormalAtPoint(const float point[3], const float normal[3])
Apply the transformation to a single-precision normal at the specified vertex.
double * TransformPoint(double x, double y, double z)
Apply the transformation to a double-precision coordinate.
float * TransformFloatPoint(const float point[3])
Apply the transformation to an (x,y,z) coordinate.
double * TransformPoint(const double point[3])
vtkAbstractTransform * ForwardTransform
virtual void InternalDeepCopy(vtkAbstractTransform *)
Perform any subclass-specific DeepCopy.
int GetInverseFlag()
get the inverse flag
vtkAbstractTransform * PreMatrixTransform
int GetPreMultiplyFlag()
set/get the PreMultiply flag
virtual void UnRegister(vtkObjectBase *o)
Decrease the reference count (release by another object).
a simple class to control print indentation
Definition: vtkIndent.h:39
double * TransformDoublePoint(double x, double y, double z)
Apply the transformation to a double-precision (x,y,z) coordinate.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
superclass for all geometric transformations
virtual vtkMTimeType GetMTime()
Return this object's modified time.
double * TransformDoublePoint(const double point[3])
Apply the transformation to a double-precision (x,y,z) coordinate.
float * TransformFloatVectorAtPoint(const float point[3], const float vector[3])
Apply the transformation to a single-precision vector at the specified vertex.
abstract base class for most VTK objects
Definition: vtkObjectBase.h:65
#define VTK_SIZEHINT(...)
#define VTK_NEWINSTANCE
vtkTransformPair * TransformList
double * TransformDoubleVectorAtPoint(const double point[3], const double vector[3])
Apply the transformation to a double-precision vector at the specified vertex.
Critical section locking class.
int GetNumberOfTransforms()
the number of stored transforms
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])
vtkTransformConcatenation ** Stack
float * TransformFloatPoint(float x, float y, float z)
Apply the transformation to an (x,y,z) coordinate.
static vtkTransformConcatenationStack * New()
represent and manipulate 3D points
Definition: vtkPoints.h:39
void TransformPoint(const double in[3], double out[3])
Apply the transformation to a double-precision coordinate.