Commit a4aa42c0 authored by Kenneth Moreland's avatar Kenneth Moreland
Browse files

Avoid "weird" arrays in fields

In some of the tests there was a field that was using a counting array.
This uses an integer as the value type and has a special implicit
storage type. Currently, this is likely to cause problems whenever it
runs into a cast and call of a dynamic array. For now, let's avoid
these.

In the near future we should have expanded virtual method capabilities
that will make it possible to support these atypical arrays.
parent 6a6ac7cd
......@@ -19,12 +19,15 @@
// this software.
//
//=============================================================================
#include <vtkm/cont/testing/MakeTestDataSet.h>
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/filter/MarchingCubes.h>
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/worklet/connectivities/CellSetConnectivity.h>
#include <vtkm/cont/testing/MakeTestDataSet.h>
#include <vtkm/cont/testing/Testing.h>
class TangleField : public vtkm::worklet::WorkletMapField
{
public:
......@@ -94,7 +97,9 @@ static vtkm::cont::DataSet MakeIsosurfaceTestDataSet(vtkm::Id3 dims)
tangleFieldDispatcher.Invoke(vertexCountImplicitArray, pointFieldArray);
vtkm::Id numCells = dims[0] * dims[1] * dims[2];
auto cellFieldArray = vtkm::cont::make_ArrayHandleCounting<vtkm::Id>(0, 1, numCells);
vtkm::cont::ArrayHandle<vtkm::FloatDefault> cellFieldArray;
vtkm::cont::ArrayCopy(vtkm::cont::make_ArrayHandleCounting<vtkm::Id>(0, 1, numCells),
cellFieldArray);
vtkm::Vec<vtkm::FloatDefault, 3> origin(0.0f, 0.0f, 0.0f);
vtkm::Vec<vtkm::FloatDefault, 3> spacing(1.0f / static_cast<vtkm::FloatDefault>(dims[0]),
......
......@@ -19,6 +19,7 @@
//============================================================================
#include <vtkm/Math.h>
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
#include <vtkm/cont/CellSetSingleType.h>
#include <vtkm/cont/DataSet.h>
......@@ -100,7 +101,9 @@ vtkm::cont::DataSet MakeIsosurfaceTestDataSet(vtkm::Id3 dims)
tangleFieldDispatcher.Invoke(vertexCountImplicitArray, pointFieldArray);
vtkm::Id numCells = dims[0] * dims[1] * dims[2];
auto cellFieldArray = vtkm::cont::make_ArrayHandleCounting<vtkm::Id>(0, 1, numCells);
vtkm::cont::ArrayHandle<vtkm::FloatDefault> cellFieldArray;
vtkm::cont::ArrayCopy(vtkm::cont::make_ArrayHandleCounting<vtkm::Id>(0, 1, numCells),
cellFieldArray);
vtkm::Vec<vtkm::FloatDefault, 3> origin(0.0f, 0.0f, 0.0f);
vtkm::Vec<vtkm::FloatDefault, 3> spacing(1.0f / static_cast<vtkm::FloatDefault>(dims[0]),
......@@ -246,7 +249,9 @@ inline vtkm::cont::DataSet MakeRadiantDataSet::Make3DRadiantDataSet(vtkm::IdComp
DataArrayHandle distanceToOrigin(coordinates);
DataArrayHandle distanceToOther(coordinates, EuclideanNorm(CoordType(1., 1., 1.)));
auto cellFieldArray = vtkm::cont::make_ArrayHandleCounting<vtkm::Id>(0, 1, nCells);
vtkm::cont::ArrayHandle<vtkm::FloatDefault> cellFieldArray;
vtkm::cont::ArrayCopy(vtkm::cont::make_ArrayHandleCounting<vtkm::Id>(0, 1, nCells),
cellFieldArray);
ConnectivityArrayHandle connectivity(
vtkm::cont::ArrayHandleCounting<vtkm::Id>(0, 1, nCells * HexTraits::NUM_POINTS),
......@@ -287,7 +292,7 @@ void TestMarchingCubesUniformGrid()
dataSet.GetCellSet().CopyTo(cellSet);
vtkm::cont::ArrayHandle<vtkm::Float32> pointFieldArray;
dataSet.GetField("nodevar").GetData().CopyTo(pointFieldArray);
vtkm::cont::ArrayHandleCounting<vtkm::Id> cellFieldArray;
vtkm::cont::ArrayHandle<vtkm::FloatDefault> cellFieldArray;
dataSet.GetField("cellvar").GetData().CopyTo(cellFieldArray);
vtkm::worklet::MarchingCubes isosurfaceFilter;
......@@ -309,7 +314,7 @@ void TestMarchingCubesUniformGrid()
scalarsArray = isosurfaceFilter.ProcessPointField(pointFieldArray, DeviceAdapter());
vtkm::cont::ArrayHandle<vtkm::Id> cellFieldArrayOut;
vtkm::cont::ArrayHandle<vtkm::FloatDefault> cellFieldArrayOut;
cellFieldArrayOut = isosurfaceFilter.ProcessCellField(cellFieldArray, DeviceAdapter());
std::cout << "vertices: ";
......@@ -378,10 +383,10 @@ void TestMarchingCubesExplicit()
scalars = marchingCubes.ProcessPointField(projectedArray, DeviceAdapter());
vtkm::cont::ArrayHandle<vtkm::Id> cellFieldArray;
vtkm::cont::ArrayHandle<vtkm::FloatDefault> cellFieldArray;
dataSet.GetField("cellvar").GetData().CopyTo(cellFieldArray);
vtkm::cont::ArrayHandle<vtkm::Id> cellFieldArrayOut;
vtkm::cont::ArrayHandle<vtkm::FloatDefault> cellFieldArrayOut;
cellFieldArrayOut = marchingCubes.ProcessCellField(cellFieldArray, DeviceAdapter());
std::cout << "vertices: ";
......@@ -407,9 +412,13 @@ void TestMarchingCubesExplicit()
"Wrong scalars result for MarchingCubes filter");
}
void TestMarchingCubes()
{
TestMarchingCubesUniformGrid();
TestMarchingCubesExplicit();
}
int UnitTestMarchingCubes(int, char* [])
{
int result1 = vtkm::cont::testing::Testing::Run(TestMarchingCubesUniformGrid);
int result2 = vtkm::cont::testing::Testing::Run(TestMarchingCubesExplicit);
return result1 == 0 && result2 == 0;
return vtkm::cont::testing::Testing::Run(TestMarchingCubes);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment