From bda2d3d8e14541714295eb1c57633328ba562f8e Mon Sep 17 00:00:00 2001 From: Sujin Philip Date: Mon, 4 Sep 2023 10:51:47 -0400 Subject: [PATCH] Clip: remap centroid interpolation points to used-only point Previously, Clip was updated to remove unused points from the input. This requires a re-mapping of point ids after compaction. This re-mapping was missed for the points used for interpolation of centorid points. --- vtkm/filter/contour/worklet/Clip.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/vtkm/filter/contour/worklet/Clip.h b/vtkm/filter/contour/worklet/Clip.h index 19ffcfc80..ce630a88b 100644 --- a/vtkm/filter/contour/worklet/Clip.h +++ b/vtkm/filter/contour/worklet/Clip.h @@ -684,6 +684,31 @@ public: pointsOnlyConnectivity); pointsOnlyConnectivityIndices.ReleaseResources(); + + // We want to find the entries in `InCellInterpolationInfo` that point to exisiting points. + // `cellPointEdgeReverseConnectivity` map to entries that point to edges. + vtkm::cont::ArrayHandle stencil; + stencil.AllocateAndFill(this->InCellInterpolationInfo.GetNumberOfValues(), 1); + auto edgeOnlyStencilEntries = + vtkm::cont::make_ArrayHandlePermutation(cellPointEdgeReverseConnectivity, stencil); + vtkm::cont::Algorithm::Fill(edgeOnlyStencilEntries, vtkm::UInt8{}); + vtkm::cont::ArrayHandle idxsToPoints; + vtkm::cont::Algorithm::CopyIf( + vtkm::cont::ArrayHandleIndex(this->InCellInterpolationInfo.GetNumberOfValues()), + stencil, + idxsToPoints); + stencil.ReleaseResources(); + + // Remap the point indices in `InCellInterpolationInfo`, to the used-only point indices + // computed above. + // This only works if the points needed for interpolating centroids are included in the + // `connectivity` array. This has been verified to be true for all cases in the clip tables. + auto inCellInterpolationInfoPointsOnly = + vtkm::cont::make_ArrayHandlePermutation(idxsToPoints, this->InCellInterpolationInfo); + invoke(vtkm::worklet::RemoveUnusedPoints::TransformPointIndices{}, + inCellInterpolationInfoPointsOnly, + pointMapInputToOutput, + inCellInterpolationInfoPointsOnly); } // Get unique EdgeInterpolation : unique edge points. @@ -701,6 +726,9 @@ public: EdgeInterpolation::LessThanOp()); edgeInterpolation.ReleaseResources(); + // This only works if the edges in `cellPointEdgeInterpolation` also exist in + // `EdgePointsInterpolation`. This has been verified to be true for all cases in the clip + // tables. vtkm::cont::ArrayHandle cellInterpolationIndexToUnique; vtkm::cont::Algorithm::LowerBounds(this->EdgePointsInterpolation, cellPointEdgeInterpolation,