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 
48 #ifndef vtkPerspectiveTransform_h
49 #define vtkPerspectiveTransform_h
50 
51 #include "vtkCommonTransformsModule.h" // For export macro
53 
54 #include "vtkMatrix4x4.h" // Needed for inline methods
55 
56 class VTKCOMMONTRANSFORMS_EXPORT vtkPerspectiveTransform : public vtkHomogeneousTransform
57 {
58  public:
61  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
62 
68  void Identity() { this->Concatenation->Identity(); this->Modified(); };
69 
75  void Inverse() VTK_OVERRIDE
76  { this->Concatenation->Inverse(); this->Modified(); };
77 
86  void AdjustViewport(double oldXMin, double oldXMax,
87  double oldYMin, double oldYMax,
88  double newXMin, double newXMax,
89  double newYMin, double newYMax);
90 
98  void AdjustZBuffer(double oldNearZ, double oldFarZ,
99  double newNearZ, double newFarZ);
100 
106  void Ortho(double xmin, double xmax, double ymin, double ymax,
107  double znear, double zfar);
108 
115  void Frustum(double xmin, double xmax, double ymin, double ymax,
116  double znear, double zfar);
117 
124  void Perspective(double angle, double aspect, double znear, double zfar);
125 
139  void Shear(double dxdz, double dydz, double zplane);
140 
151  void Stereo(double angle, double focaldistance);
152 
158  void SetupCamera(const double position[3], const double focalpoint[3],
159  const double viewup[3]);
160 
161  void SetupCamera(double p0, double p1, double p2,
162  double fp0, double fp1, double fp2,
163  double vup0, double vup1, double vup2);
164 
166 
170  void Translate(double x, double y, double z) {
171  this->Concatenation->Translate(x,y,z); };
172  void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); };
173  void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); };
175 
177 
183  void RotateWXYZ(double angle, double x, double y, double z) {
184  this->Concatenation->Rotate(angle,x,y,z); };
185  void RotateWXYZ(double angle, const double axis[3]) {
186  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
187  void RotateWXYZ(double angle, const float axis[3]) {
188  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
190 
192 
197  void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); };
198  void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); };
199  void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); };
201 
203 
208  void Scale(double x, double y, double z) {
209  this->Concatenation->Scale(x,y,z); };
210  void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); };
211  void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); };
213 
215 
219  void SetMatrix(vtkMatrix4x4 *matrix) {
220  this->SetMatrix(*matrix->Element); };
221  void SetMatrix(const double elements[16]) {
222  this->Identity(); this->Concatenate(elements); };
224 
226 
230  void Concatenate(vtkMatrix4x4 *matrix) {
231  this->Concatenate(*matrix->Element); };
232  void Concatenate(const double elements[16]) {
233  this->Concatenation->Concatenate(elements); };
235 
244 
252  void PreMultiply() {
253  if (this->Concatenation->GetPreMultiplyFlag()) { return; }
254  this->Concatenation->SetPreMultiplyFlag(1); this->Modified(); };
255 
263  void PostMultiply() {
264  if (!this->Concatenation->GetPreMultiplyFlag()) { return; }
265  this->Concatenation->SetPreMultiplyFlag(0); this->Modified(); };
266 
272  return this->Concatenation->GetNumberOfTransforms() +
273  (this->Input == NULL ? 0 : 1); };
274 
276 
284  {
286  if (this->Input == NULL)
287  {
288  t=this->Concatenation->GetTransform(i);
289  }
290  else if (i < this->Concatenation->GetNumberOfPreTransforms())
291  {
292  t=this->Concatenation->GetTransform(i);
293  }
294  else if (i > this->Concatenation->GetNumberOfPreTransforms())
295  {
296  t=this->Concatenation->GetTransform(i-1);
297  }
298  else if (this->GetInverseFlag())
299  {
300  t=this->Input->GetInverse();
301  }
302  else
303  {
304  t=this->Input;
305  }
306  return static_cast<vtkHomogeneousTransform *>(t);
307  }
309 
311 
320  vtkHomogeneousTransform *GetInput() { return this->Input; };
322 
331  return this->Concatenation->GetInverseFlag(); };
332 
334 
337  void Push() { if (this->Stack == NULL) {
338  this->Stack = vtkTransformConcatenationStack::New(); }
339  this->Stack->Push(&this->Concatenation);
340  this->Modified(); };
342 
344 
348  void Pop() { if (this->Stack == NULL) { return; }
349  this->Stack->Pop(&this->Concatenation);
350  this->Modified(); };
352 
358 
367  int CircuitCheck(vtkAbstractTransform *transform) VTK_OVERRIDE;
368 
372  vtkMTimeType GetMTime() VTK_OVERRIDE;
373 
374 protected:
376  ~vtkPerspectiveTransform() VTK_OVERRIDE;
377 
378  void InternalDeepCopy(vtkAbstractTransform *t) VTK_OVERRIDE;
379  void InternalUpdate() VTK_OVERRIDE;
380 
384 
385 private:
386  vtkPerspectiveTransform(const vtkPerspectiveTransform&) VTK_DELETE_FUNCTION;
387  void operator=(const vtkPerspectiveTransform&) VTK_DELETE_FUNCTION;
388 };
389 
390 
391 #endif
vtkPerspectiveTransform::Scale
void Scale(const double s[3])
Definition: vtkPerspectiveTransform.h:210
vtkHomogeneousTransform
superclass for homogeneous transformations
Definition: vtkHomogeneousTransform.h:35
vtkPerspectiveTransform::Perspective
void Perspective(double angle, double aspect, double znear, double zfar)
Create a perspective projection matrix by specifying the view angle (this angle is in the y direction...
vtkPerspectiveTransform::SetMatrix
void SetMatrix(vtkMatrix4x4 *matrix)
Set the current matrix directly.
Definition: vtkPerspectiveTransform.h:219
vtkPerspectiveTransform::Translate
void Translate(double x, double y, double z)
Create a translation matrix and concatenate it with the current transformation according to PreMultip...
Definition: vtkPerspectiveTransform.h:170
vtkAbstractTransform
superclass for all geometric transformations
Definition: vtkAbstractTransform.h:51
vtkPerspectiveTransform::Concatenate
void Concatenate(vtkHomogeneousTransform *transform)
Concatenate the specified transform with the current transformation according to PreMultiply or PostM...
vtkPerspectiveTransform::Scale
void Scale(const float s[3])
Definition: vtkPerspectiveTransform.h:211
vtkMatrix4x4::Element
double Element[4][4]
The internal data is public for historical reasons. Do not use!
Definition: vtkMatrix4x4.h:45
vtkTransformConcatenationStack
Definition: vtkAbstractTransform.h:460
vtkPerspectiveTransform::Concatenate
void Concatenate(vtkMatrix4x4 *matrix)
Concatenates the matrix with the current transformation according to PreMultiply or PostMultiply sema...
Definition: vtkPerspectiveTransform.h:230
vtkPerspectiveTransform::PostMultiply
void PostMultiply()
Sets the internal state of the transform to PostMultiply.
Definition: vtkPerspectiveTransform.h:263
vtkPerspectiveTransform::RotateX
void RotateX(double angle)
Create a rotation matrix about the X, Y, or Z axis and concatenate it with the current transformation...
Definition: vtkPerspectiveTransform.h:197
vtkPerspectiveTransform::PreMultiply
void PreMultiply()
Sets the internal state of the transform to PreMultiply.
Definition: vtkPerspectiveTransform.h:252
vtkObject::Modified
virtual void Modified()
Update the modification time for this object.
vtkPerspectiveTransform::RotateZ
void RotateZ(double angle)
Definition: vtkPerspectiveTransform.h:199
vtkPerspectiveTransform::Inverse
void Inverse() override
Invert the transformation.
Definition: vtkPerspectiveTransform.h:75
vtkPerspectiveTransform::SetMatrix
void SetMatrix(const double elements[16])
Definition: vtkPerspectiveTransform.h:221
vtkPerspectiveTransform::GetNumberOfConcatenatedTransforms
int GetNumberOfConcatenatedTransforms()
Get the total number of transformations that are linked into this one via Concatenate() operations or...
Definition: vtkPerspectiveTransform.h:271
vtkPerspectiveTransform::Push
void Push()
Pushes the current transformation onto the transformation stack.
Definition: vtkPerspectiveTransform.h:337
vtkPerspectiveTransform::RotateWXYZ
void RotateWXYZ(double angle, double x, double y, double z)
Create a rotation matrix and concatenate it with the current transformation according to PreMultiply ...
Definition: vtkPerspectiveTransform.h:183
vtkPerspectiveTransform::Translate
void Translate(const double x[3])
Definition: vtkPerspectiveTransform.h:172
vtkAbstractTransform::GetInverse
vtkAbstractTransform * GetInverse()
Get the inverse of this transform.
vtkPerspectiveTransform::Identity
void Identity()
Set this transformation to the identity transformation.
Definition: vtkPerspectiveTransform.h:68
vtkMTimeType
vtkTypeUInt64 vtkMTimeType
Definition: vtkType.h:248
vtkX3D::position
@ position
Definition: vtkX3D.h:261
vtkPerspectiveTransform::RotateWXYZ
void RotateWXYZ(double angle, const float axis[3])
Definition: vtkPerspectiveTransform.h:187
vtkPerspectiveTransform::GetConcatenatedTransform
vtkHomogeneousTransform * GetConcatenatedTransform(int i)
Get one of the concatenated transformations as a vtkAbstractTransform.
Definition: vtkPerspectiveTransform.h:283
vtkPerspectiveTransform::RotateY
void RotateY(double angle)
Definition: vtkPerspectiveTransform.h:198
vtkPerspectiveTransform::AdjustViewport
void AdjustViewport(double oldXMin, double oldXMax, double oldYMin, double oldYMax, double newXMin, double newXMax, double newYMin, double newYMax)
Perform an adjustment to the viewport coordinates.
vtkPerspectiveTransform::SetInput
void SetInput(vtkHomogeneousTransform *input)
Set the input for this transformation.
vtkHomogeneousTransform.h
vtkMatrix4x4.h
vtkPerspectiveTransform::Translate
void Translate(const float x[3])
Definition: vtkPerspectiveTransform.h:173
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:42
vtkPerspectiveTransform::Ortho
void Ortho(double xmin, double xmax, double ymin, double ymax, double znear, double zfar)
Create an orthogonal projection matrix and concatenate it by the current transformation.
vtkPerspectiveTransform::GetInput
vtkHomogeneousTransform * GetInput()
Definition: vtkPerspectiveTransform.h:320
vtkPerspectiveTransform::Concatenate
void Concatenate(const double elements[16])
Definition: vtkPerspectiveTransform.h:232
vtkPerspectiveTransform::Shear
void Shear(double dxdz, double dydz, double zplane)
Create a shear transformation about a plane at distance z from the camera.
vtkTransformConcatenationStack::New
static vtkTransformConcatenationStack * New()
Definition: vtkAbstractTransform.h:462
vtkPerspectiveTransform
describes a 4x4 matrix transformation
Definition: vtkPerspectiveTransform.h:57
vtkPerspectiveTransform::RotateWXYZ
void RotateWXYZ(double angle, const double axis[3])
Definition: vtkPerspectiveTransform.h:185
vtkPerspectiveTransform::Scale
void Scale(double x, double y, double z)
Create a scale matrix (i.e.
Definition: vtkPerspectiveTransform.h:208
vtkPerspectiveTransform::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkPerspectiveTransform::New
static vtkPerspectiveTransform * New()
vtkPerspectiveTransform::Stereo
void Stereo(double angle, double focaldistance)
Create a stereo shear matrix and concatenate it with the current transformation.
vtkPerspectiveTransform::SetupCamera
void SetupCamera(double p0, double p1, double p2, double fp0, double fp1, double fp2, double vup0, double vup1, double vup2)
vtkPerspectiveTransform::MakeTransform
vtkAbstractTransform * MakeTransform() override
Make a new transform of the same type – you are responsible for deleting the transform when you are d...
vtkPerspectiveTransform::Frustum
void Frustum(double xmin, double xmax, double ymin, double ymax, double znear, double zfar)
Create an perspective projection matrix and concatenate it by the current transformation.
vtkPerspectiveTransform::SetupCamera
void SetupCamera(const double position[3], const double focalpoint[3], const double viewup[3])
Set a view transformation matrix for the camera (this matrix does not contain any perspective) and co...
vtkPerspectiveTransform::GetInverseFlag
int GetInverseFlag()
Get the inverse flag of the transformation.
Definition: vtkPerspectiveTransform.h:330
vtkTransformConcatenation
Definition: vtkAbstractTransform.h:356
vtkPerspectiveTransform::AdjustZBuffer
void AdjustZBuffer(double oldNearZ, double oldFarZ, double newNearZ, double newFarZ)
Perform an adjustment to the Z-Buffer range that the near and far clipping planes map to.
vtkPerspectiveTransform::Pop
void Pop()
Deletes the transformation on the top of the stack and sets the top to the next transformation on the...
Definition: vtkPerspectiveTransform.h:348