From 4f19ac6082219a91832b0cee6274ff3c99d0e8de Mon Sep 17 00:00:00 2001 From: Kenneth Moreland Date: Wed, 30 Aug 2023 09:25:55 -0500 Subject: [PATCH] Fix interpolation of cell fields with flying edges The flying edges algorithm (used when contouring uniform structured cell sets) was not interpolating cell fields correctly. There was an indexing issue where a shortcut in the stepping was not incrementing the cell index. --- docs/changelog/flying-edges-cell-fields.md | 5 +++++ .../worklet/contour/FlyingEdgesPass4Common.h | 13 +++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 docs/changelog/flying-edges-cell-fields.md diff --git a/docs/changelog/flying-edges-cell-fields.md b/docs/changelog/flying-edges-cell-fields.md new file mode 100644 index 000000000..f3175c81a --- /dev/null +++ b/docs/changelog/flying-edges-cell-fields.md @@ -0,0 +1,5 @@ +# Fix interpolation of cell fields with flying edges + +The flying edges algorithm (used when contouring uniform structured cell +sets) was not interpolating cell fields correctly. There was an indexing +issue where a shortcut in the stepping was not incrementing the cell index. diff --git a/vtkm/filter/contour/worklet/contour/FlyingEdgesPass4Common.h b/vtkm/filter/contour/worklet/contour/FlyingEdgesPass4Common.h index 059eb63d0..96aaf95ac 100644 --- a/vtkm/filter/contour/worklet/contour/FlyingEdgesPass4Common.h +++ b/vtkm/filter/contour/worklet/contour/FlyingEdgesPass4Common.h @@ -28,15 +28,19 @@ 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 increment_cellId(SumXAxis, vtkm::Id cellId, vtkm::Id) +VTKM_EXEC inline constexpr vtkm::Id increment_cellId(SumXAxis, + vtkm::Id cellId, + vtkm::Id, + vtkm::Id numToIncrement = 1) { - return cellId + 1; + return cellId + numToIncrement; } VTKM_EXEC inline constexpr vtkm::Id increment_cellId(SumYAxis, vtkm::Id cellId, - vtkm::Id y_point_axis_inc) + vtkm::Id y_point_axis_inc, + vtkm::Id numToIncrement = 1) { - return cellId + (y_point_axis_inc - 1); + return cellId + ((y_point_axis_inc - 1) * numToIncrement); } VTKM_EXEC inline bool case_includes_axes(vtkm::UInt8 const* const edgeUses) @@ -159,6 +163,7 @@ struct Pass4TrimState cellId = compute_start(AxisToSum{}, ijk, pdims - vtkm::Id3{ 1, 1, 1 }); //update our ijk + cellId = increment_cellId(AxisToSum{}, cellId, axis_inc, left - ijk[AxisToSum::xindex]); ijk[AxisToSum::xindex] = left; boundaryStatus[0] = FlyingEdges3D::Interior;