mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-19 18:45:43 +00:00
8b133288ce
There was an error that caused deprecation warnings in VTK-m to be suppressed, which meant that many uses of deprecated features went unnoticed. This fixes those deprecation warnings. The majority of the warnings were caused by the use of the deprecated `Cast`, `CopyTo`, and `ResetTypes` methods of `UnknownArrayHandle` (or `VariantArrayHandle`). Both `Cast` and `CopyTo` have been subsumed by `AsArrayHandle` (to make the functionality more clear). `ResetTypes` now requires a second template argument to define the storage types to try. Also fixed some issues with `SerializableField` being deprecated. This class is no longer necessary because `Field` can now be directly serialized.
69 lines
2.3 KiB
C++
69 lines
2.3 KiB
C++
//============================================================================
|
|
// 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.
|
|
//============================================================================
|
|
|
|
#include <vtkm/filter/ImageConnectivity.h>
|
|
|
|
#include <vtkm/cont/DataSet.h>
|
|
|
|
#include <vtkm/cont/DataSetBuilderUniform.h>
|
|
#include <vtkm/cont/testing/Testing.h>
|
|
|
|
namespace
|
|
{
|
|
|
|
vtkm::cont::DataSet MakeTestDataSet()
|
|
{
|
|
// example from Figure 35.7 of Connected Component Labeling in CUDA by OndˇrejˇŚtava,
|
|
// Bedˇrich Beneˇ
|
|
std::vector<vtkm::UInt8> pixels{
|
|
0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0,
|
|
0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0,
|
|
};
|
|
|
|
vtkm::cont::DataSetBuilderUniform builder;
|
|
vtkm::cont::DataSet dataSet = builder.Create(vtkm::Id3(8, 8, 1));
|
|
|
|
dataSet.AddPointField("color", pixels);
|
|
|
|
return dataSet;
|
|
}
|
|
|
|
void TestImageConnectivity()
|
|
{
|
|
vtkm::cont::DataSet dataSet = MakeTestDataSet();
|
|
|
|
vtkm::filter::ImageConnectivity connectivity;
|
|
connectivity.SetActiveField("color");
|
|
|
|
const vtkm::cont::DataSet outputData = connectivity.Execute(dataSet);
|
|
|
|
auto temp = outputData.GetField("component").GetData();
|
|
vtkm::cont::ArrayHandle<vtkm::Id> resultArrayHandle;
|
|
temp.AsArrayHandle(resultArrayHandle);
|
|
|
|
std::vector<vtkm::Id> componentExpected = { 0, 1, 1, 1, 0, 1, 1, 2, 0, 0, 0, 1, 0, 1, 1, 2,
|
|
0, 1, 1, 0, 0, 1, 1, 2, 0, 1, 0, 0, 0, 1, 1, 2,
|
|
0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1,
|
|
0, 1, 0, 1, 1, 1, 3, 3, 0, 1, 1, 1, 1, 1, 3, 3 };
|
|
|
|
for (vtkm::Id i = 0; i < resultArrayHandle.GetNumberOfValues(); ++i)
|
|
{
|
|
VTKM_TEST_ASSERT(
|
|
test_equal(resultArrayHandle.ReadPortal().Get(i), componentExpected[size_t(i)]),
|
|
"Wrong result for ImageConnectivity");
|
|
}
|
|
}
|
|
}
|
|
|
|
int UnitTestImageConnectivityFilter(int argc, char* argv[])
|
|
{
|
|
return vtkm::cont::testing::Testing::Run(TestImageConnectivity, argc, argv);
|
|
}
|