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 
45 #ifndef vtkPerspectiveTransform_h
46 #define vtkPerspectiveTransform_h
47 
48 #include "vtkCommonTransformsModule.h" // For export macro
50 
51 #include "vtkMatrix4x4.h" // Needed for inline methods
52 
53 class VTKCOMMONTRANSFORMS_EXPORT vtkPerspectiveTransform : public vtkHomogeneousTransform
54 {
55  public:
56  static vtkPerspectiveTransform *New();
58  void PrintSelf(ostream& os, vtkIndent indent) override;
59 
65  void Identity() { this->Concatenation->Identity(); this->Modified(); };
66 
72  void Inverse() override
73  { this->Concatenation->Inverse(); this->Modified(); };
74 
83  void AdjustViewport(double oldXMin, double oldXMax,
84  double oldYMin, double oldYMax,
85  double newXMin, double newXMax,
86  double newYMin, double newYMax);
87 
95  void AdjustZBuffer(double oldNearZ, double oldFarZ,
96  double newNearZ, double newFarZ);
97 
103  void Ortho(double xmin, double xmax, double ymin, double ymax,
104  double znear, double zfar);
105 
112  void Frustum(double xmin, double xmax, double ymin, double ymax,
113  double znear, double zfar);
114 
121  void Perspective(double angle, double aspect, double znear, double zfar);
122 
136  void Shear(double dxdz, double dydz, double zplane);
137 
148  void Stereo(double angle, double focaldistance);
149 
155  void SetupCamera(const double position[3], const double focalpoint[3],
156  const double viewup[3]);
157 
158  void SetupCamera(double p0, double p1, double p2,
159  double fp0, double fp1, double fp2,
160  double vup0, double vup1, double vup2);
161 
163 
167  void Translate(double x, double y, double z) {
168  this->Concatenation->Translate(x,y,z); };
169  void Translate(const double x[3]) { this->Translate(x[0], x[1], x[2]); };
170  void Translate(const float x[3]) { this->Translate(x[0], x[1], x[2]); };
172 
174 
180  void RotateWXYZ(double angle, double x, double y, double z) {
181  this->Concatenation->Rotate(angle,x,y,z); };
182  void RotateWXYZ(double angle, const double axis[3]) {
183  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
184  void RotateWXYZ(double angle, const float axis[3]) {
185  this->RotateWXYZ(angle, axis[0], axis[1], axis[2]); };
187 
189 
194  void RotateX(double angle) { this->RotateWXYZ(angle, 1, 0, 0); };
195  void RotateY(double angle) { this->RotateWXYZ(angle, 0, 1, 0); };
196  void RotateZ(double angle) { this->RotateWXYZ(angle, 0, 0, 1); };
198 
200 
205  void Scale(double x, double y, double z) {
206  this->Concatenation->Scale(x,y,z); };
207  void Scale(const double s[3]) { this->Scale(s[0], s[1], s[2]); };
208  void Scale(const float s[3]) { this->Scale(s[0], s[1], s[2]); };
210 
212 
216  void SetMatrix(vtkMatrix4x4 *matrix) {
217  this->SetMatrix(*matrix->Element); };
218  void SetMatrix(const double elements[16]) {
219  this->Identity(); this->Concatenate(elements); };
221 
223 
227  void Concatenate(vtkMatrix4x4 *matrix) {
228  this->Concatenate(*matrix->Element); };
229  void Concatenate(const double elements[16]) {
230  this->Concatenation->Concatenate(elements); };
232 
240  void Concatenate(vtkHomogeneousTransform *transform);
241 
249  void PreMultiply() {
250  if (this->Concatenation->GetPreMultiplyFlag()) { return; }
251  this->Concatenation->SetPreMultiplyFlag(1); this->Modified(); };
252 
260  void PostMultiply() {
261  if (!this->Concatenation->GetPreMultiplyFlag()) { return; }
262  this->Concatenation->SetPreMultiplyFlag(0); this->Modified(); };
263 
269  return this->Concatenation->GetNumberOfTransforms() +
270  (this->Input == nullptr ? 0 : 1); };
271 
273 
281  {
283  if (this->Input == nullptr)
284  {
285  t=this->Concatenation->GetTransform(i);
286  }
287  else if (i < this->Concatenation->GetNumberOfPreTransforms())
288  {
289  t=this->Concatenation->GetTransform(i);
290  }
291  else if (i > this->Concatenation->GetNumberOfPreTransforms())
292  {
293  t=this->Concatenation->GetTransform(i-1);
294  }
295  else if (this->GetInverseFlag())
296  {
297  t=this->Input->GetInverse();
298  }
299  else
300  {
301  t=this->Input;
302  }
303  return static_cast<vtkHomogeneousTransform *>(t);
304  }
306 
308 
316  void SetInput(vtkHomogeneousTransform *input);
317  vtkHomogeneousTransform *GetInput() { return this->Input; };
319 
328  return this->Concatenation->GetInverseFlag(); };
329 
331 
334  void Push() { if (this->Stack == nullptr) {
335  this->Stack = vtkTransformConcatenationStack::New(); }
336  this->Stack->Push(&this->Concatenation);
337  this->Modified(); };
339 
341 
345  void Pop() { if (this->Stack == nullptr) { return; }
346  this->Stack->Pop(&this->Concatenation);
347  this->Modified(); };
349 
355 
364  int CircuitCheck(vtkAbstractTransform *transform) override;
365 
369  vtkMTimeType GetMTime() override;
370 
371 protected:
373  ~vtkPerspectiveTransform() override;
374 
375  void InternalDeepCopy(vtkAbstractTransform *t) override;
376  void InternalUpdate() override;
377 
381 
382 private:
384  void operator=(const vtkPerspectiveTransform&) = delete;
385 };
386 
387 
388 #endif
vtkPerspectiveTransform::Scale
void Scale(const double s[3])
Definition: vtkPerspectiveTransform.h:207
vtkHomogeneousTransform
superclass for homogeneous transformations
Definition: vtkHomogeneousTransform.h:34
vtkPerspectiveTransform::SetMatrix
void SetMatrix(vtkMatrix4x4 *matrix)
Set the current matrix directly.
Definition: vtkPerspectiveTransform.h:216
vtkAbstractTransform::CircuitCheck
virtual int CircuitCheck(vtkAbstractTransform *transform)
Check for self-reference.
vtkHomogeneousTransform::InternalDeepCopy
void InternalDeepCopy(vtkAbstractTransform *transform) override
Perform any subclass-specific DeepCopy.
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:167
vtkAbstractTransform
superclass for all geometric transformations
Definition: vtkAbstractTransform.h:50
vtkPerspectiveTransform::Scale
void Scale(const float s[3])
Definition: vtkPerspectiveTransform.h:208
vtkMatrix4x4::Element
double Element[4][4]
The internal data is public for historical reasons. Do not use!
Definition: vtkMatrix4x4.h:39
vtkTransformConcatenationStack
Definition: vtkAbstractTransform.h:503
vtkPerspectiveTransform::Concatenate
void Concatenate(vtkMatrix4x4 *matrix)
Concatenates the matrix with the current transformation according to PreMultiply or PostMultiply sema...
Definition: vtkPerspectiveTransform.h:227
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkAbstractTransform::InternalUpdate
virtual void InternalUpdate()
Perform any subclass-specific Update.
Definition: vtkAbstractTransform.h:337
vtkPerspectiveTransform::PostMultiply
void PostMultiply()
Sets the internal state of the transform to PostMultiply.
Definition: vtkPerspectiveTransform.h:260
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:194
vtkPerspectiveTransform::PreMultiply
void PreMultiply()
Sets the internal state of the transform to PreMultiply.
Definition: vtkPerspectiveTransform.h:249
vtkObject::Modified
virtual void Modified()
Update the modification time for this object.
vtkPerspectiveTransform::RotateZ
void RotateZ(double angle)
Definition: vtkPerspectiveTransform.h:196
vtkPerspectiveTransform::Inverse
void Inverse() override
Invert the transformation.
Definition: vtkPerspectiveTransform.h:72
vtkPerspectiveTransform::Input
vtkHomogeneousTransform * Input
Definition: vtkPerspectiveTransform.h:378
vtkPerspectiveTransform::SetMatrix
void SetMatrix(const double elements[16])
Definition: vtkPerspectiveTransform.h:218
vtkPerspectiveTransform::GetNumberOfConcatenatedTransforms
int GetNumberOfConcatenatedTransforms()
Get the total number of transformations that are linked into this one via Concatenate() operations or...
Definition: vtkPerspectiveTransform.h:268
vtkPerspectiveTransform::Push
void Push()
Pushes the current transformation onto the transformation stack.
Definition: vtkPerspectiveTransform.h:334
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:180
vtkPerspectiveTransform::Translate
void Translate(const double x[3])
Definition: vtkPerspectiveTransform.h:169
vtkAbstractTransform::GetInverse
vtkAbstractTransform * GetInverse()
Get the inverse of this transform.
vtkPerspectiveTransform::Identity
void Identity()
Set this transformation to the identity transformation.
Definition: vtkPerspectiveTransform.h:65
vtkX3D::position
Definition: vtkX3D.h:261
vtkPerspectiveTransform::RotateWXYZ
void RotateWXYZ(double angle, const float axis[3])
Definition: vtkPerspectiveTransform.h:184
vtkPerspectiveTransform::GetConcatenatedTransform
vtkHomogeneousTransform * GetConcatenatedTransform(int i)
Get one of the concatenated transformations as a vtkAbstractTransform.
Definition: vtkPerspectiveTransform.h:280
vtkPerspectiveTransform::RotateY
void RotateY(double angle)
Definition: vtkPerspectiveTransform.h:195
vtkHomogeneousTransform.h
vtkMatrix4x4.h
vtkPerspectiveTransform::Translate
void Translate(const float x[3])
Definition: vtkPerspectiveTransform.h:170
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
vtkAbstractTransform::GetMTime
vtkMTimeType GetMTime() override
Override GetMTime necessary because of inverse transforms.
vtkPerspectiveTransform::GetInput
vtkHomogeneousTransform * GetInput()
Definition: vtkPerspectiveTransform.h:317
vtkPerspectiveTransform::Concatenate
void Concatenate(const double elements[16])
Definition: vtkPerspectiveTransform.h:229
vtkPerspectiveTransform::Concatenation
vtkTransformConcatenation * Concatenation
Definition: vtkPerspectiveTransform.h:379
vtkTransformConcatenationStack::New
static vtkTransformConcatenationStack * New()
Definition: vtkAbstractTransform.h:506
vtkPerspectiveTransform
describes a 4x4 matrix transformation
Definition: vtkPerspectiveTransform.h:53
vtkPerspectiveTransform::RotateWXYZ
void RotateWXYZ(double angle, const double axis[3])
Definition: vtkPerspectiveTransform.h:182
vtkPerspectiveTransform::Scale
void Scale(double x, double y, double z)
Create a scale matrix (i.e.
Definition: vtkPerspectiveTransform.h:205
vtkPerspectiveTransform::Stack
vtkTransformConcatenationStack * Stack
Definition: vtkPerspectiveTransform.h:380
vtkHomogeneousTransform::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkPerspectiveTransform::GetInverseFlag
int GetInverseFlag()
Get the inverse flag of the transformation.
Definition: vtkPerspectiveTransform.h:327
vtkTransformConcatenation
Definition: vtkAbstractTransform.h:394
vtkAbstractTransform::MakeTransform
virtual vtkAbstractTransform * MakeTransform()=0
Make another transform of the same type.
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:302
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:345