1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkTransformTextureCoords.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 /**
16  * @class   vtkTransformTextureCoords
17  * @brief   transform (scale, rotate, translate) texture coordinates
18  *
19  * vtkTransformTextureCoords is a filter that operates on texture
20  * coordinates. It ingests any type of dataset, and outputs a dataset of the
21  * same type. The filter lets you scale, translate, and rotate texture
22  * coordinates. For example, by using the Scale ivar, you can shift
23  * texture coordinates that range from (0->1) to range from (0->10) (useful
24  * for repeated patterns).
25  *
26  * The filter operates on texture coordinates of dimension 1->3. The texture
27  * coordinates are referred to as r-s-t. If the texture map is two dimensional,
28  * the t-coordinate (and operations on the t-coordinate) are ignored.
29  *
30  * @sa
31  * vtkTextureMapToPlane  vtkTextureMapToCylinder
32  * vtkTextureMapToSphere vtkThresholdTextureCoords vtkTexture
33 */
34 
35 #ifndef vtkTransformTextureCoords_h
36 #define vtkTransformTextureCoords_h
37 
38 #include "vtkFiltersTextureModule.h" // For export macro
39 #include "vtkDataSetAlgorithm.h"
40 
41 class VTKFILTERSTEXTURE_EXPORT vtkTransformTextureCoords : public vtkDataSetAlgorithm
42 {
43 public:
44   vtkTypeMacro(vtkTransformTextureCoords,vtkDataSetAlgorithm);
45   void PrintSelf(ostream& os, vtkIndent indent) override;
46 
47   /**
48    * Create instance with Origin (0.5,0.5,0.5); Position (0,0,0); and Scale
49    * set to (1,1,1). Rotation of the texture coordinates is turned off.
50    */
51   static vtkTransformTextureCoords *New();
52 
53   //@{
54   /**
55    * Set/Get the position of the texture map. Setting the position translates
56    * the texture map by the amount specified.
57    */
58   vtkSetVector3Macro(Position,double);
59   vtkGetVectorMacro(Position,double,3);
60   //@}
61 
62   //@{
63   /**
64    * Incrementally change the position of the texture map (i.e., does a
65    * translate or shift of the texture coordinates).
66    */
67   void AddPosition(double deltaR, double deltaS, double deltaT);
68   void AddPosition(double deltaPosition[3]);
69   //@}
70 
71   //@{
72   /**
73    * Set/Get the scale of the texture map. Scaling in performed independently
74    * on the r, s and t axes.
75    */
76   vtkSetVector3Macro(Scale,double);
77   vtkGetVectorMacro(Scale,double,3);
78   //@}
79 
80   //@{
81   /**
82    * Set/Get the origin of the texture map. This is the point about which the
83    * texture map is flipped (e.g., rotated). Since a typical texture map ranges
84    * from (0,1) in the r-s-t coordinates, the default origin is set at
85    * (0.5,0.5,0.5).
86    */
87   vtkSetVector3Macro(Origin,double);
88   vtkGetVectorMacro(Origin,double,3);
89   //@}
90 
91   //@{
92   /**
93    * Boolean indicates whether the texture map should be flipped around the
94    * s-axis. Note that the flips occur around the texture origin.
95    */
96   vtkSetMacro(FlipR,vtkTypeBool);
97   vtkGetMacro(FlipR,vtkTypeBool);
98   vtkBooleanMacro(FlipR,vtkTypeBool);
99   //@}
100 
101   //@{
102   /**
103    * Boolean indicates whether the texture map should be flipped around the
104    * s-axis. Note that the flips occur around the texture origin.
105    */
106   vtkSetMacro(FlipS,vtkTypeBool);
107   vtkGetMacro(FlipS,vtkTypeBool);
108   vtkBooleanMacro(FlipS,vtkTypeBool);
109   //@}
110 
111   //@{
112   /**
113    * Boolean indicates whether the texture map should be flipped around the
114    * t-axis. Note that the flips occur around the texture origin.
115    */
116   vtkSetMacro(FlipT,vtkTypeBool);
117   vtkGetMacro(FlipT,vtkTypeBool);
118   vtkBooleanMacro(FlipT,vtkTypeBool);
119   //@}
120 
121 protected:
122   vtkTransformTextureCoords();
~vtkTransformTextureCoords()123   ~vtkTransformTextureCoords() override {}
124 
125   int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override;
126 
127   double Origin[3]; //point around which map rotates
128   double Position[3]; //controls translation of map
129   double Scale[3]; //scales the texture map
130   vtkTypeBool FlipR; //boolean indicates whether to flip texture around r-axis
131   vtkTypeBool FlipS; //boolean indicates whether to flip texture around s-axis
132   vtkTypeBool FlipT; //boolean indicates whether to flip texture around t-axis
133 private:
134   vtkTransformTextureCoords(const vtkTransformTextureCoords&) = delete;
135   void operator=(const vtkTransformTextureCoords&) = delete;
136 };
137 
138 #endif
139