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) 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 
202  virtual void TransformPointsNormalsVectors(vtkPoints *inPts,
203  vtkPoints *outPts,
204  vtkDataArray *inNms,
205  vtkDataArray *outNms,
206  vtkDataArray *inVrs,
207  vtkDataArray *outVrs);
208 
216  vtkAbstractTransform *GetInverse();
217 
223  void SetInverse(vtkAbstractTransform *transform);
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 
268  virtual VTK_NEWINSTANCE vtkAbstractTransform *MakeTransform() = 0;
269 
278  virtual int CircuitCheck(vtkAbstractTransform *transform);
279 
283  vtkMTimeType GetMTime() VTK_OVERRIDE;
284 
289  void UnRegister(vtkObjectBase *O) VTK_OVERRIDE;
290 
291 protected:
293  ~vtkAbstractTransform() VTK_OVERRIDE;
294 
298  virtual void InternalUpdate() {}
299 
304 
305  float InternalFloatPoint[3];
306  double InternalDoublePoint[3];
307 
308 private:
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 
328 private:
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 {
339 public:
341 
344 
346  vtkAbstractTransform *tmp = this->ForwardTransform;
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.
355 class VTKCOMMONTRANSFORMS_EXPORT vtkTransformConcatenation
356 {
357 public:
359  return new vtkTransformConcatenation(); };
360  void Delete() { delete this; };
361 
365  void Concatenate(vtkAbstractTransform *transform);
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
405  void DeepCopy(vtkTransformConcatenation *transform);
406 
410  int GetNumberOfTransforms() { return this->NumberOfTransforms; };
411 
417  int GetNumberOfPreTransforms() { return this->NumberOfPreTransforms; };
418 
423  return this->NumberOfTransforms-this->NumberOfPreTransforms; };
424 
428  vtkAbstractTransform *GetTransform(int i);
429 
433  vtkMTimeType GetMaxMTime();
434 
435  void PrintSelf(ostream& os, vtkIndent indent);
436 
437 protected:
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.
459 class VTKCOMMONTRANSFORMS_EXPORT vtkTransformConcatenationStack
460 {
461 public:
463  {
464  return new vtkTransformConcatenationStack();
465  }
466  void Delete()
467  {
468  delete this;
469  }
470 
475  void Pop(vtkTransformConcatenation **concat);
476 
481  void Push(vtkTransformConcatenation **concat);
482 
484 
485 protected:
488 
492 };
493 
494 #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 Iverse() is called...
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTransformConcatenation ** StackBottom
int GetNumberOfPostTransforms()
the number of transforms that were post-concatenated.
record modification and/or execution time
Definition: vtkTimeStamp.h:35
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
float * TransformFloatNormalAtPoint(const float point[3], const float normal[3])
Apply the transformation to a single-precision normal at the specified vertex.
virtual void Update()
Updates the extensions string.
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.
vtkTypeUInt64 vtkMTimeType
Definition: vtkType.h:248
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
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_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.