Commit 65077ad1 authored by Robert Maynard's avatar Robert Maynard Committed by Kitware Robot
Browse files

Merge topic 'connected_component'

1a13324a Merge branch 'master' into connected_component
e058aaeb

 extend CellSetConnectivity to CellSetUniform and CellSetExplicit
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: default avatarRobert Maynard <robert.maynard@kitware.com>
Merge-request: !1104
parents d3fe1a6b 1a13324a
......@@ -109,11 +109,11 @@ public:
struct degree2
{
VTKM_EXEC
bool operator()(vtkm::Id degree) const { return degree == 2; }
bool operator()(vtkm::Id degree) const { return degree >= 2; }
};
template <typename T>
void EdgeToCellConnectivity(const vtkm::cont::CellSetSingleType<T>& cellSet,
template <typename CellSet>
void EdgeToCellConnectivity(const CellSet& cellSet,
vtkm::cont::ArrayHandle<vtkm::Id>& cellIds,
vtkm::cont::ArrayHandle<vtkm::Id2>& cellEdges) const
{
......@@ -128,8 +128,8 @@ public:
edgeExtractDisp.Invoke(cellSet, cellIds, cellEdges);
}
template <typename T>
void Run(const vtkm::cont::CellSetSingleType<T>& cellSet,
template <typename CellSetType>
void Run(const CellSetType& cellSet,
vtkm::cont::ArrayHandle<vtkm::Id>& numIndicesArray,
vtkm::cont::ArrayHandle<vtkm::Id>& indexOffsetArray,
vtkm::cont::ArrayHandle<vtkm::Id>& connectivityArray) const
......
......@@ -144,7 +144,41 @@ public:
"Wrong number of connected components");
}
void operator()() const { this->TestTangleIsosurface(); }
void TestExplicitDataSet() const
{
vtkm::cont::DataSet dataSet = vtkm::cont::testing::MakeTestDataSet().Make3DExplicitDataSet5();
auto cellSet = dataSet.GetCellSet().Cast<vtkm::cont::CellSetExplicit<>>();
vtkm::cont::ArrayHandle<vtkm::Id> componentArray;
CellSetConnectivity().Run(cellSet, componentArray, DeviceAdapter());
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
Algorithm::Sort(componentArray);
Algorithm::Unique(componentArray);
VTKM_TEST_ASSERT(componentArray.GetNumberOfValues() == 1,
"Wrong number of connected components");
}
void TestUniformDataSet() const
{
vtkm::cont::DataSet dataSet = vtkm::cont::testing::MakeTestDataSet().Make3DUniformDataSet1();
auto cellSet = dataSet.GetCellSet();
vtkm::cont::ArrayHandle<vtkm::Id> componentArray;
CellSetConnectivity().Run(cellSet, componentArray, DeviceAdapter());
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
Algorithm::Sort(componentArray);
Algorithm::Unique(componentArray);
VTKM_TEST_ASSERT(componentArray.GetNumberOfValues() == 1,
"Wrong number of connected components");
}
void operator()() const {
this->TestTangleIsosurface();
this->TestExplicitDataSet();
this->TestUniformDataSet();
}
};
int UnitTestCellSetConnectivity(int, char* [])
......
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