VTK-m  2.0
ArrayHandleIndex.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_cont_ArrayHandleIndex_h
11 #define vtk_m_cont_ArrayHandleIndex_h
12 
14 
15 namespace vtkm
16 {
17 
18 namespace internal
19 {
20 
21 struct VTKM_ALWAYS_EXPORT IndexFunctor
22 {
23  VTKM_EXEC_CONT vtkm::Id operator()(vtkm::Id index) const { return index; }
24 };
25 
26 } // namespace internal
27 
28 namespace cont
29 {
30 
32 {
33 };
34 
35 namespace internal
36 {
37 
38 using StorageTagIndexSuperclass =
40 
41 template <>
42 struct Storage<vtkm::Id, vtkm::cont::StorageTagIndex> : Storage<vtkm::Id, StorageTagIndexSuperclass>
43 {
44 };
45 
46 } // namespace internal
47 
54 class ArrayHandleIndex : public vtkm::cont::ArrayHandle<vtkm::Id, StorageTagIndex>
55 {
56 public:
59 
60  VTKM_CONT
62  : Superclass(
63  internal::FunctorToArrayHandleImplicitBuffers(vtkm::internal::IndexFunctor{}, length))
64  {
65  }
66 };
67 
71 {
72  return vtkm::cont::ArrayHandleIndex(length);
73 }
74 }
75 } // namespace vtkm::cont
76 
77 //=============================================================================
78 // Specializations of serialization related classes
80 
81 namespace vtkm
82 {
83 namespace cont
84 {
85 
86 template <>
87 struct SerializableTypeString<vtkm::cont::ArrayHandleIndex>
88 {
89  static VTKM_CONT const std::string Get() { return "AH_Index"; }
90 };
91 
92 template <>
93 struct SerializableTypeString<vtkm::cont::ArrayHandle<vtkm::Id, vtkm::cont::StorageTagIndex>>
94  : SerializableTypeString<vtkm::cont::ArrayHandleIndex>
95 {
96 };
97 }
98 } // vtkm::cont
99 
100 namespace mangled_diy_namespace
101 {
102 
103 template <>
104 struct Serialization<vtkm::cont::ArrayHandleIndex>
105 {
106 private:
108 
109 public:
110  static VTKM_CONT void save(BinaryBuffer& bb, const BaseType& obj)
111  {
112  vtkmdiy::save(bb, obj.GetNumberOfValues());
113  }
114 
115  static VTKM_CONT void load(BinaryBuffer& bb, BaseType& obj)
116  {
117  vtkm::Id length = 0;
118  vtkmdiy::load(bb, length);
119 
120  obj = vtkm::cont::ArrayHandleIndex(length);
121  }
122 };
123 
124 template <>
125 struct Serialization<vtkm::cont::ArrayHandle<vtkm::Id, vtkm::cont::StorageTagIndex>>
126  : Serialization<vtkm::cont::ArrayHandleIndex>
127 {
128 };
129 } // diy
131 
132 #endif //vtk_m_cont_ArrayHandleIndex_h
vtkm::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:283
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::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::cont::make_ArrayHandleIndex
VTKM_CONT vtkm::cont::ArrayHandleIndex make_ArrayHandleIndex(vtkm::Id length)
A convenience function for creating an ArrayHandleIndex.
Definition: ArrayHandleIndex.h:70
vtkm::cont::ArrayHandleIndex::VTKM_ARRAY_HANDLE_SUBCLASS_NT
VTKM_ARRAY_HANDLE_SUBCLASS_NT(ArrayHandleIndex,(vtkm::cont::ArrayHandle< vtkm::Id, StorageTagIndex >))
vtkm::cont::StorageTagIndex
Definition: ArrayHandleIndex.h:31
mangled_diy_namespace
Definition: Particle.h:331
vtkm::Id
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
vtkm::exec::arg::load
VTKM_SUPPRESS_EXEC_WARNINGS VTKM_EXEC T load(const U &u, vtkm::Id v)
Definition: FetchTagArrayDirectIn.h:36
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::cont::ArrayHandleIndex::ArrayHandleIndex
VTKM_CONT ArrayHandleIndex(vtkm::Id length)
Definition: ArrayHandleIndex.h:61
vtkm::cont::ArrayHandle::StorageTag
StorageTag_ StorageTag
Definition: ArrayHandle.h:291
VTKM_ALWAYS_EXPORT
#define VTKM_ALWAYS_EXPORT
Definition: ExportMacros.h:92
ArrayHandleImplicit.h
vtkm::cont::ArrayHandleIndex
An implicit array handle containing the its own indices.
Definition: ArrayHandleIndex.h:54