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 =========================================================================*/
38 #ifndef vtkAbstractTransform_h
39 #define vtkAbstractTransform_h
40 
41 #include "vtkCommonTransformsModule.h" // For export macro
42 #include "vtkObject.h"
43 
44 class vtkDataArray;
45 class vtkMatrix4x4;
46 class vtkPoints;
48 
50 {
51 public:
52 
54  void PrintSelf(ostream& os, vtkIndent indent);
55 
57 
59  void TransformPoint(const float in[3], float out[3]) {
60  this->Update(); this->InternalTransformPoint(in,out); };
62 
64 
66  void TransformPoint(const double in[3], double out[3]) {
67  this->Update(); this->InternalTransformPoint(in,out); };
69 
71 
73  double *TransformPoint(double x, double y, double z) {
74  return this->TransformDoublePoint(x,y,z); }
75  double *TransformPoint(const double point[3]) {
76  return this->TransformPoint(point[0],point[1],point[2]); };
78 
80 
82  float *TransformFloatPoint(float x, float y, float z) {
83  this->InternalFloatPoint[0] = x;
84  this->InternalFloatPoint[1] = y;
85  this->InternalFloatPoint[2] = z;
86  this->TransformPoint(this->InternalFloatPoint,this->InternalFloatPoint);
87  return this->InternalFloatPoint; };
88  float *TransformFloatPoint(const float point[3]) {
89  return this->TransformFloatPoint(point[0],point[1],point[2]); };
91 
93 
95  double *TransformDoublePoint(double x, double y, double z) {
96  this->InternalDoublePoint[0] = x;
97  this->InternalDoublePoint[1] = y;
98  this->InternalDoublePoint[2] = z;
99  this->TransformPoint(this->InternalDoublePoint,this->InternalDoublePoint);
100  return this->InternalDoublePoint; };
101  double *TransformDoublePoint(const double point[3]) {
102  return this->TransformDoublePoint(point[0],point[1],point[2]); };
104 
106 
109  void TransformNormalAtPoint(const float point[3], const float in[3],
110  float out[3]);
111  void TransformNormalAtPoint(const double point[3], const double in[3],
112  double out[3]);
114 
115  double *TransformNormalAtPoint(const double point[3],
116  const double normal[3]) {
117  this->TransformNormalAtPoint(point,normal,this->InternalDoublePoint);
118  return this->InternalDoublePoint; };
119 
121 
124  double *TransformDoubleNormalAtPoint(const double point[3],
125  const double normal[3]) {
126  this->TransformNormalAtPoint(point,normal,this->InternalDoublePoint);
127  return this->InternalDoublePoint; };
129 
131 
134  float *TransformFloatNormalAtPoint(const float point[3],
135  const float normal[3]) {
136  this->TransformNormalAtPoint(point,normal,this->InternalFloatPoint);
137  return this->InternalFloatPoint; };
139 
141 
144  void TransformVectorAtPoint(const float point[3], const float in[3],
145  float out[3]);
146  void TransformVectorAtPoint(const double point[3], const double in[3],
147  double out[3]);
149 
150  double *TransformVectorAtPoint(const double point[3],
151  const double vector[3]) {
152  this->TransformVectorAtPoint(point,vector,this->InternalDoublePoint);
153  return this->InternalDoublePoint; };
154 
156 
159  double *TransformDoubleVectorAtPoint(const double point[3],
160  const double vector[3]) {
161  this->TransformVectorAtPoint(point,vector,this->InternalDoublePoint);
162  return this->InternalDoublePoint; };
164 
166 
169  float *TransformFloatVectorAtPoint(const float point[3],
170  const float vector[3]) {
171  this->TransformVectorAtPoint(point,vector,this->InternalFloatPoint);
172  return this->InternalFloatPoint; };
174 
177  virtual void TransformPoints(vtkPoints *inPts, vtkPoints *outPts);
178 
180 
182  virtual void TransformPointsNormalsVectors(vtkPoints *inPts,
183  vtkPoints *outPts,
184  vtkDataArray *inNms,
185  vtkDataArray *outNms,
186  vtkDataArray *inVrs,
187  vtkDataArray *outVrs);
189 
195  vtkAbstractTransform *GetInverse();
196 
200  void SetInverse(vtkAbstractTransform *transform);
201 
203  virtual void Inverse() = 0;
204 
207 
211  void Update();
212 
214 
216  virtual void InternalTransformPoint(const float in[3], float out[3]) = 0;
217  virtual void InternalTransformPoint(const double in[3], double out[3]) = 0;
219 
221 
225  virtual void InternalTransformDerivative(const float in[3], float out[3],
226  float derivative[3][3]) = 0;
227  virtual void InternalTransformDerivative(const double in[3], double out[3],
228  double derivative[3][3]) = 0;
230 
232  virtual vtkAbstractTransform *MakeTransform() = 0;
233 
240  virtual int CircuitCheck(vtkAbstractTransform *transform);
241 
243  unsigned long GetMTime();
244 
247  virtual void UnRegister(vtkObjectBase *O);
248 
249 protected:
252 
254  virtual void InternalUpdate() {}
255 
258 
259  float InternalFloatPoint[3];
260  double InternalDoublePoint[3];
261 
262 private:
263 
264 //BTX
265  // We need to record the time of the last update, and we also need
266  // to do mutex locking so updates don't collide. These are private
267  // because Update() is not virtual.
268  // If DependsOnInverse is set, then this transform object will
269  // check its inverse on every update, and update itself accordingly
270  // if necessary.
271 //ETX
272  vtkTimeStamp UpdateTime;
273  vtkSimpleCriticalSection *UpdateMutex;
274  vtkSimpleCriticalSection *InverseMutex;
275  int DependsOnInverse;
276 
277 //BTX
278  // MyInverse is a transform which is the inverse of this one.
279 //ETX
280  vtkAbstractTransform *MyInverse;
281 
282  int InUnRegister;
283 
284 private:
285  vtkAbstractTransform(const vtkAbstractTransform&); // Not implemented.
286  void operator=(const vtkAbstractTransform&); // Not implemented.
287 };
288 
289 //BTX
290 //-------------------------------------------------------------------------
291 // A simple data structure to hold both a transform and its inverse.
292 // One of ForwardTransform or InverseTransform might be NULL,
293 // and must be acquired by calling GetInverse() on the other.
295 {
296 public:
298 
301 
304  this->ForwardTransform = this->InverseTransform;
305  this->InverseTransform = tmp; };
306 };
307 
308 // .NAME vtkTransformConcatenation - store a series of transformations.
309 // .SECTION Description
310 // A helper class (not derived from vtkObject) to store a series of
311 // transformations in a pipelined concatenation.
313 {
314 public:
316  return new vtkTransformConcatenation(); };
317  void Delete() { delete this; };
318 
320  void Concatenate(vtkAbstractTransform *transform);
321 
323  void Concatenate(const double elements[16]);
324 
326 
327  void SetPreMultiplyFlag(int flag) { this->PreMultiplyFlag = flag; };
328  int GetPreMultiplyFlag() { return this->PreMultiplyFlag; };
330 
332 
333  void Translate(double x, double y, double z);
334  void Rotate(double angle, double x, double y, double z);
335  void Scale(double x, double y, double z);
337 
339  void Inverse();
340 
342  int GetInverseFlag() { return this->InverseFlag; };
343 
345  void Identity();
346 
347  // copy the list
348  void DeepCopy(vtkTransformConcatenation *transform);
349 
351  int GetNumberOfTransforms() { return this->NumberOfTransforms; };
352 
356  int GetNumberOfPreTransforms() { return this->NumberOfPreTransforms; };
357 
359 
361  return this->NumberOfTransforms-this->NumberOfPreTransforms; };
363 
365  vtkAbstractTransform *GetTransform(int i);
366 
368  unsigned long GetMaxMTime();
369 
370  void PrintSelf(ostream& os, vtkIndent indent);
371 
372 protected:
375 
378 
383 
388 };
389 
390 // .NAME vtkTransformConcatenationStack - Store a stack of concatenations.
391 // .SECTION Description
392 // A helper class (not derived from vtkObject) to store a stack of
393 // concatenations.
395 {
396 public:
398  {
399  return new vtkTransformConcatenationStack();
400  }
401  void Delete()
402  {
403  delete this;
404  }
405 
408  void Pop(vtkTransformConcatenation **concat);
409 
412  void Push(vtkTransformConcatenation **concat);
413 
415 
416 protected:
419 
423 };
424 
425 //ETX
426 
427 #endif
static vtkTransformConcatenation * New()
void TransformPoint(const float in[3], float out[3])
vtkAbstractTransform * PostMatrixTransform
double * TransformVectorAtPoint(const double point[3], const double vector[3])
abstract base class for most VTK objects
Definition: vtkObject.h:61
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:38
vtkAbstractTransform * InverseTransform
vtkTransformConcatenation ** StackBottom
record modification and/or execution time
Definition: vtkTimeStamp.h:34
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
float * TransformFloatNormalAtPoint(const float point[3], const float normal[3])
virtual void Update()
double * TransformPoint(double x, double y, double z)
float * TransformFloatPoint(const float point[3])
double * TransformPoint(const double point[3])
vtkAbstractTransform * ForwardTransform
virtual void InternalDeepCopy(vtkAbstractTransform *)
vtkAbstractTransform * PreMatrixTransform
virtual void PrintSelf(ostream &os, vtkIndent indent)
virtual void UnRegister(vtkObjectBase *o)
virtual unsigned long GetMTime()
#define VTKCOMMONTRANSFORMS_EXPORT
a simple class to control print indentation
Definition: vtkIndent.h:38
double * TransformDoublePoint(double x, double y, double z)
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
superclass for all geometric transformations
double * TransformDoublePoint(const double point[3])
float * TransformFloatVectorAtPoint(const float point[3], const float vector[3])
abstract base class for most VTK objects
Definition: vtkObjectBase.h:59
vtkTransformPair * TransformList
double * TransformDoubleVectorAtPoint(const double point[3], const double vector[3])
Critical section locking class.
double * TransformDoubleNormalAtPoint(const double point[3], const double normal[3])
double * TransformNormalAtPoint(const double point[3], const double normal[3])
vtkTransformConcatenation ** Stack
float * TransformFloatPoint(float x, float y, float z)
static vtkTransformConcatenationStack * New()
represent and manipulate 3D points
Definition: vtkPoints.h:38
void TransformPoint(const double in[3], double out[3])