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 
50 #include "vtkCommonTransformsModule.h" // For export macro
52 
53 #include "vtkMatrix4x4.h" // Needed for inline methods
54 
56 {
57  public:
58  static vtkPerspectiveTransform *New();
60  void PrintSelf(ostream& os, vtkIndent indent);
61 
65  void Identity() { this->Concatenation->Identity(); this->Modified(); };
66 
70  void Inverse() { this->Concatenation->Inverse(); this->Modified(); };
71 
73 
79  void AdjustViewport(double oldXMin, double oldXMax,
80  double oldYMin, double oldYMax,
81  double newXMin, double newXMax,
82  double newYMin, double newYMax);
84 
86 
91  void AdjustZBuffer(double oldNearZ, double oldFarZ,
92  double newNearZ, double newFarZ);
94 
96 
99  void Ortho(double xmin, double xmax, double ymin, double ymax,
100  double znear, double zfar);
102 
104 
108  void Frustum(double xmin, double xmax, double ymin, double ymax,
109  double znear, double zfar);
111 
116  void Perspective(double angle, double aspect, double znear, double zfar);
117 
128  void Shear(double dxdz, double dydz, double zplane);
129 
137  void Stereo(double angle, double focaldistance);
138 
140 
143  void SetupCamera(const double position[3], const double focalpoint[3],
144  const double viewup[3]);
146 
147  void SetupCamera(double p0, double p1, double p2,
148  double fp0, double fp1, double fp2,
149  double vup0, double vup1, double vup2);
150 
152 
154  void Translate(double x, double y, double z) {
155  this->Concatenation->Translate(x,y,z); };
156  void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); };
157  void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); };
159 
161 
165  void RotateWXYZ(double angle, double x, double y, double z) {
166  this->Concatenation->Rotate(angle,x,y,z); };
167  void RotateWXYZ(double angle, const double axis[3]) {
168  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
169  void RotateWXYZ(double angle, const float axis[3]) {
170  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
172 
174 
177  void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); };
178  void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); };
179  void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); };
181 
183 
186  void Scale(double x, double y, double z) {
187  this->Concatenation->Scale(x,y,z); };
188  void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); };
189  void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); };
191 
193 
195  void SetMatrix(vtkMatrix4x4 *matrix) {
196  this->SetMatrix(*matrix->Element); };
197  void SetMatrix(const double elements[16]) {
198  this->Identity(); this->Concatenate(elements); };
200 
202 
204  void Concatenate(vtkMatrix4x4 *matrix) {
205  this->Concatenate(*matrix->Element); };
206  void Concatenate(const double elements[16]) {
207  this->Concatenation->Concatenate(elements); };
209 
215  void Concatenate(vtkHomogeneousTransform *transform);
216 
218 
223  void PreMultiply() {
224  if (this->Concatenation->GetPreMultiplyFlag()) { return; }
225  this->Concatenation->SetPreMultiplyFlag(1); this->Modified(); };
227 
229 
234  void PostMultiply() {
235  if (!this->Concatenation->GetPreMultiplyFlag()) { return; }
236  this->Concatenation->SetPreMultiplyFlag(0); this->Modified(); };
238 
240 
243  return this->Concatenation->GetNumberOfTransforms() +
244  (this->Input == NULL ? 0 : 1); };
246 
248 
254  {
256  if (this->Input == NULL)
257  {
258  t=this->Concatenation->GetTransform(i);
259  }
260  else if (i < this->Concatenation->GetNumberOfPreTransforms())
261  {
262  t=this->Concatenation->GetTransform(i);
263  }
264  else if (i > this->Concatenation->GetNumberOfPreTransforms())
265  {
266  t=this->Concatenation->GetTransform(i-1);
267  }
268  else if (this->GetInverseFlag())
269  {
270  t=this->Input->GetInverse();
271  }
272  else
273  {
274  t=this->Input;
275  }
276  return static_cast<vtkHomogeneousTransform *>(t);
277  }
279 
281 
287  void SetInput(vtkHomogeneousTransform *input);
288  vtkHomogeneousTransform *GetInput() { return this->Input; };
290 
292 
297  return this->Concatenation->GetInverseFlag(); };
299 
301 
302  void Push() { if (this->Stack == NULL) {
303  this->Stack = vtkTransformConcatenationStack::New(); }
304  this->Stack->Push(&this->Concatenation);
305  this->Modified(); };
307 
309 
311  void Pop() { if (this->Stack == NULL) { return; }
312  this->Stack->Pop(&this->Concatenation);
313  this->Modified(); };
315 
319 
326  int CircuitCheck(vtkAbstractTransform *transform);
327 
329  unsigned long GetMTime();
330 
331 protected:
334 
336  void InternalUpdate();
337 
341 
342 private:
343  vtkPerspectiveTransform(const vtkPerspectiveTransform&); // Not implemented
344  void operator=(const vtkPerspectiveTransform&); // Not implemented
345 };
346 
347 
348 #endif
unsigned long GetMTime()
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:38
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)
#define VTKCOMMONTRANSFORMS_EXPORT
a simple class to control print indentation
Definition: vtkIndent.h:38
void RotateWXYZ(double angle, const float axis[3])
vtkHomogeneousTransform * GetConcatenatedTransform(int i)
void InternalDeepCopy(vtkAbstractTransform *transform)
superclass for all geometric transformations
virtual void Modified()
void Translate(const float x[3])
double Element[4][4]
Definition: vtkMatrix4x4.h:50
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