VTK-m  2.2
ArrayHandleUniformPointCoordinates.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_ArrayHandleUniformPointCoordinates_h
11 #define vtk_m_cont_ArrayHandleUniformPointCoordinates_h
12 
13 #include <vtkm/Range.h>
16 
17 namespace vtkm
18 {
19 namespace cont
20 {
21 
23 {
24 };
25 
26 namespace internal
27 {
28 
29 using StorageTagUniformPointsSuperclass =
31 
32 template <>
34  : Storage<vtkm::Vec3f, StorageTagUniformPointsSuperclass>
35 {
36 };
37 
38 } // namespace internal
39 
46  : public vtkm::cont::ArrayHandle<vtkm::Vec3f, vtkm::cont::StorageTagUniformPoints>
47 {
48 public:
52 
54  VTKM_CONT
56  ValueType origin = ValueType(0.0f, 0.0f, 0.0f),
57  ValueType spacing = ValueType(1.0f, 1.0f, 1.0f));
58 
59  // Implemented so that it is defined exclusively in the control environment.
60  // If there is a separate device for the execution environment (for example,
61  // with CUDA), then the automatically generated destructor could be
62  // created for all devices, and it would not be valid for all devices.
64 
66  VTKM_CONT vtkm::Id3 GetDimensions() const;
68  VTKM_CONT vtkm::Vec3f GetOrigin() const;
70  VTKM_CONT vtkm::Vec3f GetSpacing() const;
71 };
72 
73 template <typename T>
74 class ArrayHandleStride;
75 
76 namespace internal
77 {
78 
79 template <typename S>
80 struct ArrayExtractComponentImpl;
81 
82 template <>
83 struct VTKM_CONT_EXPORT ArrayExtractComponentImpl<vtkm::cont::StorageTagUniformPoints>
84 {
87  vtkm::IdComponent componentIndex,
88  vtkm::CopyFlag allowCopy) const;
89 };
90 
91 template <typename S>
92 struct ArrayRangeComputeImpl;
93 
94 template <>
95 struct VTKM_CONT_EXPORT ArrayRangeComputeImpl<vtkm::cont::StorageTagUniformPoints>
96 {
99  const vtkm::cont::ArrayHandle<vtkm::UInt8>& maskArray,
100  bool computeFiniteRange,
101  vtkm::cont::DeviceAdapterId device) const;
102 };
103 
104 } // namespace internal
105 
106 }
107 } // namespace vtkm::cont
108 
109 //=============================================================================
110 // Specializations of serialization related classes
112 namespace vtkm
113 {
114 namespace cont
115 {
116 
117 template <>
118 struct SerializableTypeString<vtkm::cont::ArrayHandleUniformPointCoordinates>
119 {
120  static VTKM_CONT std::string Get() { return "AH_UniformPointCoordinates"; }
121 };
122 
123 template <>
124 struct SerializableTypeString<
125  vtkm::cont::ArrayHandle<vtkm::Vec3f, vtkm::cont::StorageTagUniformPoints>>
126  : SerializableTypeString<vtkm::cont::ArrayHandleUniformPointCoordinates>
127 {
128 };
129 }
130 } // vtkm::cont
131 
132 namespace mangled_diy_namespace
133 {
134 
135 template <>
136 struct Serialization<vtkm::cont::ArrayHandleUniformPointCoordinates>
137 {
138 private:
141 
142 public:
143  static VTKM_CONT void save(BinaryBuffer& bb, const BaseType& obj)
144  {
145  auto portal = obj.ReadPortal();
146  vtkmdiy::save(bb, portal.GetDimensions());
147  vtkmdiy::save(bb, portal.GetOrigin());
148  vtkmdiy::save(bb, portal.GetSpacing());
149  }
150 
151  static VTKM_CONT void load(BinaryBuffer& bb, BaseType& obj)
152  {
153  vtkm::Id3 dims;
154  typename BaseType::ValueType origin, spacing;
155 
156  vtkmdiy::load(bb, dims);
157  vtkmdiy::load(bb, origin);
158  vtkmdiy::load(bb, spacing);
159 
160  obj = vtkm::cont::ArrayHandleUniformPointCoordinates(dims, origin, spacing);
161  }
162 };
163 
164 template <>
165 struct Serialization<vtkm::cont::ArrayHandle<vtkm::Vec3f, vtkm::cont::StorageTagUniformPoints>>
166  : Serialization<vtkm::cont::ArrayHandleUniformPointCoordinates>
167 {
168 };
169 
170 } // diy
172 
173 #endif //vtk_+m_cont_ArrayHandleUniformPointCoordinates_h
vtkm::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:300
vtkm::exec::arg::load
T load(const U &u, vtkm::Id v)
Definition: FetchTagArrayDirectIn.h:36
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
ArrayPortalUniformPointCoordinates.h
vtkm::Get
auto Get(const vtkm::Tuple< Ts... > &tuple)
Retrieve the object from a vtkm::Tuple at the given index.
Definition: Tuple.h:81
VTKM_ARRAY_HANDLE_SUBCLASS_NT
#define VTKM_ARRAY_HANDLE_SUBCLASS_NT(classname, superclass)
Macro to make default methods in ArrayHandle subclasses.
Definition: ArrayHandle.h:266
vtkm::cont::StorageTagImplicit
An implementation for read-only implicit arrays.
Definition: ArrayHandleImplicit.h:86
vtkm::IdComponent
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
mangled_diy_namespace
Definition: Particle.h:351
vtkm::cont::ArrayHandleStride
An ArrayHandle that accesses a basic array with strides and offsets.
Definition: ArrayHandleStride.h:332
vtkm::cont::StorageTagUniformPoints
Definition: ArrayHandleUniformPointCoordinates.h:22
VTKM_CONT_EXPORT
#define VTKM_CONT_EXPORT
Definition: vtkm_cont_export.h:44
vtkm::cont::ArrayHandleUniformPointCoordinates::ValueType
Superclass::ValueType ValueType
Definition: ArrayHandleUniformPointCoordinates.h:51
Range.h
VTKM_CONT
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::cont::DeviceAdapterId
An object used to specify a device.
Definition: DeviceAdapterTag.h:58
vtkm::Vec< vtkm::FloatDefault, 3 >
vtkm::cont::ArrayHandleUniformPointCoordinates
ArrayHandleUniformPointCoordinates is a specialization of ArrayHandle.
Definition: ArrayHandleUniformPointCoordinates.h:45
vtkm::CopyFlag
CopyFlag
Identifier used to specify whether a function should deep copy data.
Definition: Flags.h:17
VTKM_ALWAYS_EXPORT
#define VTKM_ALWAYS_EXPORT
Definition: ExportMacros.h:89
ArrayHandleImplicit.h