mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
Fix MarchingCell for Wedge
Fixed error in one entry of number_of_triangles table for MarchineCells that results in missing triangles for wedge cell type as reported by issue #496.
This commit is contained in:
parent
f7741be0e1
commit
52f0d5b2d5
3
data/data/unstructured/box-with-errors.vtk
Normal file
3
data/data/unstructured/box-with-errors.vtk
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1e415c5dfd711901fdb0abb4dab2606b41c032938867200bdceebc13414b3bc8
|
||||
size 4045
|
@ -10,87 +10,121 @@
|
||||
|
||||
#include <vtkm/Math.h>
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/DataSetBuilderUniform.h>
|
||||
#include <vtkm/cont/DataSetFieldAdd.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/filter/CleanGrid.h>
|
||||
|
||||
#include <vtkm/filter/Contour.h>
|
||||
#include <vtkm/io/reader/VTKDataSetReader.h>
|
||||
#include <vtkm/source/Tangle.h>
|
||||
|
||||
namespace vtkm_ut_mc_filter
|
||||
namespace
|
||||
{
|
||||
|
||||
void TestContourUniformGrid()
|
||||
class TestContourFilter
|
||||
{
|
||||
std::cout << "Testing Contour filter on a uniform grid" << std::endl;
|
||||
|
||||
vtkm::Id3 dims(4, 4, 4);
|
||||
vtkm::source::Tangle tangle(dims);
|
||||
vtkm::cont::DataSet dataSet = tangle.Execute();
|
||||
|
||||
vtkm::filter::Contour mc;
|
||||
|
||||
mc.SetGenerateNormals(true);
|
||||
mc.SetIsoValue(0, 0.5);
|
||||
mc.SetActiveField("nodevar");
|
||||
mc.SetFieldsToPass(vtkm::filter::FieldSelection::MODE_NONE);
|
||||
|
||||
auto result = mc.Execute(dataSet);
|
||||
public:
|
||||
void TestContourUniformGrid() const
|
||||
{
|
||||
VTKM_TEST_ASSERT(result.GetNumberOfCoordinateSystems() == 1,
|
||||
"Wrong number of coordinate systems in the output dataset");
|
||||
//since normals is on we have one field
|
||||
VTKM_TEST_ASSERT(result.GetNumberOfFields() == 1,
|
||||
"Wrong number of fields in the output dataset");
|
||||
std::cout << "Testing Contour filter on a uniform grid" << std::endl;
|
||||
|
||||
vtkm::Id3 dims(4, 4, 4);
|
||||
vtkm::source::Tangle tangle(dims);
|
||||
vtkm::cont::DataSet dataSet = tangle.Execute();
|
||||
|
||||
vtkm::filter::Contour mc;
|
||||
|
||||
mc.SetGenerateNormals(true);
|
||||
mc.SetIsoValue(0, 0.5);
|
||||
mc.SetActiveField("nodevar");
|
||||
mc.SetFieldsToPass(vtkm::filter::FieldSelection::MODE_NONE);
|
||||
|
||||
auto result = mc.Execute(dataSet);
|
||||
{
|
||||
VTKM_TEST_ASSERT(result.GetNumberOfCoordinateSystems() == 1,
|
||||
"Wrong number of coordinate systems in the output dataset");
|
||||
//since normals is on we have one field
|
||||
VTKM_TEST_ASSERT(result.GetNumberOfFields() == 1,
|
||||
"Wrong number of fields in the output dataset");
|
||||
}
|
||||
|
||||
// let's execute with mapping fields.
|
||||
mc.SetFieldsToPass("nodevar");
|
||||
result = mc.Execute(dataSet);
|
||||
{
|
||||
const bool isMapped = result.HasField("nodevar");
|
||||
VTKM_TEST_ASSERT(isMapped, "mapping should pass");
|
||||
|
||||
VTKM_TEST_ASSERT(result.GetNumberOfFields() == 2,
|
||||
"Wrong number of fields in the output dataset");
|
||||
|
||||
vtkm::cont::CoordinateSystem coords = result.GetCoordinateSystem();
|
||||
vtkm::cont::DynamicCellSet dcells = result.GetCellSet();
|
||||
using CellSetType = vtkm::cont::CellSetSingleType<>;
|
||||
const CellSetType& cells = dcells.Cast<CellSetType>();
|
||||
|
||||
//verify that the number of points is correct (72)
|
||||
//verify that the number of cells is correct (160)
|
||||
VTKM_TEST_ASSERT(coords.GetNumberOfPoints() == 72,
|
||||
"Should have less coordinates than the unmerged version");
|
||||
VTKM_TEST_ASSERT(cells.GetNumberOfCells() == 160, "");
|
||||
}
|
||||
|
||||
//Now try with vertex merging disabled. Since this
|
||||
//we use FlyingEdges we now which does point merging for free
|
||||
//so we should see the number of points not change
|
||||
mc.SetMergeDuplicatePoints(false);
|
||||
mc.SetFieldsToPass(vtkm::filter::FieldSelection::MODE_ALL);
|
||||
result = mc.Execute(dataSet);
|
||||
{
|
||||
vtkm::cont::CoordinateSystem coords = result.GetCoordinateSystem();
|
||||
|
||||
VTKM_TEST_ASSERT(coords.GetNumberOfPoints() == 72,
|
||||
"Shouldn't have less coordinates than the unmerged version");
|
||||
|
||||
//verify that the number of cells is correct (160)
|
||||
vtkm::cont::DynamicCellSet dcells = result.GetCellSet();
|
||||
|
||||
using CellSetType = vtkm::cont::CellSetSingleType<>;
|
||||
const CellSetType& cells = dcells.Cast<CellSetType>();
|
||||
VTKM_TEST_ASSERT(cells.GetNumberOfCells() == 160, "");
|
||||
}
|
||||
}
|
||||
|
||||
// let's execute with mapping fields.
|
||||
mc.SetFieldsToPass("nodevar");
|
||||
result = mc.Execute(dataSet);
|
||||
void TestContourWedges() const
|
||||
{
|
||||
const bool isMapped = result.HasField("nodevar");
|
||||
VTKM_TEST_ASSERT(isMapped, "mapping should pass");
|
||||
auto pathname =
|
||||
vtkm::cont::testing::Testing::GetTestDataBasePath() + "/unstructured/box-with-errors.vtk";
|
||||
vtkm::io::reader::VTKDataSetReader reader(pathname);
|
||||
|
||||
VTKM_TEST_ASSERT(result.GetNumberOfFields() == 2,
|
||||
"Wrong number of fields in the output dataset");
|
||||
vtkm::cont::DataSet dataSet = reader.ReadDataSet();
|
||||
|
||||
vtkm::cont::CoordinateSystem coords = result.GetCoordinateSystem();
|
||||
vtkm::cont::DynamicCellSet dcells = result.GetCellSet();
|
||||
using CellSetType = vtkm::cont::CellSetSingleType<>;
|
||||
const CellSetType& cells = dcells.Cast<CellSetType>();
|
||||
vtkm::cont::CellSetExplicit<> cellSet;
|
||||
dataSet.GetCellSet().CopyTo(cellSet);
|
||||
|
||||
//verify that the number of points is correct (72)
|
||||
//verify that the number of cells is correct (160)
|
||||
VTKM_TEST_ASSERT(coords.GetNumberOfPoints() == 72,
|
||||
"Should have less coordinates than the unmerged version");
|
||||
VTKM_TEST_ASSERT(cells.GetNumberOfCells() == 160, "");
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> fieldArray;
|
||||
dataSet.GetPointField("gyroid").GetData().CopyTo(fieldArray);
|
||||
|
||||
vtkm::worklet::Contour isosurfaceFilter;
|
||||
isosurfaceFilter.SetMergeDuplicatePoints(false);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f_32> verticesArray;
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f_32> normalsArray;
|
||||
|
||||
auto result = isosurfaceFilter.Run(
|
||||
{ 0.0f }, cellSet, dataSet.GetCoordinateSystem(), fieldArray, verticesArray, normalsArray);
|
||||
VTKM_TEST_ASSERT(result.GetNumberOfCells() == 52);
|
||||
}
|
||||
|
||||
//Now try with vertex merging disabled. Since this
|
||||
//we use FlyingEdges we now which does point merging for free
|
||||
//so we should see the number of points not change
|
||||
mc.SetMergeDuplicatePoints(false);
|
||||
mc.SetFieldsToPass(vtkm::filter::FieldSelection::MODE_ALL);
|
||||
result = mc.Execute(dataSet);
|
||||
void operator()() const
|
||||
{
|
||||
vtkm::cont::CoordinateSystem coords = result.GetCoordinateSystem();
|
||||
|
||||
VTKM_TEST_ASSERT(coords.GetNumberOfPoints() == 72,
|
||||
"Shouldn't have less coordinates than the unmerged version");
|
||||
|
||||
//verify that the number of cells is correct (160)
|
||||
vtkm::cont::DynamicCellSet dcells = result.GetCellSet();
|
||||
|
||||
using CellSetType = vtkm::cont::CellSetSingleType<>;
|
||||
const CellSetType& cells = dcells.Cast<CellSetType>();
|
||||
VTKM_TEST_ASSERT(cells.GetNumberOfCells() == 160, "");
|
||||
this->TestContourUniformGrid();
|
||||
this->TestContourWedges();
|
||||
}
|
||||
}
|
||||
|
||||
}; // class TestContourFilter
|
||||
} // namespace
|
||||
|
||||
int UnitTestContourFilter(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(vtkm_ut_mc_filter::TestContourUniformGrid, argc, argv);
|
||||
return vtkm::cont::testing::Testing::Run(TestContourFilter{}, argc, argv);
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ VTKM_STATIC_CONSTEXPR_ARRAY vtkm::IdComponent NumTrianglesTable[] = {
|
||||
3, 4, 4, 5, 4, 5, 3, 4, 4, 5, 5, 2, 3, 4, 2, 1,
|
||||
2, 3, 3, 2, 3, 4, 2, 1, 3, 2, 4, 1, 2, 1, 1, 0,
|
||||
// CELL_SHAPE_WEDGE, case 0 - 63
|
||||
0, 1, 1, 2, 1, 2, 1, 1, 1, 2, 2, 3, 2, 3, 3, 2,
|
||||
0, 1, 1, 2, 1, 2, 2, 1, 1, 2, 2, 3, 2, 3, 3, 2,
|
||||
1, 2, 2, 3, 2, 3, 3, 2, 2, 3, 3, 2, 3, 4, 4, 1,
|
||||
1, 2, 2, 3, 2, 3, 3, 2, 2, 3, 3, 4, 3, 2, 4, 1,
|
||||
2, 3, 3, 4, 3, 4, 2, 1, 1, 2, 2, 1, 2, 1, 1, 0,
|
||||
|
Loading…
Reference in New Issue
Block a user