vtkProjectedTexture.h 4.42 KB
Newer Older
1 2
/*=========================================================================

Will Schroeder's avatar
Will Schroeder committed
3 4 5
  Program:   Visualization Toolkit
  Module:    vtkProjectedTexture.h

6
  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 8
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
Will Schroeder's avatar
Will Schroeder committed
9

10 11
     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12
     PURPOSE.  See the above copyright notice for more information.
13 14

=========================================================================*/
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
/**
 * @class   vtkProjectedTexture
 * @brief   assign texture coordinates for a projected texture
 *
 * vtkProjectedTexture assigns texture coordinates to a dataset as if
 * the texture was projected from a slide projected located somewhere in the
 * scene.  Methods are provided to position the projector and aim it at a
 * location, to set the width of the projector's frustum, and to set the
 * range of texture coordinates assigned to the dataset.
 *
 * Objects in the scene that appear behind the projector are also assigned
 * texture coordinates; the projected image is left-right and top-bottom
 * flipped, much as a lens' focus flips the rays of light that pass through
 * it.  A warning is issued if a point in the dataset falls at the focus
 * of the projector.
*/
31

32 33
#ifndef vtkProjectedTexture_h
#define vtkProjectedTexture_h
34

35
#include "vtkFiltersModelingModule.h" // For export macro
36
#include "vtkDataSetAlgorithm.h"
37

38 39 40
#define VTK_PROJECTED_TEXTURE_USE_PINHOLE 0
#define VTK_PROJECTED_TEXTURE_USE_TWO_MIRRORS 1

41
class VTKFILTERSMODELING_EXPORT vtkProjectedTexture : public vtkDataSetAlgorithm
42 43
{
public:
44
  static vtkProjectedTexture *New();
45
  vtkTypeMacro(vtkProjectedTexture,vtkDataSetAlgorithm);
46
  void PrintSelf(ostream& os, vtkIndent indent) override;
47

48 49 50 51
  //@{
  /**
   * Set/Get the position of the focus of the projector.
   */
Ken Martin's avatar
Ken Martin committed
52 53
  vtkSetVector3Macro(Position,double);
  vtkGetVectorMacro(Position,double,3);
54
  //@}
55

56 57 58 59 60
  //@{
  /**
   * Set/Get the focal point of the projector (a point that lies along
   * the center axis of the projector's frustum).
   */
Ken Martin's avatar
Ken Martin committed
61 62 63
  void SetFocalPoint(double focalPoint[3]);
  void SetFocalPoint(double x, double y, double z);
  vtkGetVectorMacro(FocalPoint,double,3);
64
  //@}
65

66 67 68 69 70
  //@{
  /**
   * Set/Get the camera mode of the projection -- pinhole projection or
   * two mirror projection.
   */
71 72 73 74
  vtkSetMacro(CameraMode, int);
  vtkGetMacro(CameraMode, int);
  void SetCameraModeToPinhole() {this->SetCameraMode(VTK_PROJECTED_TEXTURE_USE_PINHOLE);}
  void SetCameraModeToTwoMirror() {this->SetCameraMode(VTK_PROJECTED_TEXTURE_USE_TWO_MIRRORS);}
75
  //@}
76

77 78 79 80
  //@{
  /**
   * Set/Get the mirror separation for the two mirror system.
   */
Ken Martin's avatar
Ken Martin committed
81 82
  vtkSetMacro(MirrorSeparation, double);
  vtkGetMacro(MirrorSeparation, double);
83
  //@}
84

85 86 87 88
  //@{
  /**
   * Get the normalized orientation vector of the projector.
   */
Ken Martin's avatar
Ken Martin committed
89
  vtkGetVectorMacro(Orientation,double,3);
90
  //@}
91

92 93 94 95
  //@{
  /**
   * Set/Get the up vector of the projector.
   */
Ken Martin's avatar
Ken Martin committed
96 97
  vtkSetVector3Macro(Up,double);
  vtkGetVectorMacro(Up,double,3);
98 99 100 101 102 103 104 105 106 107 108 109 110
  //@}

  //@{
  /**
   * Set/Get the aspect ratio of a perpendicular cross-section of the
   * the projector's frustum.  The aspect ratio consists of three
   * numbers:  (x, y, z), where x is the width of the
   * frustum, y is the height, and z is the perpendicular
   * distance from the focus of the projector.

   * For example, if the source of the image is a pinhole camera with
   * view angle A, then you could set x=1, y=1, z=1/tan(A).
   */
Ken Martin's avatar
Ken Martin committed
111 112
  vtkSetVector3Macro(AspectRatio,double);
  vtkGetVectorMacro(AspectRatio,double,3);
113
  //@}
114

115 116 117 118
  //@{
  /**
   * Specify s-coordinate range for texture s-t coordinate pair.
   */
Ken Martin's avatar
Ken Martin committed
119 120
  vtkSetVector2Macro(SRange,double);
  vtkGetVectorMacro(SRange,double,2);
121
  //@}
122

123 124 125 126
  //@{
  /**
   * Specify t-coordinate range for texture s-t coordinate pair.
   */
Ken Martin's avatar
Ken Martin committed
127 128
  vtkSetVector2Macro(TRange,double);
  vtkGetVectorMacro(TRange,double,2);
129
  //@}
130

131
protected:
132
  vtkProjectedTexture();
133
  ~vtkProjectedTexture() override {}
134

135
  int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override;
136 137
  void ComputeNormal();

138 139
  int CameraMode;

Ken Martin's avatar
Ken Martin committed
140 141 142 143 144 145 146 147
  double Position[3];
  double Orientation[3];
  double FocalPoint[3];
  double Up[3];
  double MirrorSeparation;
  double AspectRatio[3];
  double SRange[2];
  double TRange[2];
148
private:
149 150
  vtkProjectedTexture(const vtkProjectedTexture&) = delete;
  void operator=(const vtkProjectedTexture&) = delete;
151 152 153 154
};

#endif