6#ifndef vtkmlib_DataArrayConverters_h
7#define vtkmlib_DataArrayConverters_h
9#include "vtkAcceleratorsVTKmCoreModule.h"
10#include "vtkmConfigCore.h"
17#include <viskores/cont/ArrayExtractComponent.h>
18#include <viskores/cont/ArrayHandleBasic.h>
19#include <viskores/cont/ArrayHandleRecombineVec.h>
20#include <viskores/cont/ArrayHandleRuntimeVec.h>
21#include <viskores/cont/ArrayHandleSOA.h>
22#include <viskores/cont/ArrayHandleStride.h>
23#include <viskores/cont/Field.h>
24#include <viskores/cont/UnknownArrayHandle.h>
33class CoordinateSystem;
37VTK_ABI_NAMESPACE_BEGIN
44VTK_ABI_NAMESPACE_BEGIN
51 static const char* name =
"NoNameVTKField";
64 auto deleter = [](
void* container)
69 auto reallocator = [](
void*& memory,
void*& container, viskores::BufferSizeType oldSize,
70 viskores::BufferSizeType newSize)
73 if ((
vtkArray->GetVoidPointer(0) != memory) || (
vtkArray->GetNumberOfValues() != oldSize))
76 "Dangerous inconsistency found between pointers for VTK and Viskores. "
77 "Was the VTK array resized outside of Viskores?");
79 vtkArray->SetNumberOfValues(newSize);
80 memory =
vtkArray->GetVoidPointer(0);
83 return viskores::cont::ArrayHandleBasic<T>(
95 using ContainerPair = std::pair<vtkSOADataArrayTemplate<T>*,
int>;
96 ContainerPair* componentInput =
new ContainerPair(input, componentIndex);
98 auto deleter = [](
void* container)
100 ContainerPair* containerPair =
reinterpret_cast<ContainerPair*
>(container);
101 containerPair->first->UnRegister(
nullptr);
102 delete containerPair;
104 auto reallocator = [](
void*& memory,
void*& container,
105 viskores::BufferSizeType vtkNotUsed(oldSize),
106 viskores::BufferSizeType newSize)
108 ContainerPair* containerPair =
reinterpret_cast<ContainerPair*
>(container);
109 containerPair->first->SetNumberOfTuples(newSize);
110 memory = containerPair->first->GetComponentArrayPointer(containerPair->second);
132 viskores::cont::ArrayHandleRecombineVec<T> output;
137 output.AppendComponentArray(
138 viskores::cont::ArrayExtractComponent(componentArray, 0, viskores::CopyFlag::Off));
144template <
typename DataArrayType>
164VTK_ABI_NAMESPACE_BEGIN
166VTKACCELERATORSVTKMCORE_EXPORT
169VTKACCELERATORSVTKMCORE_EXPORT
172VTKACCELERATORSVTKMCORE_EXPORT
178VTK_ABI_NAMESPACE_BEGIN
181 using T = std::underlying_type<tovtkm::FieldsFlag>::type;
187 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 viskores::cont::Field &input)
viskores::cont::ArrayHandleBasic< T > vtkAOSDataArrayToFlatArrayHandle(vtkAOSDataArrayTemplate< T > *input)
viskores::cont::ArrayHandleRuntimeVec< T > vtkDataArrayToArrayHandle(vtkAOSDataArrayTemplate< T > *input)
viskores::cont::UnknownArrayHandle vtkDataArrayToUnknownArrayHandle(DataArrayType *input)
static const char * NoNameVTKFieldName()
Temporary name for arrays converted from VTK that do not have a name.
viskores::cont::ArrayHandleBasic< T > vtkSOADataArrayToComponentArrayHandle(vtkSOADataArrayTemplate< T > *input, int componentIndex)
#define vtkLog(verbosity_name, x)
Add to log given the verbosity level.