Commit 82c3f1a3 authored by Sujin Philip's avatar Sujin Philip

Add vtkmDataSet and vtkmDataArray

1. `vtkmDataSet` is a subclass of `vtkDataSet` and wraps a Vtk-m dataset.
2. `vtkmDataArray` is a subclass of `vtkDataArray` and wraps a Vtk-m `ArrayHandle`.
parent 8210f90c
......@@ -27,7 +27,8 @@ set(private_headers
vtkmlib/DataSetConverters.h
vtkmlib/Portals.hxx
vtkmlib/PortalTraits.h
vtkmlib/Storage.hxx)
vtkmlib/Storage.hxx
vtkmDataArray.hxx)
set(impl_classes
vtkmAverageToCells
......@@ -39,6 +40,8 @@ set(impl_classes
vtkmConnectivityExec
vtkmContour
vtkmCoordinateSystemTransform
vtkmDataArray
vtkmDataSet
vtkmExternalFaces
vtkmExtractVOI
vtkmGradient
......
vtk_add_test_cxx(vtkAcceleratorsVTKmCxxTests tests
vtk_add_test_cxx(vtkAcceleratorsVTKmCxxTests1 tests1
TestVTKMCleanGrid.cxx
TestVTKMCoordinateSystemTransform.cxx,NO_VALID
TestVTKMClip.cxx
......@@ -24,11 +24,22 @@ vtk_add_test_cxx(vtkAcceleratorsVTKmCxxTests tests
TestVTKMWarpVector.cxx
)
# We are splitting the tests into two executables to workaround an issue in
# cuda. With all the tests in the same executable several tests are failing
# in cuda. We have not identified the root cause of the problem yet.
vtk_add_test_cxx(vtkAcceleratorsVTKmCxxTests2 tests2
TestVTKMDataArray.cxx,NO_VALID
TestVTKMDataSet.cxx,NO_VALID
)
if (TARGET vtkm::cuda)
#the enable_language call is scoped! so we have to re-enable
#cuda in the test directory
enable_language(CUDA)
foreach(src IN LISTS tests)
foreach(src IN LISTS tests1)
set_source_files_properties(${src}.cxx PROPERTIES LANGUAGE "CUDA")
endforeach()
foreach(src IN LISTS tests2)
set_source_files_properties(${src}.cxx PROPERTIES LANGUAGE "CUDA")
endforeach()
......@@ -44,12 +55,17 @@ if (TARGET vtkm::cuda)
endif()
vtk_test_cxx_executable(vtkAcceleratorsVTKmCxxTests tests
vtk_test_cxx_executable(vtkAcceleratorsVTKmCxxTests1 tests1
RENDERING_FACTORY
)
vtk_test_cxx_executable(vtkAcceleratorsVTKmCxxTests2 tests2
RENDERING_FACTORY
)
if (TARGET vtkm::cuda)
# When cuda is enabled VTK::AcceleratorsVTKm is built statically but with fpic
# enabled so the tests are also built with fpic enabled
set_target_properties(vtkAcceleratorsVTKmCxxTests PROPERTIES POSITION_INDEPENDENT_CODE ON)
set_target_properties(vtkAcceleratorsVTKmCxxTests1 PROPERTIES POSITION_INDEPENDENT_CODE ON)
set_target_properties(vtkAcceleratorsVTKmCxxTests2 PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()
#include "vtkmDataArray.h"
#include "vtkSmartPointer.h"
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/ArrayHandleConstant.h>
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
#include <vector>
namespace
{
//-----------------------------------------------------------------------------
class TestError
{
public:
TestError(const std::string& message, int line)
: Message(message), Line(line)
{
}
void PrintMessage(std::ostream& out) const
{
out << "Error at line " << this->Line << ": " << this->Message << "\n";
}
private:
std::string Message;
int Line;
};
#define RAISE_TEST_ERROR(msg) throw TestError((msg), __LINE__)
#define TEST_VERIFY(cond, msg) if (!(cond)) RAISE_TEST_ERROR((msg))
inline bool IsEqualFloat(double a, double b, double e = 1e-6f)
{
return (std::abs(a - b) <= e);
}
//-----------------------------------------------------------------------------
template <typename ArrayHandleType>
void TestWithArrayHandle(const ArrayHandleType& vtkmArray)
{
vtkSmartPointer<vtkDataArray> vtkArray;
vtkArray.TakeReference(make_vtkmDataArray(vtkmArray));
auto vtkmPortal = vtkmArray.GetPortalConstControl();
vtkIdType length = vtkArray->GetNumberOfTuples();
std::cout << "Length: " << length << "\n";
TEST_VERIFY(length == vtkmArray.GetNumberOfValues(), "Array lengths don't match");
int numberOfComponents = vtkArray->GetNumberOfComponents();
std::cout << "Number of components: " << numberOfComponents << "\n";
TEST_VERIFY(
numberOfComponents ==
internal::FlattenVec<typename ArrayHandleType::ValueType>::GetNumberOfComponents(vtkmPortal.Get(0)),
"Number of components don't match");
for (vtkIdType i = 0; i < length; ++i)
{
double tuple[9];
vtkArray->GetTuple(i, tuple);
auto val = vtkmPortal.Get(i);
for (int j = 0; j < numberOfComponents; ++j)
{
auto comp = internal::FlattenVec<typename ArrayHandleType::ValueType>::GetComponent(val, j);
TEST_VERIFY (IsEqualFloat(tuple[j], static_cast<double>(comp)), "values don't match");
TEST_VERIFY (IsEqualFloat(vtkArray->GetComponent(i, j), static_cast<double>(comp)),
"values don't match");
}
}
}
} // anonymous namespace
//-----------------------------------------------------------------------------
int TestVTKMDataArray(int, char*[])
try
{
static const std::vector<double> testData = { 3.0, 6.0, 2.0, 5.0, 1.0, 0.0, 4.0 };
std::cout << "Testing with Basic ArrayHandle\n";
TestWithArrayHandle(vtkm::cont::make_ArrayHandle(testData));
std::cout << "Passed\n";
std::cout << "Testing with ArrayHandleConstant\n";
TestWithArrayHandle(vtkm::cont::make_ArrayHandleConstant(vtkm::Vec<vtkm::Vec<float, 3>, 3>{{1.0f, 2.0f, 3.0f}}, 10));
std::cout << "Passed\n";
std::cout << "Testing with ArrayHandleUniformPointCoordinates\n";
TestWithArrayHandle(vtkm::cont::ArrayHandleUniformPointCoordinates(vtkm::Id3{3}));
std::cout << "Passed\n";
return EXIT_SUCCESS;
}
catch (const TestError& e)
{
e.PrintMessage(std::cout);
return 1;
}
This diff is collapsed.
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//
// Copyright 2019 Sandia Corporation.
// Copyright 2019 UT-Battelle, LLC.
// Copyright 2019 Los Alamos National Security.
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// the U.S. Government retains certain rights in this software.
//
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#define vtkmDataArray_cxx
#include "vtkmDataArray.h"
template class VTKACCELERATORSVTKM_EXPORT vtkmDataArray<char>;
template class VTKACCELERATORSVTKM_EXPORT vtkmDataArray<double>;
template class VTKACCELERATORSVTKM_EXPORT vtkmDataArray<float>;
template class VTKACCELERATORSVTKM_EXPORT vtkmDataArray<int>;
template class VTKACCELERATORSVTKM_EXPORT vtkmDataArray<long>;
template class VTKACCELERATORSVTKM_EXPORT vtkmDataArray<long long>;
template class VTKACCELERATORSVTKM_EXPORT vtkmDataArray<short>;
template class VTKACCELERATORSVTKM_EXPORT vtkmDataArray<signed char>;
template class VTKACCELERATORSVTKM_EXPORT vtkmDataArray<unsigned char>;
template class VTKACCELERATORSVTKM_EXPORT vtkmDataArray<unsigned int>;
template class VTKACCELERATORSVTKM_EXPORT vtkmDataArray<unsigned long>;
template class VTKACCELERATORSVTKM_EXPORT vtkmDataArray<unsigned long long>;
template class VTKACCELERATORSVTKM_EXPORT vtkmDataArray<unsigned short>;
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//
// Copyright 2019 Sandia Corporation.
// Copyright 2019 UT-Battelle, LLC.
// Copyright 2019 Los Alamos National Security.
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// the U.S. Government retains certain rights in this software.
//
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#ifndef __VTK_WRAP__
#ifndef VTK_WRAPPING_CXX
#ifndef vtkmDataArray_h
#define vtkmDataArray_h
#include "vtkAcceleratorsVTKmModule.h" // For export macro
#include "vtkmConfig.h" // For template export
#include "vtkGenericDataArray.h"
#include <vtkm/BaseComponent.h> // For vtkm::BaseComponent
#include <vtkm/cont/ArrayHandle.h> // For vtkm::cont::ArrayHandle
#include <vtkm/cont/VariantArrayHandle.h> // For vtkm::cont::VariantArrayHandle
#include <vtkm/ListTag.h> // For vtkm::ListTagBase
#include <vtkm/VecFromPortal.h> // For vtkm::VecFromPortal
#include <memory> // For unique_ptr
namespace internal
{
template <typename T>
class ArrayHandleWrapperBase;
} // internal
template <typename T>
class vtkmDataArray : public vtkGenericDataArray<vtkmDataArray<T>, T>
{
static_assert(std::is_arithmetic<T>::value, "T must be an integral or floating-point type");
using GenericDataArrayType = vtkGenericDataArray<vtkmDataArray<T>, T>;
public:
using SelfType = vtkmDataArray<T>;
vtkTemplateTypeMacro(SelfType, GenericDataArrayType);
using typename Superclass::ValueType;
using VtkmTypesList =
vtkm::ListTagBase<T,
vtkm::Vec<T, 2>,
vtkm::Vec<T, 3>,
vtkm::Vec<T, 4>,
vtkm::VecFromPortal<typename vtkm::cont::ArrayHandle<T>::PortalControl>>;
static vtkmDataArray* New();
template <typename V, typename S>
void SetVtkmArrayHandle(const vtkm::cont::ArrayHandle<V, S>& ah);
vtkm::cont::VariantArrayHandle GetVtkmVariantArrayHandle() const;
/// concept methods for \c vtkGenericDataArray
ValueType GetValue(vtkIdType valueIdx) const;
void SetValue(vtkIdType valueIdx, ValueType value);
void GetTypedTuple(vtkIdType tupleIdx, ValueType* tuple) const;
void SetTypedTuple(vtkIdType tupleIdx, const ValueType* tuple);
ValueType GetTypedComponent(vtkIdType tupleIdx, int compIdx) const;
void SetTypedComponent(vtkIdType tupleIdx, int compIdx, ValueType value);
protected:
vtkmDataArray();
~vtkmDataArray();
/// concept methods for \c vtkGenericDataArray
bool AllocateTuples(vtkIdType numTuples);
bool ReallocateTuples(vtkIdType numTuples);
private:
vtkmDataArray(const vtkmDataArray&) = delete;
void operator=(const vtkmDataArray&) = delete;
// To access AllocateTuples and ReallocateTuples
friend Superclass;
std::unique_ptr<internal::ArrayHandleWrapperBase<T>> VtkmArray;
};
//=============================================================================
template <typename T, typename S>
inline vtkmDataArray<typename vtkm::BaseComponent<T>::Type>*
make_vtkmDataArray(const vtkm::cont::ArrayHandle<T, S>& ah)
{
auto ret = vtkmDataArray<typename vtkm::BaseComponent<T>::Type>::New();
ret->SetVtkmArrayHandle(ah);
return ret;
}
//=============================================================================
#ifndef vtkmDataArray_cxx
extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT vtkmDataArray<char>;
extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT vtkmDataArray<double>;
extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT vtkmDataArray<float>;
extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT vtkmDataArray<int>;
extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT vtkmDataArray<long>;
extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT vtkmDataArray<long long>;
extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT vtkmDataArray<short>;
extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT vtkmDataArray<signed char>;
extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT vtkmDataArray<unsigned char>;
extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT vtkmDataArray<unsigned int>;
extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT vtkmDataArray<unsigned long>;
extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT vtkmDataArray<unsigned long long>;
extern template class VTKACCELERATORSVTKM_TEMPLATE_EXPORT vtkmDataArray<unsigned short>;
#endif // vtkmDataArray_cxx
#endif // vtkmDataArray_h
#include "vtkmDataArray.hxx"
#endif
#endif
// VTK-HeaderTest-Exclude: vtkmDataArray.h
This diff is collapsed.
This diff is collapsed.
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//
// Copyright 2015 Sandia Corporation.
// Copyright 2015 UT-Battelle, LLC.
// Copyright 2015 Los Alamos National Security.
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// the U.S. Government retains certain rights in this software.
//
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#ifndef vtkmDataSet_h
#define vtkmDataSet_h
#include "vtkAcceleratorsVTKmModule.h" // For export macro
#include "vtkDataSet.h"
#include <memory> // for std::shared_ptr
namespace vtkm
{
namespace cont
{
class DataSet;
}
} // vtkm::cont
class vtkPoints;
class vtkCell;
class vtkGenericCell;
class VTKACCELERATORSVTKM_EXPORT vtkmDataSet : public vtkDataSet
{
public:
vtkTypeMacro(vtkmDataSet, vtkDataSet);
void PrintSelf(ostream& os, vtkIndent indent) override;
static vtkmDataSet* New();
void SetVtkmDataSet(const vtkm::cont::DataSet& ds);
vtkm::cont::DataSet GetVtkmDataSet() const;
/**
* Copy the geometric and topological structure of an object. Note that
* the invoking object and the object pointed to by the parameter ds must
* be of the same type.
*/
void CopyStructure(vtkDataSet *ds) override;
/**
* Determine the number of points composing the dataset.
*/
vtkIdType GetNumberOfPoints() override;
/**
* Determine the number of cells composing the dataset.
*/
vtkIdType GetNumberOfCells() override;
/**
* Get point coordinates with ptId such that: 0 <= ptId < NumberOfPoints.
*/
double *GetPoint(vtkIdType ptId) VTK_SIZEHINT(3) override;
/**
* Copy point coordinates into user provided array x[3] for specified
* point id.
*/
void GetPoint(vtkIdType id, double x[3]) override;
using vtkDataSet::GetCell;
/**
* Get cell with cellId such that: 0 <= cellId < NumberOfCells.
*/
vtkCell *GetCell(vtkIdType cellId) override;
void GetCell(vtkIdType cellId, vtkGenericCell *cell) override;
/**
* Get the bounds of the cell with cellId such that:
* 0 <= cellId < NumberOfCells.
*/
void GetCellBounds(vtkIdType cellId, double bounds[6]) override;
/**
* Get type of cell with cellId such that: 0 <= cellId < NumberOfCells.
*/
int GetCellType(vtkIdType cellId) override;
/**
* Topological inquiry to get points defining cell.
*/
void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds) override;
/**
* Topological inquiry to get cells using point.
*/
void GetPointCells(vtkIdType ptId, vtkIdList *cellIds) override;
//@{
/**
* Locate the closest point to the global coordinate x. Return the
* point id. If point id < 0; then no point found. (This may arise
* when point is outside of dataset.)
*/
vtkIdType FindPoint(double x[3]) override;
//@}
/**
* Locate cell based on global coordinate x and tolerance
* squared. If cell and cellId is non-nullptr, then search starts from
* this cell and looks at immediate neighbors. Returns cellId >= 0
* if inside, < 0 otherwise. The parametric coordinates are
* provided in pcoords[3]. The interpolation weights are returned in
* weights[]. (The number of weights is equal to the number of
* points in the found cell). Tolerance is used to control how close
* the point is to be considered "in" the cell.
*/
vtkIdType FindCell(double x[3], vtkCell *cell, vtkIdType cellId,
double tol2, int& subId, double pcoords[3],
double *weights) override;
/**
* This is a version of the above method that can be used with
* multithreaded applications. A vtkGenericCell must be passed in
* to be used in internal calls that might be made to GetCell()
*/
vtkIdType FindCell(double x[3], vtkCell *cell,
vtkGenericCell *gencell, vtkIdType cellId,
double tol2, int& subId, double pcoords[3],
double *weights) override;
/**
* Reclaim any extra memory used to store data.
*/
void Squeeze() override;
/**
* Compute the data bounding box from data points.
*/
void ComputeBounds() override;
/**
* Restore data object to initial state.
* THIS METHOD IS NOT THREAD SAFE.
*/
void Initialize() override;
/**
* Convenience method returns largest cell size in dataset. This is generally
* used to allocate memory for supporting data structures.
*/
int GetMaxCellSize() override;
/**
* Return the actual size of the data in kibibytes (1024 bytes). This number
* is valid only after the pipeline has updated. The memory size
* returned is guaranteed to be greater than or equal to the
* memory required to represent the data (e.g., extra space in
* arrays, etc. are not included in the return value).
*/
unsigned long GetActualMemorySize() override;
/**
* Return the type of data object.
*/
int GetDataObjectType() override { return VTK_DATA_SET; }
//@{
/**
* Shallow and Deep copy.
*/
void ShallowCopy(vtkDataObject *src) override;
void DeepCopy(vtkDataObject *src) override;
//@}
protected:
vtkmDataSet();
~vtkmDataSet() override;
private:
vtkmDataSet(const vtkmDataSet&) = delete;
void operator=(const vtkmDataSet&) = delete;
struct DataMembers;
std::shared_ptr<DataMembers> Internals;
};
#endif // vtkmDataSet_h
// VTK-HeaderTest-Exclude: vtkmDataSet.h
......@@ -16,9 +16,11 @@
#include "ArrayConverters.h"
#include "Storage.h"
#include "vtkmDataArray.h"
#include "vtkmFilterPolicy.h"
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/ArrayHandleVirtual.h>
#include <vtkm/cont/CoordinateSystem.hxx>
#include <vtkm/cont/DataSet.h>
......@@ -206,6 +208,26 @@ vtkm::cont::Field Convert(DataArrayType* input, int association)
return vtkm::cont::Field();
}
template <typename T>
vtkm::cont::Field Convert(vtkmDataArray<T>* input, int association)
{
// we need to switch on if we are a cell or point field first!
// The problem is that the constructor signature for fields differ based
// on if they are a cell or point field.
if (association == vtkDataObject::FIELD_ASSOCIATION_POINTS)
{
return vtkm::cont::Field(input->GetName(), vtkm::cont::Field::Association::POINTS,
input->GetVtkmVariantArrayHandle());
}
else if (association == vtkDataObject::FIELD_ASSOCIATION_CELLS)
{
return vtkm::cont::Field(input->GetName(), vtkm::cont::Field::Association::CELL_SET, "cells",
input->GetVtkmVariantArrayHandle());
}
return vtkm::cont::Field();
}
// determine the type and call the proper Convert routine
vtkm::cont::Field Convert(vtkDataArray* input, int association)
{
......@@ -224,14 +246,17 @@ vtkm::cont::Field Convert(vtkDataArray* input, int association)
switch (input->GetDataType())
{
vtkTemplateMacro(
vtkAOSDataArrayTemplate<VTK_TT>* typedIn =
vtkAOSDataArrayTemplate<VTK_TT>* typedIn1 =
vtkAOSDataArrayTemplate<VTK_TT>::FastDownCast(input);
if (typedIn) { field = Convert(typedIn, association); } else {
if (typedIn1) { field = Convert(typedIn1, association); }
else {
vtkSOADataArrayTemplate<VTK_TT>* typedIn2 =
vtkSOADataArrayTemplate<VTK_TT>::FastDownCast(input);
if (typedIn2)
{
field = Convert(typedIn2, association);
if (typedIn2) { field = Convert(typedIn2, association); }
else {
vtkmDataArray<VTK_TT>* typedIn3 =
vtkmDataArray<VTK_TT>::SafeDownCast(input);
if (typedIn3) { field = Convert(typedIn3, association); }
}
});
// end vtkTemplateMacro
......@@ -245,93 +270,8 @@ namespace fromvtkm {
namespace {
template <typename T> struct CopyArrayContents {};
template <> struct CopyArrayContents<tovtkm::vtkPortalOfVecOfVecValues>
{
template <typename PortalType, typename U>
void operator()(const PortalType& portal, U* array, vtkIdType numValues) const
{
using Traits = tovtkm::vtkPortalTraits<typename PortalType::ValueType>;
// slow path for NxM component arrays
vtkIdType index = 0;
for (vtkIdType i = 0; i < numValues; ++i)
{
auto v = portal.Get(i);
for (vtkm::IdComponent j = 0; j < Traits::NUM_COMPONENTS_OUTER; ++j)
{
auto c = v[i];
for (vtkm::IdComponent k = 0; k < Traits::NUM_COMPONENTS_INNER; ++k, ++index)
{
array->SetValue(index, c[k]);
}
}
}
}
};
template <> struct CopyArrayContents<tovtkm::vtkPortalOfVecOfValues>
{
template <typename PortalType, typename U>
void operator()(const PortalType& portal, U* array, vtkIdType numValues) const
{
using Traits = tovtkm::vtkPortalTraits<typename PortalType::ValueType>;
// slow path for N component arrays
vtkIdType index = 0;
for (vtkIdType i = 0; i < numValues; ++i)
{
auto v = portal.Get(i);
for (vtkm::IdComponent j = 0; j < Traits::NUM_COMPONENTS; ++j, ++index)
{
array->SetValue(index, v[j]);
}
}
}
};
template <> struct CopyArrayContents<tovtkm::vtkPortalOfScalarValues>
{
template <typename PortalType, typename U>
void operator()(const PortalType& portal, U* array, vtkIdType numValues) const
{
// fast path for single component arrays, can't steal the memory
// since the storage types isn't one we know
for (vtkIdType i = 0; i < numValues; ++i)
{
array->SetValue(i, portal.Get(i));
}
}
};
struct ArrayConverter
{
private:
template <typename T, typename S>
void CopyEachValue(vtkm::cont::ArrayHandle<T, S> &handle) const
{
// we need to make a copy
using Traits = tovtkm::vtkPortalTraits<T>;
using ValueType = typename Traits::ComponentType;
using VTKArrayType = vtkAOSDataArrayTemplate<ValueType>;
const vtkIdType numValues = handle.GetNumberOfValues();
const vtkIdType numComps = Traits::NUM_COMPONENTS;
VTKArrayType *array = VTKArrayType::New();
array->SetNumberOfComponents(numComps);
array->SetNumberOfTuples(numValues);
// copy directly into the vtkarray
auto portal = handle.GetPortalConstControl();
// Need to do a compile time switch for copying a single component
// array versus a multiple component array
CopyArrayContents<typename Traits::TagType> copier;
copier(portal, array, numValues);
this->Data = array;
}
public:
mutable vtkDataArray* Data;
......@@ -343,7 +283,7 @@ public:
template <typename T, typename S>
void operator()(vtkm::cont::ArrayHandle<T, S> handle) const
{
this->CopyEachValue(handle);
this->Data = make_vtkmDataArray(handle);
}
template <typename T>
......@@ -366,7 +306,7 @@ public:
}
else
{
this->CopyEachValue( handle );
this->Data = make_vtkmDataArray(handle);
}
}
......
......@@ -24,6 +24,7 @@
#include "UnstructuredGridConverter.h"
#include "vtkmCellSetSingleType.h"
#include "vtkmDataArray.h"