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 "vtkObject.h"
42 
43 class vtkDataArray;
44 class vtkMatrix4x4;
45 class vtkPoints;
47 
49 {
50 public:
51 
53  void PrintSelf(ostream& os, vtkIndent indent);
54 
56 
58  void TransformPoint(const float in[3], float out[3]) {
59  this->Update(); this->InternalTransformPoint(in,out); };
61 
63 
65  void TransformPoint(const double in[3], double out[3]) {
66  this->Update(); this->InternalTransformPoint(in,out); };
68 
70 
72  double *TransformPoint(double x, double y, double z) {
73  return this->TransformDoublePoint(x,y,z); }
74  double *TransformPoint(const double point[3]) {
75  return this->TransformPoint(point[0],point[1],point[2]); };
77 
79 
81  float *TransformFloatPoint(float x, float y, float z) {
82  this->InternalFloatPoint[0] = x;
83  this->InternalFloatPoint[1] = y;
84  this->InternalFloatPoint[2] = z;
85  this->TransformPoint(this->InternalFloatPoint,this->InternalFloatPoint);
86  return this->InternalFloatPoint; };
87  float *TransformFloatPoint(const float point[3]) {
88  return this->TransformFloatPoint(point[0],point[1],point[2]); };
90 
92 
94  double *TransformDoublePoint(double x, double y, double z) {
95  this->InternalDoublePoint[0] = x;
96  this->InternalDoublePoint[1] = y;
97  this->InternalDoublePoint[2] = z;
98  this->TransformPoint(this->InternalDoublePoint,this->InternalDoublePoint);
99  return this->InternalDoublePoint; };
100  double *TransformDoublePoint(const double point[3]) {
101  return this->TransformDoublePoint(point[0],point[1],point[2]); };
103 
105 
108  void TransformNormalAtPoint(const float point[3], const float in[3],
109  float out[3]);
110  void TransformNormalAtPoint(const double point[3], const double in[3],
111  double out[3]);
113 
114  double *TransformNormalAtPoint(const double point[3],
115  const double normal[3]) {
116  this->TransformNormalAtPoint(point,normal,this->InternalDoublePoint);
117  return this->InternalDoublePoint; };
118 
120 
123  double *TransformDoubleNormalAtPoint(const double point[3],
124  const double normal[3]) {
125  this->TransformNormalAtPoint(point,normal,this->InternalDoublePoint);
126  return this->InternalDoublePoint; };
128 
130 
133  float *TransformFloatNormalAtPoint(const float point[3],
134  const float normal[3]) {
135  this->TransformNormalAtPoint(point,normal,this->InternalFloatPoint);
136  return this->InternalFloatPoint; };
138 
140 
143  void TransformVectorAtPoint(const float point[3], const float in[3],
144  float out[3]);
145  void TransformVectorAtPoint(const double point[3], const double in[3],
146  double out[3]);
148 
149  double *TransformVectorAtPoint(const double point[3],
150  const double vector[3]) {
151  this->TransformVectorAtPoint(point,vector,this->InternalDoublePoint);
152  return this->InternalDoublePoint; };
153 
155 
158  double *TransformDoubleVectorAtPoint(const double point[3],
159  const double vector[3]) {
160  this->TransformVectorAtPoint(point,vector,this->InternalDoublePoint);
161  return this->InternalDoublePoint; };
163 
165 
168  float *TransformFloatVectorAtPoint(const float point[3],
169  const float vector[3]) {
170  this->TransformVectorAtPoint(point,vector,this->InternalFloatPoint);
171  return this->InternalFloatPoint; };
173 
176  virtual void TransformPoints(vtkPoints *inPts, vtkPoints *outPts);
177 
179 
181  virtual void TransformPointsNormalsVectors(vtkPoints *inPts,
182  vtkPoints *outPts,
183  vtkDataArray *inNms,
184  vtkDataArray *outNms,
185  vtkDataArray *inVrs,
186  vtkDataArray *outVrs);
188 
194  vtkAbstractTransform *GetInverse();
195 
199  void SetInverse(vtkAbstractTransform *transform);
200 
202  virtual void Inverse() = 0;
203 
205  void DeepCopy(vtkAbstractTransform *);
206 
210  void Update();
211 
213 
215  virtual void InternalTransformPoint(const float in[3], float out[3]) = 0;
216  virtual void InternalTransformPoint(const double in[3], double out[3]) = 0;
218 
220 
224  virtual void InternalTransformDerivative(const float in[3], float out[3],
225  float derivative[3][3]) = 0;
226  virtual void InternalTransformDerivative(const double in[3], double out[3],
227  double derivative[3][3]) = 0;
229 
231  virtual vtkAbstractTransform *MakeTransform() = 0;
232 
239  virtual int CircuitCheck(vtkAbstractTransform *transform);
240 
242  unsigned long GetMTime();
243 
246  virtual void UnRegister(vtkObjectBase *O);
247 
250  VTK_LEGACY(void Identity());
251 
252 protected:
255 
257  virtual void InternalUpdate() {};
258 
260  virtual void InternalDeepCopy(vtkAbstractTransform *) {};
261 
262  float InternalFloatPoint[3];
263  double InternalDoublePoint[3];
264 
265 private:
266 
267 //BTX
268  // We need to record the time of the last update, and we also need
269  // to do mutex locking so updates don't collide. These are private
270  // because Update() is not virtual.
271  // If DependsOnInverse is set, then this transform object will
272  // check its inverse on every update, and update itself accordingly
273  // if necessary.
274 //ETX
275  vtkTimeStamp UpdateTime;
276  vtkSimpleCriticalSection *UpdateMutex;
277  vtkSimpleCriticalSection *InverseMutex;
278  int DependsOnInverse;
279 
280 //BTX
281  // MyInverse is a transform which is the inverse of this one.
282 //ETX
283  vtkAbstractTransform *MyInverse;
284 
285  int InUnRegister;
286 
287 private:
288  vtkAbstractTransform(const vtkAbstractTransform&); // Not implemented.
289  void operator=(const vtkAbstractTransform&); // Not implemented.
290 };
291 
292 //BTX
293 //-------------------------------------------------------------------------
294 // A simple data structure to hold both a transform and its inverse.
295 // One of ForwardTransform or InverseTransform might be NULL,
296 // and must be acquired by calling GetInverse() on the other.
298 {
299 public:
301 
304 
307  this->ForwardTransform = this->InverseTransform;
308  this->InverseTransform = tmp; };
309 };
310 
311 // .NAME vtkTransformConcatenation - store a series of transformations.
312 // .SECTION Description
313 // A helper class (not derived from vtkObject) to store a series of
314 // transformations in a pipelined concatenation.
316 {
317 public:
319  return new vtkTransformConcatenation(); };
320  void Delete() { delete this; };
321 
323  void Concatenate(vtkAbstractTransform *transform);
324 
326  void Concatenate(const double elements[16]);
327 
329 
330  void SetPreMultiplyFlag(int flag) { this->PreMultiplyFlag = flag; };
331  int GetPreMultiplyFlag() { return this->PreMultiplyFlag; };
333 
335 
336  void Translate(double x, double y, double z);
337  void Rotate(double angle, double x, double y, double z);
338  void Scale(double x, double y, double z);
340 
342  void Inverse();
343 
345  int GetInverseFlag() { return this->InverseFlag; };
346 
348  void Identity();
349 
350  // copy the list
351  void DeepCopy(vtkTransformConcatenation *transform);
352 
354  int GetNumberOfTransforms() { return this->NumberOfTransforms; };
355 
359  int GetNumberOfPreTransforms() { return this->NumberOfPreTransforms; };
360 
362 
364  return this->NumberOfTransforms-this->NumberOfPreTransforms; };
366 
368  vtkAbstractTransform *GetTransform(int i);
369 
371  unsigned long GetMaxMTime();
372 
373  void PrintSelf(ostream& os, vtkIndent indent);
374 
375 protected:
378 
381 
386 
391 };
392 
393 // .NAME vtkTransformConcatenationStack - Store a stack of concatenations.
394 // .SECTION Description
395 // A helper class (not derived from vtkObject) to store a stack of
396 // concatenations.
398 {
399 public:
401  {
402  return new vtkTransformConcatenationStack();
403  }
404  void Delete()
405  {
406  delete this;
407  }
408 
411  void Pop(vtkTransformConcatenation **concat);
412 
415  void Push(vtkTransformConcatenation **concat);
416 
417  void DeepCopy(vtkTransformConcatenationStack *stack);
418 
419 protected:
422 
426 };
427 
428 //ETX
429 
430 #endif
431 
432 
433 
434 
435 
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:60
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:37
vtkAbstractTransform * InverseTransform
vtkTransformConcatenation ** StackBottom
record modification and/or execution time
Definition: vtkTimeStamp.h:33
float * TransformFloatNormalAtPoint(const float point[3], const float normal[3])
double * TransformPoint(double x, double y, double z)
float * TransformFloatPoint(const float point[3])
double * TransformPoint(const double point[3])
vtkAbstractTransform * ForwardTransform
vtkAbstractTransform * PreMatrixTransform
virtual void PrintSelf(ostream &os, vtkIndent indent)
virtual void UnRegister(vtkObjectBase *o)
virtual unsigned long GetMTime()
a simple class to control print indentation
Definition: vtkIndent.h:37
double * TransformDoublePoint(double x, double y, double z)
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:53
superclass for all geometric transformations
double * TransformDoublePoint(const double point[3])
#define VTK_COMMON_EXPORT
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])
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])