1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkTextureMapToPlane.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   vtkTextureMapToPlane
17  * @brief   generate texture coordinates by mapping points to plane
18  *
19  * vtkTextureMapToPlane is a filter that generates 2D texture coordinates
20  * by mapping input dataset points onto a plane. The plane can either be
21  * user specified or generated automatically. (A least squares method is
22  * used to generate the plane automatically.)
23  *
24  * There are two ways you can specify the plane. The first is to provide a
25  * plane normal. In this case the points are projected to a plane, and the
26  * points are then mapped into the user specified s-t coordinate range. For
27  * more control, you can specify a plane with three points: an origin and two
28  * points defining the two axes of the plane. (This is compatible with the
29  * vtkPlaneSource.) Using the second method, the SRange and TRange vectors
30  * are ignored, since the presumption is that the user does not want to scale
31  * the texture coordinates; and you can adjust the origin and axes points to
32  * achieve the texture coordinate scaling you need. Note also that using the
33  * three point method the axes do not have to be orthogonal.
34  *
35  * @sa
36  *  vtkPlaneSource vtkTextureMapToCylinder
37  * vtkTextureMapToSphere vtkThresholdTextureCoords
38  */
39 
40 #ifndef vtkTextureMapToPlane_h
41 #define vtkTextureMapToPlane_h
42 
43 #include "vtkDataSetAlgorithm.h"
44 #include "vtkFiltersTextureModule.h" // For export macro
45 
46 class VTKFILTERSTEXTURE_EXPORT vtkTextureMapToPlane : public vtkDataSetAlgorithm
47 {
48 public:
49   vtkTypeMacro(vtkTextureMapToPlane, vtkDataSetAlgorithm);
50   void PrintSelf(ostream& os, vtkIndent indent) override;
51 
52   /**
53    * Construct with s,t range=(0,1) and automatic plane generation turned on.
54    */
55   static vtkTextureMapToPlane* New();
56 
57   ///@{
58   /**
59    * Specify a point defining the origin of the plane. Used in conjunction with
60    * the Point1 and Point2 ivars to specify a map plane.
61    */
62   vtkSetVector3Macro(Origin, double);
63   vtkGetVectorMacro(Origin, double, 3);
64   ///@}
65 
66   ///@{
67   /**
68    * Specify a point defining the first axis of the plane.
69    */
70   vtkSetVector3Macro(Point1, double);
71   vtkGetVectorMacro(Point1, double, 3);
72   ///@}
73 
74   ///@{
75   /**
76    * Specify a point defining the second axis of the plane.
77    */
78   vtkSetVector3Macro(Point2, double);
79   vtkGetVectorMacro(Point2, double, 3);
80   ///@}
81 
82   ///@{
83   /**
84    * Specify plane normal. An alternative way to specify a map plane. Using
85    * this method, the object will scale the resulting texture coordinate
86    * between the SRange and TRange specified.
87    */
88   vtkSetVector3Macro(Normal, double);
89   vtkGetVectorMacro(Normal, double, 3);
90   ///@}
91 
92   ///@{
93   /**
94    * Specify s-coordinate range for texture s-t coordinate pair.
95    */
96   vtkSetVector2Macro(SRange, double);
97   vtkGetVectorMacro(SRange, double, 2);
98   ///@}
99 
100   ///@{
101   /**
102    * Specify t-coordinate range for texture s-t coordinate pair.
103    */
104   vtkSetVector2Macro(TRange, double);
105   vtkGetVectorMacro(TRange, double, 2);
106   ///@}
107 
108   ///@{
109   /**
110    * Turn on/off automatic plane generation.
111    */
112   vtkSetMacro(AutomaticPlaneGeneration, vtkTypeBool);
113   vtkGetMacro(AutomaticPlaneGeneration, vtkTypeBool);
114   vtkBooleanMacro(AutomaticPlaneGeneration, vtkTypeBool);
115   ///@}
116 
117 protected:
118   vtkTextureMapToPlane();
119   ~vtkTextureMapToPlane() override = default;
120 
121   int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
122   void ComputeNormal(vtkDataSet* output);
123 
124   double Origin[3];
125   double Point1[3];
126   double Point2[3];
127   double Normal[3];
128   double SRange[2];
129   double TRange[2];
130   vtkTypeBool AutomaticPlaneGeneration;
131 
132 private:
133   vtkTextureMapToPlane(const vtkTextureMapToPlane&) = delete;
134   void operator=(const vtkTextureMapToPlane&) = delete;
135 };
136 
137 #endif
138