Merge topic 'correct_flying_edge_cellid'

748f8f8c3 Correct flying edge cell-id mapping

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Matt Larsen <larsen30@llnl.gov>
Merge-request: !2124
This commit is contained in:
Robert Maynard 2020-06-08 14:36:15 +00:00 committed by Kitware Robot
commit aeb94c0dd8
6 changed files with 75 additions and 6 deletions

@ -48,15 +48,38 @@ public:
}
// let's execute with mapping fields.
mc.SetFieldsToPass("nodevar");
mc.SetFieldsToPass({ "nodevar", "cellvar" });
result = mc.Execute(dataSet);
{
const bool isMapped = result.HasField("nodevar");
VTKM_TEST_ASSERT(isMapped, "mapping should pass");
VTKM_TEST_ASSERT(result.GetNumberOfFields() == 2,
VTKM_TEST_ASSERT(result.GetNumberOfFields() == 3,
"Wrong number of fields in the output dataset");
//verify the cellvar result
vtkm::cont::ArrayHandle<vtkm::FloatDefault> cellFieldArrayOut;
result.GetField("cellvar").GetData().CopyTo(cellFieldArrayOut);
vtkm::cont::Algorithm::Sort(cellFieldArrayOut);
{
std::vector<vtkm::Id> correctcellIdStart = { 0, 1, 1, 2, 2, 3, 4, 4, 5, 5, 5, 6, 6, 6 };
std::vector<vtkm::Id> correctcellIdEnd = { 57, 57, 58, 58, 58, 59, 59,
60, 61, 61, 62, 62, 63 };
auto id_portal = cellFieldArrayOut.ReadPortal();
for (std::size_t i = 0; i < correctcellIdStart.size(); ++i)
{
VTKM_TEST_ASSERT(id_portal.Get(vtkm::Id(i)) == correctcellIdStart[i]);
}
vtkm::Id index = cellFieldArrayOut.GetNumberOfValues() - vtkm::Id(correctcellIdEnd.size());
for (std::size_t i = 0; i < correctcellIdEnd.size(); ++i, ++index)
{
VTKM_TEST_ASSERT(id_portal.Get(index) == correctcellIdEnd[i]);
}
}
vtkm::cont::CoordinateSystem coords = result.GetCoordinateSystem();
vtkm::cont::DynamicCellSet dcells = result.GetCellSet();
using CellSetType = vtkm::cont::CellSetSingleType<>;

@ -28,6 +28,20 @@ VTKM_EXEC inline vtkm::Id3 compute_incs3d(const vtkm::Id3& dims)
return vtkm::Id3{ 1, dims[0], (dims[0] * dims[1]) };
}
VTKM_EXEC inline constexpr vtkm::Id compute_cell_Id(SumXAxis,
vtkm::Id startingCellId,
vtkm::Id,
vtkm::Id i)
{
return startingCellId + i;
}
VTKM_EXEC inline constexpr vtkm::Id compute_cell_Id(SumYAxis,
vtkm::Id startingCellId,
vtkm::Id y_point_axis_inc,
vtkm::Id j)
{
return startingCellId + ((y_point_axis_inc - 1) * j);
}
VTKM_EXEC inline bool case_includes_axes(vtkm::UInt8 const* const edgeUses)
{

@ -114,6 +114,8 @@ struct ComputePass4X : public vtkm::worklet::WorkletVisitCellsWithPoints
const vtkm::Id3 pdims = this->PointDims;
const vtkm::Id3 increments = compute_incs3d(pdims);
const vtkm::Id startingCellId =
compute_start(AxisToSum{}, state.ijk, pdims - vtkm::Id3{ 1, 1, 1 });
vtkm::Id edgeIds[12];
auto edgeCase = getEdgeCase(edges, state.startPos, (state.axis_inc * state.left));
@ -127,7 +129,7 @@ struct ComputePass4X : public vtkm::worklet::WorkletVisitCellsWithPoints
if (numTris > 0)
{
//compute what the current cellId is
vtkm::Id cellId = compute_start(AxisToSum{}, ijk, pdims - vtkm::Id3{ 1, 1, 1 });
vtkm::Id cellId = compute_cell_Id(AxisToSum{}, startingCellId, state.axis_inc, i);
// Start by generating triangles for this case
generate_tris(cellId, edgeCase, numTris, edgeIds, cell_tri_offset, conn, inputCellIds);

@ -119,6 +119,8 @@ struct ComputePass4XWithNormals : public vtkm::worklet::WorkletVisitCellsWithPoi
const vtkm::Id3 pdims = this->PointDims;
const vtkm::Id3 increments = compute_incs3d(pdims);
const vtkm::Id startingCellId =
compute_start(AxisToSum{}, state.ijk, pdims - vtkm::Id3{ 1, 1, 1 });
vtkm::Id edgeIds[12];
auto edgeCase = getEdgeCase(edges, state.startPos, (state.axis_inc * state.left));
@ -132,7 +134,7 @@ struct ComputePass4XWithNormals : public vtkm::worklet::WorkletVisitCellsWithPoi
if (numTris > 0)
{
//compute what the current cellId is
vtkm::Id cellId = compute_start(AxisToSum{}, ijk, pdims - vtkm::Id3{ 1, 1, 1 });
vtkm::Id cellId = compute_cell_Id(AxisToSum{}, startingCellId, state.axis_inc, i);
// Start by generating triangles for this case
generate_tris(cellId, edgeCase, numTris, edgeIds, cell_tri_offset, conn, inputCellIds);

@ -109,6 +109,8 @@ struct ComputePass4Y : public vtkm::worklet::WorkletVisitCellsWithPoints
const vtkm::Id3 pdims = this->PointDims;
const vtkm::Id3 increments = compute_incs3d(pdims);
const vtkm::Id startingCellId =
compute_start(AxisToSum{}, state.ijk, pdims - vtkm::Id3{ 1, 1, 1 });
vtkm::Id edgeIds[12];
auto edgeCase = getEdgeCase(edges, state.startPos, (state.axis_inc * state.left));
@ -122,7 +124,7 @@ struct ComputePass4Y : public vtkm::worklet::WorkletVisitCellsWithPoints
if (numTris > 0)
{
//compute what the current cellId is
vtkm::Id cellId = compute_start(AxisToSum{}, ijk, pdims - vtkm::Id3{ 1, 1, 1 });
vtkm::Id cellId = compute_cell_Id(AxisToSum{}, startingCellId, state.axis_inc, i);
// Start by generating triangles for this case
generate_tris(cellId, edgeCase, numTris, edgeIds, cell_tri_offset, conn, inputCellIds);

@ -231,11 +231,37 @@ void TestContourUniformGrid()
std::cout << std::endl;
VTKM_TEST_ASSERT(result.GetNumberOfCells() == cellFieldArrayOut.GetNumberOfValues());
VTKM_TEST_ASSERT(result.GetNumberOfCells() == (160 * numContours));
VTKM_TEST_ASSERT(verticesArray.GetNumberOfValues() == (72 * numContours));
// The flying edge and marching cube algorithms differ in how the generate
// multi-contour results. Marching Cubes interlaces output from all contours
// together, while flying edges outputs all of contour 1 before any of contour 2.
//
// To make it possible to consistently compare the result we sort the cell-ids
//
vtkm::cont::Algorithm::Sort(cellFieldArrayOut);
{
std::vector<vtkm::Id> correctcellIdStart = { 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4,
4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6 };
std::vector<vtkm::Id> correctcellIdEnd = { 57, 57, 57, 57, 58, 58, 58, 58, 58, 58, 59, 59, 59,
59, 60, 60, 61, 61, 61, 61, 62, 62, 62, 62, 63, 63 };
auto id_portal = cellFieldArrayOut.ReadPortal();
for (std::size_t i = 0; i < correctcellIdStart.size(); ++i)
{
VTKM_TEST_ASSERT(id_portal.Get(vtkm::Id(i)) == correctcellIdStart[i]);
}
vtkm::Id index = cellFieldArrayOut.GetNumberOfValues() - vtkm::Id(correctcellIdEnd.size());
for (std::size_t i = 0; i < correctcellIdEnd.size(); ++i, ++index)
{
VTKM_TEST_ASSERT(id_portal.Get(index) == correctcellIdEnd[i]);
}
}
// Verify that multiple contours of the same iso value are identical
{
auto normal_portal = normalsArray.ReadPortal();