VTK-m  2.0
ShiftScaleToRGB.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 #ifndef vtk_m_worklet_colorconversion_ShiftScaleToRGB_h
11 #define vtk_m_worklet_colorconversion_ShiftScaleToRGB_h
12 
14 
15 #include <vtkm/Math.h>
16 
17 namespace vtkm
18 {
19 namespace worklet
20 {
21 namespace colorconversion
22 {
23 
25 {
26  using ControlSignature = void(FieldIn in, FieldOut out);
27  using ExecutionSignature = _2(_1);
28 
30  : Shift(shift)
31  , Scale(scale)
32  {
33  }
34 
35  template <typename T>
36  VTKM_EXEC vtkm::Vec3ui_8 operator()(const T& in) const
37  { //vtkScalarsToColorsLuminanceToRGB
38  vtkm::Float32 l = (static_cast<vtkm::Float32>(in) + this->Shift) * this->Scale;
40  return vtkm::Vec3ui_8{ static_cast<vtkm::UInt8>(l + 0.5f) };
41  }
42 
43  template <typename T>
45  { //vtkScalarsToColorsLuminanceAlphaToRGB (which actually doesn't exist in vtk)
46  return this->operator()(in[0]);
47  }
48 
49  template <typename T>
51  { //vtkScalarsToColorsRGBToRGB
52  vtkm::Vec3f_32 rgb(in);
53  rgb = (rgb + vtkm::Vec3f_32(this->Shift)) * this->Scale;
55  return vtkm::Vec3ui_8{ static_cast<vtkm::UInt8>(rgb[0] + 0.5f),
56  static_cast<vtkm::UInt8>(rgb[1] + 0.5f),
57  static_cast<vtkm::UInt8>(rgb[2] + 0.5f) };
58  }
59 
60  template <typename T>
62  { //vtkScalarsToColorsRGBAToRGB
63  return this->operator()(vtkm::Vec<T, 3>{ in[0], in[1], in[2] });
64  }
65 
66 private:
69 };
70 }
71 }
72 }
73 #endif
vtkm::worklet::colorconversion::ShiftScaleToRGB
Definition: ShiftScaleToRGB.h:24
vtkm::worklet::colorconversion::ShiftScaleToRGB::operator()
VTKM_EXEC vtkm::Vec3ui_8 operator()(const T &in) const
Definition: ShiftScaleToRGB.h:36
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::worklet::colorconversion::ShiftScaleToRGB::operator()
VTKM_EXEC vtkm::Vec3ui_8 operator()(const vtkm::Vec< T, 3 > &in) const
Definition: ShiftScaleToRGB.h:50
vtkm::worklet::WorkletMapField::FieldOut
A control signature tag for output fields.
Definition: WorkletMapField.h:60
vtkm::Vec3f_32
vtkm::Vec< vtkm::Float32, 3 > Vec3f_32
Vec3f_32 corresponds to a 3-dimensional vector of 32-bit floating point values.
Definition: Types.h:1020
Conversions.h
vtkm::worklet::colorconversion::ShiftScaleToRGB::ExecutionSignature
_2(_1) ExecutionSignature
Definition: ShiftScaleToRGB.h:27
vtkm::worklet::colorconversion::ShiftScaleToRGB::Shift
const vtkm::Float32 Shift
Definition: ShiftScaleToRGB.h:67
vtkm::worklet::colorconversion::ShiftScaleToRGB::ControlSignature
void(FieldIn in, FieldOut out) ControlSignature
Definition: ShiftScaleToRGB.h:26
vtkm::Vec< T, 4 >
Definition: Types.h:1093
Math.h
vtkm::worklet::WorkletMapField::FieldIn
A control signature tag for input fields.
Definition: WorkletMapField.h:49
vtkm::worklet::colorconversion::ShiftScaleToRGB::Scale
const vtkm::Float32 Scale
Definition: ShiftScaleToRGB.h:68
vtkm::worklet::colorconversion::ShiftScaleToRGB::operator()
VTKM_EXEC vtkm::Vec3ui_8 operator()(const vtkm::Vec< T, 2 > &in) const
Definition: ShiftScaleToRGB.h:44
vtkm::Vec< T, 2 >
Definition: Types.h:859
vtkm::worklet::colorconversion::ShiftScaleToRGB::operator()
VTKM_EXEC vtkm::Vec3ui_8 operator()(const vtkm::Vec< T, 4 > &in) const
Definition: ShiftScaleToRGB.h:61
vtkm::UInt8
uint8_t UInt8
Definition: Types.h:157
vtkm::Vec< T, 3 >
Definition: Types.h:975
vtkm::Vec< vtkm::UInt8, 3 >
vtkm::Float32
float Float32
Definition: Types.h:154
vtkm::worklet::colorconversion::ShiftScaleToRGB::ShiftScaleToRGB
ShiftScaleToRGB(vtkm::Float32 shift, vtkm::Float32 scale)
Definition: ShiftScaleToRGB.h:29
vtkm::worklet::WorkletMapField
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:38
vtkm::worklet::colorconversion::Clamp
VTKM_EXEC void Clamp(vtkm::Float32 &val)
Definition: Conversions.h:39