Go to the documentation of this file.
10 #ifndef vtk_m_cont_ArrayHandleConstant_h
11 #define vtk_m_cont_ArrayHandleConstant_h
34 template <
typename ValueType>
38 ConstantFunctor(
const ValueType& value = ValueType())
51 using StorageTagConstantSuperclass =
55 struct Storage<T,
vtkm::cont::StorageTagConstant> : Storage<T, StorageTagConstantSuperclass<T>>
80 :
Superclass(internal::FunctorToArrayHandleImplicitBuffers(internal::ConstantFunctor<T>(value),
106 template <
typename T>
114 "Cannot extract component of ArrayHandleConstant without copying. "
115 "(However, the whole array does not need to be copied.)");
130 template <
typename S>
131 struct ArrayRangeComputeImpl;
136 template <
typename T>
140 bool computeFiniteRange,
143 bool allMasked =
false;
147 auto ids = GetFirstAndLastUnmaskedIndices(maskArray, devId);
148 allMasked = (ids[1] < ids[0]);
154 result.
Allocate(value.GetNumberOfComponents());
156 for (
vtkm::IdComponent index = 0; index < value.GetNumberOfComponents(); ++index)
159 if (allMasked || (computeFiniteRange && !vtkm::IsFinite(comp)))
165 resultPortal.Set(index,
vtkm::Range{ comp, comp });
172 template <
typename S>
173 struct ArrayRangeComputeMagnitudeImpl;
178 template <
typename T>
182 bool computeFiniteRange,
188 auto ids = GetFirstAndLastUnmaskedIndices(maskArray, devId);
197 return (computeFiniteRange && !vtkm::IsFinite(rangeValue))
216 template <
typename T>
217 struct SerializableTypeString<
vtkm::cont::ArrayHandleConstant<T>>
226 template <
typename T>
227 struct SerializableTypeString<
vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagConstant>>
228 : SerializableTypeString<vtkm::cont::ArrayHandleConstant<T>>
237 template <
typename T>
238 struct Serialization<
vtkm::cont::ArrayHandleConstant<T>>
245 static VTKM_CONT void save(BinaryBuffer& bb,
const BaseType& obj)
247 vtkmdiy::save(bb, obj.GetNumberOfValues());
248 vtkmdiy::save(bb, obj.ReadPortal().Get(0));
263 template <
typename T>
264 struct Serialization<
vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagConstant>>
265 : Serialization<vtkm::cont::ArrayHandleConstant<T>>
272 #endif //vtk_m_cont_ArrayHandleConstant_h
vtkm::VecFlat< T > make_VecFlat(const T &vec)
Converts a Vec-like object to a VecFlat.
Definition: VecFlat.h:281
Manages an array-worth of data.
Definition: ArrayHandle.h:300
T load(const U &u, vtkm::Id v)
Definition: FetchTagArrayDirectIn.h:36
Groups connected points that have the same field value.
Definition: Atomic.h:19
auto Get(const vtkm::Tuple< Ts... > &tuple)
Retrieve the object from a vtkm::Tuple at the given index.
Definition: Tuple.h:81
#define VTKM_ARRAY_HANDLE_SUBCLASS(classname, fullclasstype, superclass)
Macro to make default methods in ArrayHandle subclasses.
Definition: ArrayHandle.h:243
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
T GetValue() const
Returns the constant value stored in this array.
Definition: ArrayHandleConstant.h:89
vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:468
vtkm::cont::ArrayHandleConstant< T > make_ArrayHandleConstant(T value, vtkm::Id numberOfValues)
make_ArrayHandleConstant is convenience function to generate an ArrayHandleImplicit.
Definition: ArrayHandleConstant.h:95
Definition: Particle.h:351
ArrayHandleConstant(T value, vtkm::Id numberOfValues=0)
Construct a constant array containing the given value.
Definition: ArrayHandleConstant.h:79
Definition: ArrayHandleConstant.h:27
vtkm::cont::ArrayHandleStride< T > make_ArrayHandleStride(const vtkm::cont::ArrayHandle< T, vtkm::cont::StorageTagBasic > &array, vtkm::Id numValues, vtkm::Id stride, vtkm::Id offset, vtkm::Id modulo=0, vtkm::Id divisor=1)
Create an array by adding a stride to a basic array.
Definition: ArrayHandleStride.h:419
typename vtkm::cont::detail::GetTypeInParentheses< void(vtkm::cont::ArrayHandle< T, vtkm::cont::StorageTagConstant >) >::type Superclass
Definition: ArrayHandleConstant.h:75
#define VTKM_CONT_EXPORT
Definition: vtkm_cont_export.h:44
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
Treat a Vec or Vec-like object as a flat Vec.
Definition: VecFlat.h:224
An array handle with a constant value.
Definition: ArrayHandleConstant.h:70
#define vtkmNotUsed(parameter_name)
Simple macro to identify a parameter as unused.
Definition: ExportMacros.h:128
ReadPortalType ReadPortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:433
An object used to specify a device.
Definition: DeviceAdapterTag.h:58
detail::FloatingPointReturnType< T >::Type Magnitude(const T &x)
Returns the magnitude of a vector.
Definition: VectorAnalysis.h:100
This class is thrown when a VTKm function or method encounters an invalid value that inhibits progres...
Definition: ErrorBadValue.h:25
double Float64
Base type to use for 64-bit floating-point numbers.
Definition: Types.h:161
CopyFlag
Identifier used to specify whether a function should deep copy data.
Definition: Flags.h:17
void Allocate(vtkm::Id numberOfValues, vtkm::CopyFlag preserve, vtkm::cont::Token &token) const
Allocates an array large enough to hold the given number of values.
Definition: ArrayHandle.h:490
#define VTKM_ALWAYS_EXPORT
Definition: ExportMacros.h:89
vtkm::cont::ArrayHandleBasic< T > make_ArrayHandle(const T *array, vtkm::Id numberOfValues, vtkm::CopyFlag copy)
A convenience function for creating an ArrayHandle from a standard C array.
Definition: ArrayHandleBasic.h:270
WritePortalType WritePortal() const
Get an array portal that can be used in the control environment.
Definition: ArrayHandle.h:454
An ArrayHandle that computes values on the fly.
Definition: ArrayHandleImplicit.h:179
Represent a continuous scalar range of values.
Definition: Range.h:31