Go to the documentation of this file.
10 #ifndef vtk_m_cont_ArrayCopy_h
11 #define vtk_m_cont_ArrayCopy_h
21 #include <vtkm/cont/vtkm_cont_export.h>
41 inline void ArrayCopyValueTypeCheck()
44 "An `ArrayHandle` that has a special value type that is not supported "
45 "by the precompiled version of `ArrayCopy` has been used. If this array "
46 "must be deep copied, consider using `ArrayCopyDevice`. Look at the "
47 "compile error for the type assigned to template parameter `T` to "
48 "see the offending type.");
52 struct ArrayCopyConcreteSrc;
54 template <
typename SrcIsArrayHandle>
62 template <
typename SrcIsArrayHandle>
71 template <
typename T,
typename S>
77 detail::ArrayCopyValueTypeCheck<T>();
87 vtkm::cont::detail::ArrayCopyImpl(source, destWrapper, std::false_type{}, std::false_type{});
89 destWrapper.AsArrayHandle(destination);
93 template <
typename TS,
typename SS,
typename TD,
typename SD>
99 ArrayCopyValueTypeCheck<TS>();
100 ArrayCopyValueTypeCheck<TD>();
102 detail::ArrayCopyConcreteSrc<SS>{}(source, destination);
106 template <
typename T,
typename S>
141 template <
typename SourceArrayType,
typename DestArrayType>
142 inline void ArrayCopy(
const SourceArrayType& source, DestArrayType& destination)
144 detail::ArrayCopyImpl(source,
146 typename internal::ArrayHandleCheck<SourceArrayType>::type{},
147 typename internal::ArrayHandleCheck<DestArrayType>::type{});
151 template <
typename SourceArrayType>
154 detail::ArrayCopyImpl(source,
156 typename internal::ArrayHandleCheck<SourceArrayType>::type{},
162 template <
typename T,
typename S>
181 template <
typename T,
typename S>
202 template <
typename S>
203 struct ArrayCopyConcreteSrc
205 template <
typename T,
typename DestArray>
210 source, destination, vtkm::cont::internal::ArrayExtractComponentIsInefficient<ArrayType>{});
213 template <
typename T,
typename DestArray>
215 DestArray& destination,
221 template <
typename T,
typename DestArray>
223 DestArray& destination,
227 "Attempting to copy from an array of type " +
229 " with ArrayCopy is inefficient. It is highly recommended you use another method "
230 "such as vtkm::cont::ArrayCopyDevice.");
239 struct ArrayCopyConcreteSrc<
vtkm::cont::StorageTagConstant>
241 template <
typename T1,
typename T2,
typename S2>
252 struct ArrayCopyConcreteSrc<
vtkm::cont::StorageTagIndex>
254 template <
typename T,
typename S>
266 struct VTKM_CONT_EXPORT ArrayCopyConcreteSrc<
vtkm::cont::StorageTagCounting>
268 template <
typename T1,
typename T2,
typename S2>
273 T1 start = countingSource.
GetStart();
274 T1 step = countingSource.
GetStep();
281 for (
vtkm::IdComponent comp = 0; comp < VTraits1::GetNumberOfComponents(start); ++comp)
283 this->CopyCountingFloat(
294 destination = this->CopyCountingId(source);
307 template <
typename ST1,
typename ST2>
308 struct ArrayCopyConcreteSrc<
vtkm::cont::StorageTagConcatenate<ST1, ST2>>
310 template <
typename SourceArrayType,
typename DestArrayType>
311 void operator()(
const SourceArrayType& source, DestArrayType& destination)
const
313 auto source1 = source.GetStorage().GetArray1(source.GetBuffers());
314 auto source2 = source.GetStorage().GetArray2(source.GetBuffers());
317 destination.Allocate(source.GetNumberOfValues());
320 destination, source1.GetNumberOfValues(), source2.GetNumberOfValues());
328 template <
typename SIndex,
typename SValue>
329 struct ArrayCopyConcreteSrc<
vtkm::cont::StorageTagPermutation<SIndex, SValue>>
332 template <
typename T1,
typename T2,
typename S2>
339 vtkm::cont::internal::MapArrayPermutation(valueArray, indexArray);
349 #endif //vtk_m_cont_ArrayCopy_h
const VTKM_CONT std::vector< vtkm::cont::internal::Buffer > & GetBuffers() const
Returns the internal Buffer structures that hold the data.
Definition: ArrayHandle.h:696
VTKM_CONT CountingValueType GetStart() const
Definition: ArrayHandleCounting.h:142
VTKM_CONT vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:448
VTKM_CONT void AsArrayHandle(vtkm::cont::ArrayHandle< T, S > &array) const
Definition: UnknownArrayHandle.h:616
Groups connected points that have the same field value.
Definition: Atomic.h:19
ArrayHandleView< ArrayHandleType > make_ArrayHandleView(const ArrayHandleType &array, vtkm::Id startIndex, vtkm::Id numValues)
Definition: ArrayHandleView.h:222
@ Warn
Less important user errors, such as out-of-bounds parameters.
VTKM_CONT vtkm::cont::ArrayHandleStride< BaseComponentType > ExtractComponent(vtkm::IdComponent componentIndex, vtkm::CopyFlag allowCopy=vtkm::CopyFlag::On) const
Extract a component of the array.
Definition: UnknownArrayHandle.h:730
VTKM_CONT 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:465
VTKM_CONT void AllocateAndFill(vtkm::Id numberOfValues, const ValueType &fillValue, vtkm::CopyFlag preserve, vtkm::cont::Token &token) const
Allocates an array and fills it with an initial value.
Definition: ArrayHandle.h:495
VTKM_CONT T GetValue() const
Returns the constant value stored in this array.
Definition: ArrayHandleConstant.h:81
vtkm::Int32 IdComponent
Represents a component ID (index of component in a vector).
Definition: Types.h:168
VTKM_CONT void ArrayCopyShallowIfPossible(const vtkm::cont::UnknownArrayHandle source, vtkm::cont::ArrayHandle< T, S > &destination)
Copies from an unknown to a known array type.
Definition: ArrayCopy.h:182
VTKM_CONT bool CanConvert() const
Determine if the contained array can be passed to the given array type.
Definition: UnknownArrayHandle.h:913
An ArrayHandle of an unknown value type and storage.
Definition: UnknownArrayHandle.h:406
typename detail::HasVecTraitsImpl< T >::Type HasVecTraits
Determines whether the given type has VecTraits defined.
Definition: VecTraits.h:176
VTKM_CONT StorageType GetStorage() const
Get the storage.
Definition: ArrayHandle.h:401
Definition: ArrayHandlePermutation.h:93
vtkm::Int32 Id
Represents an ID (index into arrays).
Definition: Types.h:191
void DeepCopyFrom(const vtkm::cont::UnknownArrayHandle &source)
Deep copies data from another UnknownArrayHandle.
ArrayHandleCounting is a specialization of ArrayHandle.
Definition: ArrayHandleCounting.h:127
#define VTKM_STATIC_ASSERT_MSG(condition, message)
Definition: StaticAssert.h:18
void ArrayCopy(const SourceArrayType &source, DestArrayType &destination)
Does a deep copy from one array to another array.
Definition: ArrayCopy.h:142
#define VTKM_CONT
Definition: ExportMacros.h:57
An array handle with a constant value.
Definition: ArrayHandleConstant.h:63
#define vtkmNotUsed(parameter_name)
Simple macro to identify a parameter as unused.
Definition: ExportMacros.h:128
#define VTKM_LOG_S(level,...)
Writes a message using stream syntax to the indicated log level.
Definition: Logging.h:261
VTKM_CONT void DeepCopyFrom(const vtkm::cont::ArrayHandle< ValueType, StorageTag > &source) const
Deep copies the data in the array.
Definition: ArrayHandle.h:682
vtkm::Float32 FloatDefault
The floating point type to use when no other precision is specified.
Definition: Types.h:198
The VecTraits class gives several static members that define how to use a given type as a vector.
Definition: VecTraits.h:66
VTKM_CONT CountingValueType GetStep() const
Definition: ArrayHandleCounting.h:144
VTKM_CONT_EXPORT VTKM_CONT std::string TypeToString(const std::type_info &t)
Use RTTI information to retrieve the name of the type T.
An implicit array handle containing the its own indices.
Definition: ArrayHandleIndex.h:54