1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkAngularPeriodicDataArray.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 /**
17  * @class   vtkAngularPeriodicDataArray
18  * @brief   Map native an Array into an angulat
19  * periodic array
20  *
21  *
22  * Map an array into a periodic array. Data from the original array are
23  * rotated (on the fly) by the specified angle along the specified axis
24  * around the specified point. Lookup is not implemented.
25  * Creating the array is virtually free, accessing a tuple require some
26  * computation.
27  */
28 
29 #ifndef vtkAngularPeriodicDataArray_h
30 #define vtkAngularPeriodicDataArray_h
31 
32 #include "vtkPeriodicDataArray.h" // Parent
33 
34 #define VTK_PERIODIC_ARRAY_AXIS_X 0
35 #define VTK_PERIODIC_ARRAY_AXIS_Y 1
36 #define VTK_PERIODIC_ARRAY_AXIS_Z 2
37 
38 class vtkMatrix3x3;
39 
40 template <class Scalar>
41 class vtkAngularPeriodicDataArray : public vtkPeriodicDataArray<Scalar>
42 {
43 public:
44   vtkAbstractTemplateTypeMacro(vtkAngularPeriodicDataArray<Scalar>, vtkPeriodicDataArray<Scalar>);
45   vtkAOSArrayNewInstanceMacro(vtkAngularPeriodicDataArray<Scalar>);
46   static vtkAngularPeriodicDataArray* New();
47   void PrintSelf(ostream& os, vtkIndent indent) override;
48 
49   /**
50    * Initialize the mapped array with the original input data array.
51    */
52   void InitializeArray(vtkAOSDataArrayTemplate<Scalar>* inputData);
53 
54   ///@{
55   /**
56    * Set/Get the rotation angle in degrees. Default is 0.
57    */
58   void SetAngle(double angle);
59   vtkGetMacro(Angle, double);
60   ///@}
61 
62   ///@{
63   /**
64    * Set/Get the rotation center. Default is 0,0,0.
65    */
66   void SetCenter(double* center);
67   vtkGetVector3Macro(Center, double);
68   ///@}
69 
70   ///@{
71   /**
72    * Set/Get the rotation axis. Default is VTK_PERIODIC_ARRAY_AXIS_X axis.
73    */
74   void SetAxis(int axis);
75   vtkGetMacro(Axis, int);
SetAxisToX(void)76   void SetAxisToX(void) { this->SetAxisType(VTK_PERIODIC_ARRAY_AXIS_X); }
SetAxisToY(void)77   void SetAxisToY(void) { this->SetAxisType(VTK_PERIODIC_ARRAY_AXIS_Y); }
SetAxisToZ(void)78   void SetAxisToZ(void) { this->SetAxisType(VTK_PERIODIC_ARRAY_AXIS_Z); }
79   ///@}
80 
81 protected:
82   vtkAngularPeriodicDataArray();
83   ~vtkAngularPeriodicDataArray() override;
84 
85   /**
86    * Transform the provided tuple
87    */
88   void Transform(Scalar* tuple) const override;
89 
90   /**
91    * Update rotation matrix from Axis, Angle and Center
92    */
93   void UpdateRotationMatrix();
94 
95 private:
96   vtkAngularPeriodicDataArray(const vtkAngularPeriodicDataArray&) = delete;
97   void operator=(const vtkAngularPeriodicDataArray&) = delete;
98 
99   double Angle;          // Rotation angle in degrees
100   double AngleInRadians; // Rotation angle in radians
101   double Center[3];      // Rotation center
102   int Axis;              // Rotation Axis
103 
104   vtkMatrix3x3* RotationMatrix;
105 };
106 
107 #include "vtkAngularPeriodicDataArray.txx"
108 
109 #endif // vtkAngularPeriodicDataArray_h
110 // VTK-HeaderTest-Exclude: vtkAngularPeriodicDataArray.h
111