VTK
vtkPerspectiveTransform.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkPerspectiveTransform.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 =========================================================================*/
15 
47 #ifndef __vtkPerspectiveTransform_h
48 #define __vtkPerspectiveTransform_h
49 
51 
52 #include "vtkMatrix4x4.h" // Needed for inline methods
53 
55 {
56  public:
57  static vtkPerspectiveTransform *New();
59  void PrintSelf(ostream& os, vtkIndent indent);
60 
64  void Identity() { this->Concatenation->Identity(); this->Modified(); };
65 
69  void Inverse() { this->Concatenation->Inverse(); this->Modified(); };
70 
72 
78  void AdjustViewport(double oldXMin, double oldXMax,
79  double oldYMin, double oldYMax,
80  double newXMin, double newXMax,
81  double newYMin, double newYMax);
83 
85 
90  void AdjustZBuffer(double oldNearZ, double oldFarZ,
91  double newNearZ, double newFarZ);
93 
95 
98  void Ortho(double xmin, double xmax, double ymin, double ymax,
99  double znear, double zfar);
101 
103 
107  void Frustum(double xmin, double xmax, double ymin, double ymax,
108  double znear, double zfar);
110 
115  void Perspective(double angle, double aspect, double znear, double zfar);
116 
127  void Shear(double dxdz, double dydz, double zplane);
128 
136  void Stereo(double angle, double focaldistance);
137 
139 
142  void SetupCamera(const double position[3], const double focalpoint[3],
143  const double viewup[3]);
145 
146  void SetupCamera(double p0, double p1, double p2,
147  double fp0, double fp1, double fp2,
148  double vup0, double vup1, double vup2);
149 
151 
153  void Translate(double x, double y, double z) {
154  this->Concatenation->Translate(x,y,z); };
155  void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); };
156  void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); };
158 
160 
164  void RotateWXYZ(double angle, double x, double y, double z) {
165  this->Concatenation->Rotate(angle,x,y,z); };
166  void RotateWXYZ(double angle, const double axis[3]) {
167  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
168  void RotateWXYZ(double angle, const float axis[3]) {
169  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
171 
173 
176  void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); };
177  void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); };
178  void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); };
180 
182 
185  void Scale(double x, double y, double z) {
186  this->Concatenation->Scale(x,y,z); };
187  void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); };
188  void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); };
190 
192 
194  void SetMatrix(vtkMatrix4x4 *matrix) {
195  this->SetMatrix(*matrix->Element); };
196  void SetMatrix(const double elements[16]) {
197  this->Identity(); this->Concatenate(elements); };
199 
201 
203  void Concatenate(vtkMatrix4x4 *matrix) {
204  this->Concatenate(*matrix->Element); };
205  void Concatenate(const double elements[16]) {
206  this->Concatenation->Concatenate(elements); };
208 
214  void Concatenate(vtkHomogeneousTransform *transform);
215 
217 
222  void PreMultiply() {
223  if (this->Concatenation->GetPreMultiplyFlag()) { return; }
224  this->Concatenation->SetPreMultiplyFlag(1); this->Modified(); };
226 
228 
233  void PostMultiply() {
234  if (!this->Concatenation->GetPreMultiplyFlag()) { return; }
235  this->Concatenation->SetPreMultiplyFlag(0); this->Modified(); };
237 
239 
242  return this->Concatenation->GetNumberOfTransforms() +
243  (this->Input == NULL ? 0 : 1); };
245 
247 
253  {
255  if (this->Input == NULL)
256  {
257  t=this->Concatenation->GetTransform(i);
258  }
259  else if (i < this->Concatenation->GetNumberOfPreTransforms())
260  {
261  t=this->Concatenation->GetTransform(i);
262  }
263  else if (i > this->Concatenation->GetNumberOfPreTransforms())
264  {
265  t=this->Concatenation->GetTransform(i-1);
266  }
267  else if (this->GetInverseFlag())
268  {
269  t=this->Input->GetInverse();
270  }
271  else
272  {
273  t=this->Input;
274  }
275  return static_cast<vtkHomogeneousTransform *>(t);
276  }
278 
280 
286  void SetInput(vtkHomogeneousTransform *input);
287  vtkHomogeneousTransform *GetInput() { return this->Input; };
289 
291 
296  return this->Concatenation->GetInverseFlag(); };
298 
300 
301  void Push() { if (this->Stack == NULL) {
302  this->Stack = vtkTransformConcatenationStack::New(); }
303  this->Stack->Push(&this->Concatenation);
304  this->Modified(); };
306 
308 
310  void Pop() { if (this->Stack == NULL) { return; }
311  this->Stack->Pop(&this->Concatenation);
312  this->Modified(); };
314 
318 
325  int CircuitCheck(vtkAbstractTransform *transform);
326 
328  unsigned long GetMTime();
329 
330 protected:
333 
335  void InternalUpdate();
336 
340 
341 private:
342  vtkPerspectiveTransform(const vtkPerspectiveTransform&); // Not implemented
343  void operator=(const vtkPerspectiveTransform&); // Not implemented
344 };
345 
346 
347 #endif
unsigned long GetMTime()
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:37
vtkHomogeneousTransform * Input
void SetMatrix(const double elements[16])
void RotateWXYZ(double angle, double x, double y, double z)
superclass for homogeneous transformations
void Scale(const double s[3])
void SetMatrix(vtkMatrix4x4 *matrix)
void Scale(const float s[3])
virtual vtkAbstractTransform * MakeTransform()=0
vtkAbstractTransform * GetInverse()
void Concatenate(vtkMatrix4x4 *matrix)
void Translate(const double x[3])
vtkHomogeneousTransform * GetInput()
virtual int CircuitCheck(vtkAbstractTransform *transform)
a simple class to control print indentation
Definition: vtkIndent.h:37
void RotateWXYZ(double angle, const float axis[3])
vtkHomogeneousTransform * GetConcatenatedTransform(int i)
void InternalDeepCopy(vtkAbstractTransform *transform)
superclass for all geometric transformations
#define VTK_COMMON_EXPORT
virtual void Modified()
void Translate(const float x[3])
double Element[4][4]
Definition: vtkMatrix4x4.h:49
void Concatenate(const double elements[16])
vtkTransformConcatenation * Concatenation
vtkTransformConcatenationStack * Stack
void RotateWXYZ(double angle, const double axis[3])
void PrintSelf(ostream &os, vtkIndent indent)
static vtkObject * New()
static vtkTransformConcatenationStack * New()
void Scale(double x, double y, double z)
void Translate(double x, double y, double z)
describes a 4x4 matrix transformation