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