1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkPlaneSource.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   vtkPlaneSource
17  * @brief   create an array of quadrilaterals located in a plane
18  *
19  * vtkPlaneSource creates an m x n array of quadrilaterals arranged as
20  * a regular tiling in a plane. The plane is defined by specifying an
21  * origin point, and then two other points that, together with the
22  * origin, define two axes for the plane. These axes do not have to be
23  * orthogonal - so you can create a parallelogram. (The axes must not
24  * be parallel.) The resolution of the plane (i.e., number of subdivisions) is
25  * controlled by the ivars XResolution and YResolution.
26  *
27  * By default, the plane is centered at the origin and perpendicular to the
28  * z-axis, with width and height of length 1 and resolutions set to 1.
29  *
30  * There are three convenience methods that allow you to easily move the
31  * plane.  The first, SetNormal(), allows you to specify the plane
32  * normal. The effect of this method is to rotate the plane around the center
33  * of the plane, aligning the plane normal with the specified normal. The
34  * rotation is about the axis defined by the cross product of the current
35  * normal with the new normal. The second, SetCenter(), translates the center
36  * of the plane to the specified center point. The third method, Push(),
37  * allows you to translate the plane along the plane normal by the distance
38  * specified. (Negative Push values translate the plane in the negative
39  * normal direction.)  Note that the SetNormal(), SetCenter() and Push()
40  * methods modify the Origin, Point1, and/or Point2 instance variables.
41  *
42  * @warning
43  * The normal to the plane will point in the direction of the cross product
44  * of the first axis (Origin->Point1) with the second (Origin->Point2). This
45  * also affects the normals to the generated polygons.
46 */
47 
48 #ifndef vtkPlaneSource_h
49 #define vtkPlaneSource_h
50 
51 #include "vtkFiltersSourcesModule.h" // For export macro
52 #include "vtkPolyDataAlgorithm.h"
53 
54 class VTKFILTERSSOURCES_EXPORT vtkPlaneSource : public vtkPolyDataAlgorithm
55 {
56 public:
57   void PrintSelf(ostream& os, vtkIndent indent) override;
58   vtkTypeMacro(vtkPlaneSource,vtkPolyDataAlgorithm);
59 
60   /**
61    * Construct plane perpendicular to z-axis, resolution 1x1, width
62    * and height 1.0, and centered at the origin.
63    */
64   static vtkPlaneSource *New();
65 
66   //@{
67   /**
68    * Specify the resolution of the plane along the first axes.
69    */
70   vtkSetMacro(XResolution,int);
71   vtkGetMacro(XResolution,int);
72   //@}
73 
74   //@{
75   /**
76    * Specify the resolution of the plane along the second axes.
77    */
78   vtkSetMacro(YResolution,int);
79   vtkGetMacro(YResolution,int);
80   //@}
81 
82   //@{
83   /**
84    * Set the number of x-y subdivisions in the plane.
85    */
86   void SetResolution(const int xR, const int yR);
GetResolution(int & xR,int & yR)87   void GetResolution(int& xR,int& yR) {
88     xR=this->XResolution; yR=this->YResolution;};
89   //@}
90 
91   //@{
92   /**
93    * Specify a point defining the origin of the plane.
94    */
95   vtkSetVector3Macro(Origin,double);
96   vtkGetVectorMacro(Origin,double,3);
97   //@}
98 
99   //@{
100   /**
101    * Specify a point defining the first axis of the plane.
102    */
103   void SetPoint1(double x, double y, double z);
104   void SetPoint1(double pnt[3]);
105   vtkGetVectorMacro(Point1,double,3);
106   //@}
107 
108   //@{
109   /**
110    * Specify a point defining the second axis of the plane.
111    */
112   void SetPoint2(double x, double y, double z);
113   void SetPoint2(double pnt[3]);
114   vtkGetVectorMacro(Point2,double,3);
115   //@}
116 
117   //@{
118   /**
119    * Set/Get the center of the plane. Works in conjunction with the plane
120    * normal to position the plane. Don't use this method to define the plane.
121    * Instead, use it to move the plane to a new center point.
122    */
123   void SetCenter(double x, double y, double z);
124   void SetCenter(double center[3]);
125   vtkGetVectorMacro(Center,double,3);
126   //@}
127 
128   //@{
129   /**
130    * Set/Get the plane normal. Works in conjunction with the plane center to
131    * orient the plane. Don't use this method to define the plane. Instead, use
132    * it to rotate the plane around the current center point.
133    */
134   void SetNormal(double nx, double ny, double nz);
135   void SetNormal(double n[3]);
136   vtkGetVectorMacro(Normal,double,3);
137   //@}
138 
139   /**
140    * Translate the plane in the direction of the normal by the
141    * distance specified.  Negative values move the plane in the
142    * opposite direction.
143    */
144   void Push(double distance);
145 
146   //@{
147   /**
148    * Set/get the desired precision for the output points.
149    * vtkAlgorithm::SINGLE_PRECISION - Output single-precision floating point.
150    * vtkAlgorithm::DOUBLE_PRECISION - Output double-precision floating point.
151    */
152   vtkSetMacro(OutputPointsPrecision,int);
153   vtkGetMacro(OutputPointsPrecision,int);
154   //@}
155 
156 protected:
157   vtkPlaneSource();
~vtkPlaneSource()158   ~vtkPlaneSource() override {}
159 
160   int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override;
161 
162   int XResolution;
163   int YResolution;
164   double Origin[3];
165   double Point1[3];
166   double Point2[3];
167   double Normal[3];
168   double Center[3];
169   int OutputPointsPrecision;
170 
171   int UpdatePlane(double v1[3], double v2[3]);
172 private:
173   vtkPlaneSource(const vtkPlaneSource&) = delete;
174   void operator=(const vtkPlaneSource&) = delete;
175 };
176 
177 #endif
178