VTK-m  2.0
PointTransform.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
10 
11 #ifndef vtk_m_filter_field_transform_PointTransform_h
12 #define vtk_m_filter_field_transform_PointTransform_h
13 
14 #include <vtkm/Matrix.h>
15 #include <vtkm/Transform3D.h>
16 
18 #include <vtkm/filter/field_transform/vtkm_filter_field_transform_export.h>
19 
20 namespace vtkm
21 {
22 namespace filter
23 {
24 namespace field_transform
25 {
29 class VTKM_FILTER_FIELD_TRANSFORM_EXPORT PointTransform : public vtkm::filter::FilterField
30 {
31 public:
32  VTKM_CONT
34 
35  //Translation
37  const vtkm::FloatDefault& ty,
38  const vtkm::FloatDefault& tz)
39  {
40  matrix = vtkm::Transform3DTranslate(tx, ty, tz);
41  }
42 
44  {
45  SetTranslation(v[0], v[1], v[2]);
46  }
47 
48  //Rotation
49  VTKM_CONT void SetRotation(const vtkm::FloatDefault& angleDegrees,
51  {
52  matrix = vtkm::Transform3DRotate(angleDegrees, axis);
53  }
54 
55  VTKM_CONT void SetRotation(const vtkm::FloatDefault& angleDegrees,
56  const vtkm::FloatDefault& rx,
57  const vtkm::FloatDefault& ry,
58  const vtkm::FloatDefault& rz)
59  {
60  SetRotation(angleDegrees, { rx, ry, rz });
61  }
62 
63  VTKM_CONT void SetRotationX(const vtkm::FloatDefault& angleDegrees)
64  {
65  SetRotation(angleDegrees, 1, 0, 0);
66  }
67 
68  VTKM_CONT void SetRotationY(const vtkm::FloatDefault& angleDegrees)
69  {
70  SetRotation(angleDegrees, 0, 1, 0);
71  }
72 
73  VTKM_CONT void SetRotationZ(const vtkm::FloatDefault& angleDegrees)
74  {
75  SetRotation(angleDegrees, 0, 0, 1);
76  }
77 
78  //Scaling
79  VTKM_CONT void SetScale(const vtkm::FloatDefault& s) { matrix = vtkm::Transform3DScale(s, s, s); }
80 
82  const vtkm::FloatDefault& sy,
83  const vtkm::FloatDefault& sz)
84  {
85  matrix = vtkm::Transform3DScale(sx, sy, sz);
86  }
87 
89  {
90  matrix = vtkm::Transform3DScale(v[0], v[1], v[2]);
91  }
92 
93  //General transformation
94  VTKM_CONT
95  void SetTransform(const vtkm::Matrix<vtkm::FloatDefault, 4, 4>& mtx) { matrix = mtx; }
96 
97  void SetChangeCoordinateSystem(bool flag);
98  bool GetChangeCoordinateSystem() const;
99 
100 private:
101  VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override;
102 
104  bool ChangeCoordinateSystem = true;
105 };
106 } // namespace field_transform
107 } // namespace filter
108 } // namespace vtkm
109 
110 #endif // vtk_m_filter_field_transform_PointTransform_h
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::filter::field_transform::PointTransform::SetScale
VTKM_CONT void SetScale(const vtkm::FloatDefault &sx, const vtkm::FloatDefault &sy, const vtkm::FloatDefault &sz)
Definition: PointTransform.h:81
vtkm::Transform3DRotate
VTKM_EXEC_CONT vtkm::Matrix< T, 4, 4 > Transform3DRotate(T angleDegrees, const vtkm::Vec< T, 3 > &axisOfRotation)
Returns a rotation matrix.
Definition: Transform3D.h:144
vtkm::filter::field_transform::PointTransform::SetRotationY
VTKM_CONT void SetRotationY(const vtkm::FloatDefault &angleDegrees)
Definition: PointTransform.h:68
vtkm::filter::field_transform::PointTransform::SetRotation
VTKM_CONT void SetRotation(const vtkm::FloatDefault &angleDegrees, const vtkm::FloatDefault &rx, const vtkm::FloatDefault &ry, const vtkm::FloatDefault &rz)
Definition: PointTransform.h:55
Matrix.h
vtkm::cont::DataSet
Definition: DataSet.h:34
vtkm::filter::field_transform::PointTransform::SetTransform
VTKM_CONT void SetTransform(const vtkm::Matrix< vtkm::FloatDefault, 4, 4 > &mtx)
Definition: PointTransform.h:95
vtkm::Transform3DTranslate
VTKM_EXEC_CONT vtkm::Matrix< T, 4, 4 > Transform3DTranslate(const T &x, const T &y, const T &z)
Returns a translation matrix.
Definition: Transform3D.h:121
FilterField.h
vtkm::filter::FilterField
Definition: FilterField.h:21
vtkm::filter::field_transform::PointTransform::SetRotation
VTKM_CONT void SetRotation(const vtkm::FloatDefault &angleDegrees, const vtkm::Vec< vtkm::FloatDefault, 3 > &axis)
Definition: PointTransform.h:49
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::filter::field_transform::PointTransform::SetTranslation
VTKM_CONT void SetTranslation(const vtkm::Vec< vtkm::FloatDefault, 3 > &v)
Definition: PointTransform.h:43
vtkm::filter::field_transform::PointTransform::SetScale
VTKM_CONT void SetScale(const vtkm::FloatDefault &s)
Definition: PointTransform.h:79
Transform3D.h
vtkm::filter::field_transform::PointTransform::SetTranslation
VTKM_CONT void SetTranslation(const vtkm::FloatDefault &tx, const vtkm::FloatDefault &ty, const vtkm::FloatDefault &tz)
Definition: PointTransform.h:36
vtkm::Vec< vtkm::FloatDefault, 3 >
vtkm::filter::field_transform::PointTransform::matrix
vtkm::Matrix< vtkm::FloatDefault, 4, 4 > matrix
Definition: PointTransform.h:103
vtkm::filter::field_transform::PointTransform::SetRotationZ
VTKM_CONT void SetRotationZ(const vtkm::FloatDefault &angleDegrees)
Definition: PointTransform.h:73
vtkm::Matrix< vtkm::FloatDefault, 4, 4 >
vtkm::FloatDefault
vtkm::Float32 FloatDefault
The floating point type to use when no other precision is specified.
Definition: Types.h:198
vtkm::filter::field_transform::PointTransform::SetRotationX
VTKM_CONT void SetRotationX(const vtkm::FloatDefault &angleDegrees)
Definition: PointTransform.h:63
vtkm::Transform3DScale
VTKM_EXEC_CONT vtkm::Matrix< T, 4, 4 > Transform3DScale(const T &scaleX, const T &scaleY, const T &scaleZ)
Returns a scale matrix.
Definition: Transform3D.h:84
vtkm::filter::field_transform::PointTransform::SetScale
VTKM_CONT void SetScale(const vtkm::Vec< vtkm::FloatDefault, 3 > &v)
Definition: PointTransform.h:88
vtkm::filter::field_transform::PointTransform
Generate scalar field from a dataset.
Definition: PointTransform.h:29