VTK-m  2.0
Worklets.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_rendering_raytracing_Worklets_h
11 #define vtk_m_rendering_raytracing_Worklets_h
13 namespace vtkm
14 {
15 namespace rendering
16 {
17 namespace raytracing
18 {
19 //
20 // Utility memory set functor
21 //
22 template <class T>
24 {
25  T Value;
26 
27 public:
28  VTKM_CONT
29  MemSet(T value)
30  : Value(value)
31  {
32  }
33  using ControlSignature = void(FieldOut);
34  using ExecutionSignature = void(_1);
35  VTKM_EXEC
36  void operator()(T& outValue) const { outValue = Value; }
37 }; //class MemSet
38 
39 template <typename FloatType>
41 {
43 
44 public:
45  VTKM_CONT
46  CopyAndOffset(const FloatType offset = 0.00001)
47  : Offset(offset)
48  {
49  }
51  using ExecutionSignature = void(_1, _2);
52 
53  VTKM_EXEC inline void operator()(const FloatType& inValue, FloatType& outValue) const
54  {
55  outValue = inValue + Offset;
56  }
57 }; //class Copy and iffset
58 
59 template <typename FloatType>
61 {
64 
65 public:
66  VTKM_CONT
67  CopyAndOffsetMask(const FloatType offset = 0.00001, const vtkm::UInt8 mask = 1)
68  : Offset(offset)
69  , MaskValue(mask)
70  {
71  }
73  using ExecutionSignature = void(_1, _2, _3);
74 
75  template <typename MaskType>
76  VTKM_EXEC inline void operator()(const FloatType& inValue,
77  FloatType& outValue,
78  const MaskType& mask) const
79  {
80  if (mask == MaskValue)
81  outValue = inValue + Offset;
82  }
83 }; //class Copy and iffset
84 
85 template <class T>
87 {
88  T Value;
89 
90 public:
91  VTKM_CONT
92  Mask(T value)
93  : Value(value)
94  {
95  }
97  using ExecutionSignature = void(_1, _2);
98 
99  template <typename O>
100  VTKM_EXEC void operator()(const T& inValue, O& outValue) const
101  {
102  if (inValue == Value)
103  outValue = static_cast<O>(1);
104  else
105  outValue = static_cast<O>(0);
106  }
107 }; //class mask
108 
109 template <class T, int N>
111 {
113 
114 public:
115  VTKM_CONT
117  : Values(values)
118  {
119  }
121  using ExecutionSignature = void(_1, _2);
122 
123  template <typename O>
124  VTKM_EXEC void operator()(const T& inValue, O& outValue) const
125  {
126  bool doMask = false;
127  for (vtkm::Int32 i = 0; i < N; ++i)
128  {
129  if (inValue == Values[i])
130  doMask = true;
131  }
132  if (doMask)
133  outValue = static_cast<O>(1);
134  else
135  outValue = static_cast<O>(0);
136  }
137 }; //class double mask
138 
139 struct MaxValue
140 {
141  template <typename T>
142  VTKM_EXEC_CONT T operator()(const T& a, const T& b) const
143  {
144  return (a > b) ? a : b;
145  }
146 
147 }; //struct MaxValue
148 
149 struct MinValue
150 {
151  template <typename T>
152  VTKM_EXEC_CONT T operator()(const T& a, const T& b) const
153  {
154  return (a < b) ? a : b;
155  }
156 
157 }; //struct MinValue
158 }
159 }
160 } //namespace vtkm::rendering::raytracing
161 #endif //vtk_m_rendering_raytracing_Worklets_h
vtkm::rendering::raytracing::Mask::ExecutionSignature
void(_1, _2) ExecutionSignature
Definition: Worklets.h:97
vtkm::rendering::raytracing::Mask::Mask
VTKM_CONT Mask(T value)
Definition: Worklets.h:92
vtkm::rendering::raytracing::MemSet
Definition: Worklets.h:23
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::rendering::raytracing::CopyAndOffset::CopyAndOffset
VTKM_CONT CopyAndOffset(const FloatType offset=0.00001)
Definition: Worklets.h:46
WorkletMapField.h
VTKM_EXEC_CONT
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
vtkm::worklet::WorkletMapField::FieldOut
A control signature tag for output fields.
Definition: WorkletMapField.h:60
vtkm::rendering::raytracing::MemSet::ExecutionSignature
void(_1) ExecutionSignature
Definition: Worklets.h:34
vtkm::rendering::raytracing::CopyAndOffset::operator()
VTKM_EXEC void operator()(const FloatType &inValue, FloatType &outValue) const
Definition: Worklets.h:53
vtkm::rendering::raytracing::CopyAndOffsetMask::CopyAndOffsetMask
VTKM_CONT CopyAndOffsetMask(const FloatType offset=0.00001, const vtkm::UInt8 mask=1)
Definition: Worklets.h:67
vtkm::rendering::raytracing::MaxValue
Definition: Worklets.h:139
vtkm::worklet::cellmetrics::FloatType
vtkm::FloatDefault FloatType
Definition: CellAspectFrobeniusMetric.h:50
vtkm::rendering::raytracing::ManyMask::ControlSignature
void(FieldIn, FieldOut) ControlSignature
Definition: Worklets.h:120
vtkm::rendering::raytracing::CopyAndOffsetMask::ExecutionSignature
void(_1, _2, _3) ExecutionSignature
Definition: Worklets.h:73
vtkm::rendering::raytracing::Mask::Value
T Value
Definition: Worklets.h:88
vtkm::rendering::raytracing::ManyMask::operator()
VTKM_EXEC void operator()(const T &inValue, O &outValue) const
Definition: Worklets.h:124
vtkm::rendering::raytracing::CopyAndOffsetMask::Offset
FloatType Offset
Definition: Worklets.h:62
vtkm::rendering::raytracing::Mask::ControlSignature
void(FieldIn, FieldOut) ControlSignature
Definition: Worklets.h:96
vtkm::rendering::raytracing::MemSet::Value
T Value
Definition: Worklets.h:25
vtkm::rendering::raytracing::MinValue
Definition: Worklets.h:149
vtkm::rendering::raytracing::ManyMask::ManyMask
VTKM_CONT ManyMask(vtkm::Vec< T, N > values)
Definition: Worklets.h:116
vtkm::worklet::WorkletMapField::FieldIn
A control signature tag for input fields.
Definition: WorkletMapField.h:49
vtkm::rendering::raytracing::ManyMask::ExecutionSignature
void(_1, _2) ExecutionSignature
Definition: Worklets.h:121
vtkm::rendering::raytracing::CopyAndOffset::Offset
FloatType Offset
Definition: Worklets.h:42
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::worklet::WorkletMapField::FieldInOut
A control signature tag for input-output (in-place) fields.
Definition: WorkletMapField.h:71
vtkm::rendering::raytracing::MemSet::ControlSignature
void(FieldOut) ControlSignature
Definition: Worklets.h:33
vtkm::UInt8
uint8_t UInt8
Definition: Types.h:157
vtkm::rendering::raytracing::CopyAndOffsetMask
Definition: Worklets.h:60
vtkm::rendering::raytracing::MemSet::operator()
VTKM_EXEC void operator()(T &outValue) const
Definition: Worklets.h:36
vtkm::rendering::raytracing::CopyAndOffset::ControlSignature
void(FieldIn, FieldOut) ControlSignature
Definition: Worklets.h:50
vtkm::rendering::raytracing::Mask::operator()
VTKM_EXEC void operator()(const T &inValue, O &outValue) const
Definition: Worklets.h:100
vtkm::rendering::raytracing::ManyMask
Definition: Worklets.h:110
vtkm::rendering::raytracing::CopyAndOffset
Definition: Worklets.h:40
vtkm::Vec< T, N >
vtkm::worklet::MaskNone
Default mask object that does not suppress anything.
Definition: MaskNone.h:27
vtkm::rendering::raytracing::MinValue::operator()
VTKM_EXEC_CONT T operator()(const T &a, const T &b) const
Definition: Worklets.h:152
vtkm::Int32
int32_t Int32
Definition: Types.h:160
vtkm::rendering::raytracing::MemSet::MemSet
VTKM_CONT MemSet(T value)
Definition: Worklets.h:29
vtkm::rendering::raytracing::Mask
Definition: Worklets.h:86
vtkm::rendering::raytracing::CopyAndOffset::ExecutionSignature
void(_1, _2) ExecutionSignature
Definition: Worklets.h:51
vtkm::rendering::raytracing::CopyAndOffsetMask::operator()
VTKM_EXEC void operator()(const FloatType &inValue, FloatType &outValue, const MaskType &mask) const
Definition: Worklets.h:76
vtkm::rendering::raytracing::CopyAndOffsetMask::ControlSignature
void(FieldIn, FieldInOut, FieldIn) ControlSignature
Definition: Worklets.h:72
vtkm::rendering::raytracing::CopyAndOffsetMask::MaskValue
vtkm::UInt8 MaskValue
Definition: Worklets.h:63
vtkm::worklet::WorkletMapField
Base class for worklets that do a simple mapping of field arrays.
Definition: WorkletMapField.h:38
vtkm::rendering::raytracing::ManyMask::Values
vtkm::Vec< T, N > Values
Definition: Worklets.h:112
vtkm::rendering::raytracing::MaxValue::operator()
VTKM_EXEC_CONT T operator()(const T &a, const T &b) const
Definition: Worklets.h:142