6#ifndef vtkmlib_DataArrayConverters_h
7#define vtkmlib_DataArrayConverters_h
9#include "vtkAcceleratorsVTKmCoreModule.h"
10#include "vtkmConfigCore.h"
17#include <vtkm/cont/ArrayExtractComponent.h>
18#include <vtkm/cont/ArrayHandleBasic.h>
19#include <vtkm/cont/ArrayHandleRecombineVec.h>
20#include <vtkm/cont/ArrayHandleRuntimeVec.h>
21#include <vtkm/cont/ArrayHandleSOA.h>
22#include <vtkm/cont/ArrayHandleStride.h>
23#include <vtkm/cont/Field.h>
24#include <vtkm/cont/UnknownArrayHandle.h>
33class CoordinateSystem;
37VTK_ABI_NAMESPACE_BEGIN
44VTK_ABI_NAMESPACE_BEGIN
51 static const char* name =
"NoNameVTKField";
63 auto deleter = [](
void* container)
69 [](
void*& memory,
void*& container, vtkm::BufferSizeType oldSize, vtkm::BufferSizeType newSize)
72 if ((
vtkArray->GetVoidPointer(0) != memory) || (
vtkArray->GetNumberOfValues() != oldSize))
75 "Dangerous inconsistency found between pointers for VTK and VTK-m. "
76 "Was the VTK array resized outside of VTK-m?");
78 vtkArray->SetNumberOfValues(newSize);
79 memory =
vtkArray->GetVoidPointer(0);
82 return vtkm::cont::ArrayHandleBasic<T>(
94 using ContainerPair = std::pair<vtkSOADataArrayTemplate<T>*,
int>;
95 ContainerPair* componentInput =
new ContainerPair(input, componentIndex);
97 auto deleter = [](
void* container)
99 ContainerPair* containerPair =
reinterpret_cast<ContainerPair*
>(container);
100 containerPair->first->UnRegister(
nullptr);
101 delete containerPair;
103 auto reallocator = [](
void*& memory,
void*& container, vtkm::BufferSizeType vtkNotUsed(oldSize),
104 vtkm::BufferSizeType newSize)
106 ContainerPair* containerPair =
reinterpret_cast<ContainerPair*
>(container);
107 containerPair->first->SetNumberOfTuples(newSize);
108 memory = containerPair->first->GetComponentArrayPointer(containerPair->second);
128 vtkm::cont::ArrayHandleRecombineVec<T> output;
133 output.AppendComponentArray(
134 vtkm::cont::ArrayExtractComponent(componentArray, 0, vtkm::CopyFlag::Off));
140template <
typename DataArrayType>
160VTK_ABI_NAMESPACE_BEGIN
162VTKACCELERATORSVTKMCORE_EXPORT
165VTKACCELERATORSVTKMCORE_EXPORT
168VTKACCELERATORSVTKMCORE_EXPORT
174VTK_ABI_NAMESPACE_BEGIN
177 using T = std::underlying_type<tovtkm::FieldsFlag>::type;
183 using T = std::underlying_type<tovtkm::FieldsFlag>::type;
tovtkm::FieldsFlag operator&(const tovtkm::FieldsFlag &a, const tovtkm::FieldsFlag &b)
tovtkm::FieldsFlag operator|(const tovtkm::FieldsFlag &a, const tovtkm::FieldsFlag &b)
Array-Of-Structs implementation of vtkGenericDataArray.
ValueType * GetPointer(vtkIdType valueIdx)
Get the address of a particular data index.
int GetNumberOfComponents() const
Set/Get the dimension (n) of the components.
vtkIdType GetNumberOfTuples() const
Get the number of complete tuples (a component group) in the array.
vtkIdType GetNumberOfValues() const
Get the total number of values in the array.
Abstract interface for N-dimensional arrays.
abstract superclass for arrays of numeric data
virtual void UnRegister(vtkObjectBase *o)
Decrease the reference count (release by another object).
void Register(vtkObjectBase *o)
Increase the reference count (mark as used by another object).
represent and manipulate 3D points
Struct-Of-Arrays implementation of vtkGenericDataArray.
ValueType * GetComponentArrayPointer(int comp)
Return a pointer to a contiguous block of memory containing all values for a particular components (i...
VTKACCELERATORSVTKMCORE_EXPORT vtkDataArray * Convert(const vtkm::cont::Field &input)
vtkm::cont::ArrayHandleRuntimeVec< T > vtkDataArrayToArrayHandle(vtkAOSDataArrayTemplate< T > *input)
vtkm::cont::UnknownArrayHandle vtkDataArrayToUnknownArrayHandle(DataArrayType *input)
vtkm::cont::ArrayHandleBasic< T > vtkAOSDataArrayToFlatArrayHandle(vtkAOSDataArrayTemplate< T > *input)
vtkm::cont::ArrayHandleBasic< T > vtkSOADataArrayToComponentArrayHandle(vtkSOADataArrayTemplate< T > *input, int componentIndex)
static const char * NoNameVTKFieldName()
Temporary name for arrays converted from VTK that do not have a name.
#define vtkLog(verbosity_name, x)
Add to log given the verbosity level.