VTK-m  2.0
FastVec.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_exec_internal_FastVec_h
11 #define vtk_m_exec_internal_FastVec_h
12 
13 #include <vtkm/Types.h>
14 #include <vtkm/VecVariable.h>
15 
16 namespace vtkm
17 {
18 namespace exec
19 {
20 namespace internal
21 {
22 
30 template <typename VecType, vtkm::IdComponent MaxSize>
31 class FastVec
32 {
33 public:
35 
36  explicit VTKM_EXEC FastVec(const VecType& vec)
37  : Vec(vec)
38  {
39  }
40 
41  VTKM_EXEC const Type& Get() const { return this->Vec; }
42 
43 private:
44  Type Vec;
45 };
46 
47 template <typename ComponentType, vtkm::IdComponent NumComponents, vtkm::IdComponent MaxSize>
48 class FastVec<vtkm::Vec<ComponentType, NumComponents>, MaxSize>
49 {
50 public:
52 
53  explicit VTKM_EXEC FastVec(const Type& vec)
54  : Vec(vec)
55  {
56  VTKM_ASSERT(vec.GetNumberOfComponents() <= MaxSize);
57  }
58 
59  VTKM_EXEC const Type& Get() const { return this->Vec; }
60 
61 private:
62  const Type& Vec;
63 };
64 
65 template <typename ComponentType, vtkm::IdComponent MaxSize1, vtkm::IdComponent MaxSize2>
66 class FastVec<vtkm::VecVariable<ComponentType, MaxSize1>, MaxSize2>
67 {
68 public:
70 
71  explicit VTKM_EXEC FastVec(const Type& vec)
72  : Vec(vec)
73  {
74  VTKM_ASSERT(vec.GetNumberOfComponents() <= MaxSize2);
75  }
76 
77  VTKM_EXEC const Type& Get() const { return this->Vec; }
78 
79 private:
80  const Type& Vec;
81 };
82 }
83 }
84 } // vtkm::exec::internal
85 
86 #endif // vtk_m_exec_internal_FastVec_h
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
Types.h
VTKM_ASSERT
#define VTKM_ASSERT(condition)
Definition: Assert.h:43
vtkm::Get
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC_CONT auto Get(const vtkm::Tuple< Ts... > &tuple) -> decltype(tuple.template Get< Index >())
Retrieve the object from a vtkm::Tuple at the given index.
Definition: Tuple.h:83
vtkm::Vec
class VTKM_ALWAYS_EXPORT Vec
Definition: Types.h:319
vtkm::VecVariable
A short variable-length array with maximum length.
Definition: VecVariable.h:30
vtkm::Vec
A short fixed-length array.
Definition: Types.h:767
VecVariable.h