VTK-m  2.0
TransferFunction.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_TransferFunction_h
11 #define vtk_m_worklet_colorconversion_TransferFunction_h
12 
13 #include <vtkm/exec/ColorTable.h>
16 
17 namespace vtkm
18 {
19 namespace worklet
20 {
21 namespace colorconversion
22 {
23 
25 {
26  using ControlSignature = void(FieldIn in, ExecObject colorTable, FieldOut color);
27  using ExecutionSignature = void(_1, _2, _3);
28 
29  template <typename T>
30  VTKM_EXEC void operator()(const T& in,
31  const vtkm::exec::ColorTable& colorTable,
32  vtkm::Vec3ui_8& output) const
33  {
34  vtkm::Vec<float, 3> rgb = colorTable.MapThroughColorSpace(static_cast<double>(in));
35  output[0] = colorconversion::ColorToUChar(rgb[0]);
36  output[1] = colorconversion::ColorToUChar(rgb[1]);
37  output[2] = colorconversion::ColorToUChar(rgb[2]);
38  }
39 
40  template <typename T>
41  VTKM_EXEC void operator()(const T& in,
42  const vtkm::exec::ColorTable& colorTable,
43  vtkm::Vec4ui_8& output) const
44  {
45  vtkm::Vec<float, 3> rgb = colorTable.MapThroughColorSpace(static_cast<double>(in));
46  float alpha = colorTable.MapThroughOpacitySpace(static_cast<double>(in));
47  output[0] = colorconversion::ColorToUChar(rgb[0]);
48  output[1] = colorconversion::ColorToUChar(rgb[1]);
49  output[2] = colorconversion::ColorToUChar(rgb[2]);
50  output[3] = colorconversion::ColorToUChar(alpha);
51  }
52 
53  template <typename T>
54  VTKM_EXEC void operator()(const T& in,
55  const vtkm::exec::ColorTable& colorTable,
56  vtkm::Vec3f_32& output) const
57  {
58  output = colorTable.MapThroughColorSpace(static_cast<double>(in));
59  }
60 
61  template <typename T>
62  VTKM_EXEC void operator()(const T& in,
63  const vtkm::exec::ColorTable& colorTable,
64  vtkm::Vec4f_32& output) const
65  {
66  vtkm::Vec3f_32 rgb = colorTable.MapThroughColorSpace(static_cast<vtkm::Float64>(in));
67  vtkm::Float32 alpha = colorTable.MapThroughOpacitySpace(static_cast<vtkm::Float64>(in));
68  output[0] = rgb[0];
69  output[1] = rgb[1];
70  output[2] = rgb[2];
71  output[3] = alpha;
72  }
73 };
74 }
75 }
76 }
77 #endif
vtkm::worklet::colorconversion::TransferFunction
Definition: TransferFunction.h:24
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::TransferFunction::operator()
VTKM_EXEC void operator()(const T &in, const vtkm::exec::ColorTable &colorTable, vtkm::Vec4ui_8 &output) const
Definition: TransferFunction.h:41
vtkm::worklet::colorconversion::TransferFunction::ExecutionSignature
void(_1, _2, _3) ExecutionSignature
Definition: TransferFunction.h:27
WorkletMapField.h
ColorTable.h
vtkm::worklet::WorkletMapField::FieldOut
A control signature tag for output fields.
Definition: WorkletMapField.h:60
vtkm::worklet::colorconversion::TransferFunction::ControlSignature
void(FieldIn in, ExecObject colorTable, FieldOut color) ControlSignature
Definition: TransferFunction.h:26
Conversions.h
vtkm::worklet::colorconversion::TransferFunction::operator()
VTKM_EXEC void operator()(const T &in, const vtkm::exec::ColorTable &colorTable, vtkm::Vec3f_32 &output) const
Definition: TransferFunction.h:54
vtkm::worklet::colorconversion::TransferFunction::operator()
VTKM_EXEC void operator()(const T &in, const vtkm::exec::ColorTable &colorTable, vtkm::Vec4f_32 &output) const
Definition: TransferFunction.h:62
vtkm::exec::ColorTable::MapThroughColorSpace
VTKM_EXEC vtkm::Vec3f_32 MapThroughColorSpace(vtkm::Float64) const
vtkm::worklet::WorkletMapField::FieldIn
A control signature tag for input fields.
Definition: WorkletMapField.h:49
vtkm::exec::ColorTable
Definition: exec/ColorTable.h:34
vtkm::worklet::colorconversion::ColorToUChar
VTKM_EXEC vtkm::UInt8 ColorToUChar(T t)
Definition: Conversions.h:21
vtkm::Vec< vtkm::UInt8, 3 >
vtkm::Float32
float Float32
Definition: Types.h:154
vtkm::Float64
double Float64
Definition: Types.h:155
vtkm::exec::ColorTable::MapThroughOpacitySpace
VTKM_EXEC vtkm::Float32 MapThroughOpacitySpace(vtkm::Float64 value) const
vtkm::worklet::colorconversion::TransferFunction::operator()
VTKM_EXEC void operator()(const T &in, const vtkm::exec::ColorTable &colorTable, vtkm::Vec3ui_8 &output) const
Definition: TransferFunction.h:30
vtkm::worklet::WorkletMapField
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:38