2014-05-01 23:19:54 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2014-05-01 23:19:54 +00:00
|
|
|
// 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.
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
|
|
|
|
|
|
|
#include <vtkm/cont/testing/Testing.h>
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace
|
|
|
|
{
|
2014-05-01 23:19:54 +00:00
|
|
|
|
2019-07-31 16:20:38 +00:00
|
|
|
using Vector3 = vtkm::Vec3f;
|
2014-10-09 14:54:56 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::Id3 DIMENSIONS(16, 18, 5);
|
2014-05-01 23:19:54 +00:00
|
|
|
const vtkm::Id NUM_POINTS = 1440;
|
|
|
|
|
2015-08-17 17:15:03 +00:00
|
|
|
const Vector3 ORIGIN(-20, 5, -10);
|
2014-10-09 14:54:56 +00:00
|
|
|
const Vector3 SPACING(10, 1, 0.1f);
|
2014-05-01 23:19:54 +00:00
|
|
|
|
|
|
|
void TestArrayHandleUniformPointCoordinates()
|
|
|
|
{
|
|
|
|
std::cout << "Creating ArrayHandleUniformPointCoordinates" << std::endl;
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::ArrayHandleUniformPointCoordinates arrayHandle(DIMENSIONS, ORIGIN, SPACING);
|
2014-05-01 23:19:54 +00:00
|
|
|
VTKM_TEST_ASSERT(arrayHandle.GetNumberOfValues() == NUM_POINTS,
|
|
|
|
"Array computed wrong number of points.");
|
|
|
|
|
|
|
|
std::cout << "Getting array portal." << std::endl;
|
2020-01-28 19:14:32 +00:00
|
|
|
vtkm::internal::ArrayPortalUniformPointCoordinates portal = arrayHandle.ReadPortal();
|
2017-05-18 14:29:41 +00:00
|
|
|
VTKM_TEST_ASSERT(portal.GetNumberOfValues() == NUM_POINTS, "Portal has wrong number of points.");
|
|
|
|
VTKM_TEST_ASSERT(portal.GetRange3() == DIMENSIONS, "Portal range is wrong.");
|
2014-05-01 23:19:54 +00:00
|
|
|
|
|
|
|
std::cout << "Checking computed values of portal." << std::endl;
|
2014-10-09 14:54:56 +00:00
|
|
|
Vector3 expectedValue;
|
2014-05-01 23:19:54 +00:00
|
|
|
vtkm::Id flatIndex = 0;
|
|
|
|
vtkm::Id3 blockIndex;
|
2015-08-17 17:15:03 +00:00
|
|
|
expectedValue[2] = ORIGIN[2];
|
|
|
|
for (blockIndex[2] = 0; blockIndex[2] < DIMENSIONS[2]; blockIndex[2]++)
|
2014-05-01 23:19:54 +00:00
|
|
|
{
|
2015-08-17 17:15:03 +00:00
|
|
|
expectedValue[1] = ORIGIN[1];
|
|
|
|
for (blockIndex[1] = 0; blockIndex[1] < DIMENSIONS[1]; blockIndex[1]++)
|
2014-05-01 23:19:54 +00:00
|
|
|
{
|
2015-08-17 17:15:03 +00:00
|
|
|
expectedValue[0] = ORIGIN[0];
|
|
|
|
for (blockIndex[0] = 0; blockIndex[0] < DIMENSIONS[0]; blockIndex[0]++)
|
2014-05-01 23:19:54 +00:00
|
|
|
{
|
|
|
|
VTKM_TEST_ASSERT(test_equal(expectedValue, portal.Get(flatIndex)),
|
|
|
|
"Got wrong value for flat index.");
|
|
|
|
|
|
|
|
VTKM_TEST_ASSERT(test_equal(expectedValue, portal.Get(blockIndex)),
|
|
|
|
"Got wrong value for block index.");
|
|
|
|
|
|
|
|
flatIndex++;
|
|
|
|
expectedValue[0] += SPACING[0];
|
|
|
|
}
|
|
|
|
expectedValue[1] += SPACING[1];
|
|
|
|
}
|
|
|
|
expectedValue[2] += SPACING[2];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // anonymous namespace
|
|
|
|
|
2019-01-01 22:19:02 +00:00
|
|
|
int UnitTestArrayHandleUniformPointCoordinates(int argc, char* argv[])
|
2014-05-01 23:19:54 +00:00
|
|
|
{
|
2019-01-01 22:19:02 +00:00
|
|
|
return vtkm::cont::testing::Testing::Run(TestArrayHandleUniformPointCoordinates, argc, argv);
|
2014-05-01 23:19:54 +00:00
|
|
|
}
|