//============================================================================ // Copyright (c) Kitware, Inc. // All rights reserved. // See LICENSE.txt for details. // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notice for more information. // // Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS). // Copyright 2014 UT-Battelle, LLC. // Copyright 2014 Los Alamos National Security. // // Under the terms of Contract DE-NA0003525 with NTESS, // the U.S. Government retains certain rights in this software. // // Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National // Laboratory (LANL), the U.S. Government retains certain rights in // this software. //============================================================================ #ifndef vtk_m_worklet_PointTransform_h #define vtk_m_worklet_PointTransform_h #include #include #include #include namespace vtkm { namespace worklet { template class PointTransform : public vtkm::worklet::WorkletMapField { public: typedef void ControlSignature(FieldIn, FieldOut); typedef _2 ExecutionSignature(_1); VTKM_CONT PointTransform() {} //Translation template VTKM_CONT void SetTranslation(const S& tx, const S& ty, const S& tz) { matrix = vtkm::Transform3DTranslate(static_cast(tx), static_cast(ty), static_cast(tz)); } template VTKM_CONT void SetTranslation(const vtkm::Vec& v) { SetTranslation(v[0], v[1], v[2]); } //Rotation template VTKM_CONT void SetRotation(const S& angleDegrees, const vtkm::Vec& axis) { matrix = vtkm::Transform3DRotate(angleDegrees, axis); } template VTKM_CONT void SetRotationX(const S& angleDegrees, const S& rx, const S& ry, const S& rz) { SetRotation(angleDegrees, vtkm::Vec(rx, ry, rz)); } template VTKM_CONT void SetRotationX(const S& angleDegrees) { SetRotation(angleDegrees, 1, 0, 0); } template VTKM_CONT void SetRotationY(const S& angleDegrees) { SetRotation(angleDegrees, 0, 1, 0); } template VTKM_CONT void SetRotationZ(const S& angleDegrees) { SetRotation(angleDegrees, 0, 0, 1); } //Scaling template VTKM_CONT void SetScale(const S& s) { matrix = vtkm::Transform3DScale(s, s, s); } template VTKM_CONT void SetScale(const S& sx, const S& sy, const S& sz) { matrix = vtkm::Transform3DScale(static_cast(sx), static_cast(sy), static_cast(sz)); } template VTKM_CONT void SetScale(const vtkm::Vec& v) { matrix = vtkm::Transform3DScale(v[0], v[1], v[2]); } //General transformation VTKM_CONT void SetTransform(const vtkm::Matrix& mtx) { matrix = mtx; } //Functor VTKM_EXEC vtkm::Vec operator()(const vtkm::Vec& vec) const { return vtkm::Transform3DPoint(matrix, vec); } private: vtkm::Matrix matrix; }; } } // namespace vtkm::worklet #endif // vtk_m_worklet_PointTransform_h