VTK-m  2.0
RayTracingTypeDefs.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_RayTracingTypeDefs_h
11 #define vtk_m_rendering_raytracing_RayTracingTypeDefs_h
12 
13 #include <type_traits>
14 #include <vtkm/List.h>
15 #include <vtkm/Math.h>
16 #include <vtkm/cont/ArrayHandle.h>
21 #include <vtkm/cont/Field.h>
22 #include <vtkm/cont/TryExecute.h>
24 
25 namespace vtkm
26 {
27 namespace rendering
28 {
29 // A more useful bounds check that tells you where it happened
30 #ifndef NDEBUG
31 #define BOUNDS_CHECK(HANDLE, INDEX) BoundsCheck((HANDLE), (INDEX), __FILE__, __LINE__)
32 #else
33 #define BOUNDS_CHECK(HANDLE, INDEX)
34 #endif
35 
36 template <typename ArrayHandleType>
37 VTKM_EXEC inline void BoundsCheck(const ArrayHandleType& handle,
38  const vtkm::Id& index,
39  const char* file,
40  int line)
41 {
42  if (index < 0 || index >= handle.GetNumberOfValues())
43  printf("Bad Index %d at file %s line %d\n", (int)index, file, line);
44 }
45 
46 namespace raytracing
47 {
48 template <typename T>
49 VTKM_EXEC_CONT inline void GetInfinity(T& vtkmNotUsed(infinity));
50 
51 template <>
52 VTKM_EXEC_CONT inline void GetInfinity<vtkm::Float32>(vtkm::Float32& infinity)
53 {
54  infinity = vtkm::Infinity32();
55 }
56 
57 template <>
58 VTKM_EXEC_CONT inline void GetInfinity<vtkm::Float64>(vtkm::Float64& infinity)
59 {
60  infinity = vtkm::Infinity64();
61 }
62 
63 template <typename Device>
64 inline std::string GetDeviceString(Device);
65 
66 template <>
67 inline std::string GetDeviceString<vtkm::cont::DeviceAdapterTagSerial>(
68  vtkm::cont::DeviceAdapterTagSerial)
69 {
70  return "serial";
71 }
72 
73 template <>
74 inline std::string GetDeviceString<vtkm::cont::DeviceAdapterTagTBB>(vtkm::cont::DeviceAdapterTagTBB)
75 {
76  return "tbb";
77 }
78 
79 template <>
80 inline std::string GetDeviceString<vtkm::cont::DeviceAdapterTagOpenMP>(
81  vtkm::cont::DeviceAdapterTagOpenMP)
82 {
83  return "openmp";
84 }
85 
86 template <>
87 inline std::string GetDeviceString<vtkm::cont::DeviceAdapterTagCuda>(
88  vtkm::cont::DeviceAdapterTagCuda)
89 {
90  return "cuda";
91 }
92 
93 template <>
94 inline std::string GetDeviceString<vtkm::cont::DeviceAdapterTagKokkos>(
95  vtkm::cont::DeviceAdapterTagKokkos)
96 {
97  return "kokkos";
98 }
99 
101 {
102  std::string result;
104  : result("")
105  {
106  }
107 
108  template <typename Device>
109  VTKM_CONT bool operator()(Device)
110  {
112  result = GetDeviceString(Device());
113  return true;
114  }
115 };
116 
117 inline std::string GetDeviceString()
118 {
119  DeviceStringFunctor functor;
120  vtkm::cont::TryExecute(functor);
121  return functor.result;
122 }
123 
126 
127 //Defining types supported by the rendering
128 
129 //vec3s
133 
134 // Scalars Types
137 
139 
141 
144 {
145  return field.GetData().ResetTypes(ScalarRenderingTypes{}, VTKM_DEFAULT_STORAGE_LIST{});
146 }
147 
150 {
151  return field.GetData().ResetTypes(Vec3RenderingTypes{}, VTKM_DEFAULT_STORAGE_LIST{});
152 }
153 }
154 }
155 } //namespace vtkm::rendering::raytracing
156 #endif //vtk_m_rendering_raytracing_RayTracingTypeDefs_h
vtkm::rendering::raytracing::GetDeviceString
std::string GetDeviceString(Device)
vtkm::cont::ArrayHandle< vtkm::Vec4f_32 >
ArrayHandle.h
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
VTKM_EXEC_CONT
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
vtkm::rendering::raytracing::GetInfinity
VTKM_EXEC_CONT void GetInfinity(T &vtkmNotUsed(infinity))
ArrayHandleCompositeVector.h
DeviceAdapterList.h
vtkm::rendering::raytracing::GetScalarFieldArray
VTKM_CONT vtkm::cont::UncertainArrayHandle< ScalarRenderingTypes, VTKM_DEFAULT_STORAGE_LIST > GetScalarFieldArray(const vtkm::cont::Field &field)
Definition: RayTracingTypeDefs.h:143
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
vtkm::rendering::raytracing::ScalarD
vtkm::Float64 ScalarD
Definition: RayTracingTypeDefs.h:136
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::cont::Field::GetData
const vtkm::cont::UnknownArrayHandle & GetData() const
ArrayHandleUniformPointCoordinates.h
vtkm::Vec3f_64
vtkm::Vec< vtkm::Float64, 3 > Vec3f_64
Vec3f_64 corresponds to a 3-dimensional vector of 64-bit floating point values.
Definition: Types.h:1026
UncertainArrayHandle.h
Math.h
vtkm::rendering::BoundsCheck
VTKM_EXEC void BoundsCheck(const ArrayHandleType &handle, const vtkm::Id &index, const char *file, int line)
Definition: RayTracingTypeDefs.h:37
TryExecute.h
vtkm::cont::Field
A Field encapsulates an array on some piece of the mesh, such as the points, a cell set,...
Definition: cont/Field.h:31
vtkm::rendering::raytracing::DeviceStringFunctor::operator()
VTKM_CONT bool operator()(Device)
Definition: RayTracingTypeDefs.h:109
ArrayHandleCartesianProduct.h
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkmNotUsed
#define vtkmNotUsed(parameter_name)
Simple macro to identify a parameter as unused.
Definition: ExportMacros.h:128
vtkm::Vec< vtkm::Float32, 3 >
vtkm::cont::UncertainArrayHandle
An ArrayHandle of an uncertain value type and storage.
Definition: UncertainArrayHandle.h:39
vtkm::cont::UnknownArrayHandle::ResetTypes
VTKM_CONT vtkm::cont::UncertainArrayHandle< NewValueTypeList, NewStorageTypeList > ResetTypes(NewValueTypeList=NewValueTypeList{}, NewStorageTypeList=NewStorageTypeList{}) const
Assigns potential value and storage types.
Definition: UncertainArrayHandle.h:129
vtkm::Float32
float Float32
Definition: Types.h:154
Field.h
vtkm::List
Definition: List.h:34
vtkm::Float64
double Float64
Definition: Types.h:155
vtkm::rendering::raytracing::DeviceStringFunctor::result
std::string result
Definition: RayTracingTypeDefs.h:102
vtkm::rendering::raytracing::ScalarF
vtkm::Float32 ScalarF
Definition: RayTracingTypeDefs.h:135
vtkm::rendering::raytracing::DeviceStringFunctor::DeviceStringFunctor
DeviceStringFunctor()
Definition: RayTracingTypeDefs.h:103
vtkm::rendering::raytracing::DeviceStringFunctor
Definition: RayTracingTypeDefs.h:100
List.h
vtkm::cont::TryExecute
VTKM_CONT bool TryExecute(Functor &&functor, Args &&... args)
Try to execute a functor on a set of devices until one succeeds.
Definition: TryExecute.h:244
vtkm::rendering::raytracing::GetVec3FieldArray
VTKM_CONT vtkm::cont::UncertainArrayHandle< Vec3RenderingTypes, VTKM_DEFAULT_STORAGE_LIST > GetVec3FieldArray(const vtkm::cont::Field &field)
Definition: RayTracingTypeDefs.h:149
VTKM_IS_DEVICE_ADAPTER_TAG
#define VTKM_IS_DEVICE_ADAPTER_TAG(tag)
Checks that the argument is a proper device adapter tag.
Definition: DeviceAdapterTag.h:164