Viskores  1.0
ArrayHandleUniformPointCoordinates.h
Go to the documentation of this file.
1 //============================================================================
2 // The contents of this file are covered by the Viskores license. See
3 // LICENSE.txt for details.
4 //
5 // By contributing to this file, all contributors agree to the Developer
6 // Certificate of Origin Version 1.1 (DCO 1.1) as stated in DCO.txt.
7 //============================================================================
8 
9 //============================================================================
10 // Copyright (c) Kitware, Inc.
11 // All rights reserved.
12 // See LICENSE.txt for details.
13 //
14 // This software is distributed WITHOUT ANY WARRANTY; without even
15 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 // PURPOSE. See the above copyright notice for more information.
17 //============================================================================
18 #ifndef viskores_cont_ArrayHandleUniformPointCoordinates_h
19 #define viskores_cont_ArrayHandleUniformPointCoordinates_h
20 
21 #include <viskores/Range.h>
24 
25 namespace viskores
26 {
27 namespace cont
28 {
29 
30 struct VISKORES_ALWAYS_EXPORT StorageTagUniformPoints
31 {
32 };
33 
34 namespace internal
35 {
36 
37 using StorageTagUniformPointsSuperclass =
39 
40 template <>
42  : Storage<viskores::Vec3f, StorageTagUniformPointsSuperclass>
43 {
44 };
45 
46 } // namespace internal
47 
53 class VISKORES_CONT_EXPORT ArrayHandleUniformPointCoordinates
54  : public viskores::cont::ArrayHandle<viskores::Vec3f, viskores::cont::StorageTagUniformPoints>
55 {
56 public:
60 
64  ValueType origin = ValueType(0.0f, 0.0f, 0.0f),
65  ValueType spacing = ValueType(1.0f, 1.0f, 1.0f));
66 
67  // Implemented so that it is defined exclusively in the control environment.
68  // If there is a separate device for the execution environment (for example,
69  // with CUDA), then the automatically generated destructor could be
70  // created for all devices, and it would not be valid for all devices.
72 
74  VISKORES_CONT viskores::Id3 GetDimensions() const;
76  VISKORES_CONT viskores::Vec3f GetOrigin() const;
78  VISKORES_CONT viskores::Vec3f GetSpacing() const;
79 };
80 
81 template <typename T>
82 class ArrayHandleStride;
83 
84 namespace internal
85 {
86 
87 template <typename S>
88 struct ArrayExtractComponentImpl;
89 
90 template <>
91 struct VISKORES_CONT_EXPORT ArrayExtractComponentImpl<viskores::cont::StorageTagUniformPoints>
92 {
95  viskores::IdComponent componentIndex,
96  viskores::CopyFlag allowCopy) const;
97 };
98 
99 template <typename S>
100 struct ArrayRangeComputeImpl;
101 
102 template <>
103 struct VISKORES_CONT_EXPORT ArrayRangeComputeImpl<viskores::cont::StorageTagUniformPoints>
104 {
108  bool computeFiniteRange,
109  viskores::cont::DeviceAdapterId device) const;
110 };
111 
112 } // namespace internal
113 
114 }
115 } // namespace viskores::cont
116 
117 //=============================================================================
118 // Specializations of serialization related classes
120 namespace viskores
121 {
122 namespace cont
123 {
124 
125 template <>
126 struct SerializableTypeString<viskores::cont::ArrayHandleUniformPointCoordinates>
127 {
128  static VISKORES_CONT std::string Get() { return "AH_UniformPointCoordinates"; }
129 };
130 
131 template <>
132 struct SerializableTypeString<
133  viskores::cont::ArrayHandle<viskores::Vec3f, viskores::cont::StorageTagUniformPoints>>
134  : SerializableTypeString<viskores::cont::ArrayHandleUniformPointCoordinates>
135 {
136 };
137 }
138 } // viskores::cont
139 
140 namespace mangled_diy_namespace
141 {
142 
143 template <>
144 struct Serialization<viskores::cont::ArrayHandleUniformPointCoordinates>
145 {
146 private:
149 
150 public:
151  static VISKORES_CONT void save(BinaryBuffer& bb, const BaseType& obj)
152  {
153  auto portal = obj.ReadPortal();
154  viskoresdiy::save(bb, portal.GetDimensions());
155  viskoresdiy::save(bb, portal.GetOrigin());
156  viskoresdiy::save(bb, portal.GetSpacing());
157  }
158 
159  static VISKORES_CONT void load(BinaryBuffer& bb, BaseType& obj)
160  {
161  viskores::Id3 dims;
162  typename BaseType::ValueType origin, spacing;
163 
164  viskoresdiy::load(bb, dims);
165  viskoresdiy::load(bb, origin);
166  viskoresdiy::load(bb, spacing);
167 
168  obj = viskores::cont::ArrayHandleUniformPointCoordinates(dims, origin, spacing);
169  }
170 };
171 
172 template <>
173 struct Serialization<
174  viskores::cont::ArrayHandle<viskores::Vec3f, viskores::cont::StorageTagUniformPoints>>
175  : Serialization<viskores::cont::ArrayHandleUniformPointCoordinates>
176 {
177 };
178 
179 } // diy
181 
182 #endif //vtk_+m_cont_ArrayHandleUniformPointCoordinates_h
viskores::exec::arg::load
T load(const U &u, viskores::Id v)
Definition: FetchTagArrayDirectIn.h:44
ArrayPortalUniformPointCoordinates.h
VISKORES_ARRAY_HANDLE_SUBCLASS_NT
#define VISKORES_ARRAY_HANDLE_SUBCLASS_NT(classname, superclass)
Macro to make default methods in ArrayHandle subclasses.
Definition: ArrayHandle.h:279
viskores::cont::ArrayHandle
Manages an array-worth of data.
Definition: ArrayHandle.h:313
viskores::IdComponent
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
mangled_diy_namespace
Definition: Particle.h:373
viskores::cont::ArrayHandleStride
An ArrayHandle that accesses a basic array with strides and offsets.
Definition: ArrayHandleStride.h:343
viskores::cont::ArrayHandleUniformPointCoordinates
ArrayHandleUniformPointCoordinates is a specialization of ArrayHandle.
Definition: ArrayHandleUniformPointCoordinates.h:53
VISKORES_CONT
#define VISKORES_CONT
Definition: ExportMacros.h:65
viskores
Groups connected points that have the same field value.
Definition: Atomic.h:27
Range.h
viskores::cont::StorageTagImplicit
An implementation for read-only implicit arrays.
Definition: ArrayHandleImplicit.h:94
viskores::cont::DeviceAdapterId
An object used to specify a device.
Definition: DeviceAdapterTag.h:66
viskores::cont::ArrayHandleUniformPointCoordinates::ValueType
Superclass::ValueType ValueType
Definition: ArrayHandleUniformPointCoordinates.h:59
viskores::cont::StorageTagUniformPoints
Definition: ArrayHandleUniformPointCoordinates.h:30
viskores::Get
auto Get(const viskores::Tuple< Ts... > &tuple)
Retrieve the object from a viskores::Tuple at the given index.
Definition: Tuple.h:89
ArrayHandleImplicit.h
viskores::CopyFlag
CopyFlag
Identifier used to specify whether a function should deep copy data.
Definition: Flags.h:25
viskores::Vec< viskores::FloatDefault, 3 >