From 9fb58dcf1ec320b36ffa32239ef6e5d068d707cd Mon Sep 17 00:00:00 2001 From: Dave Pugmire Date: Wed, 30 Aug 2023 12:04:05 -0400 Subject: [PATCH] Optimize cellID bin check. --- vtkm/exec/CellLocatorUniformBins.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/vtkm/exec/CellLocatorUniformBins.h b/vtkm/exec/CellLocatorUniformBins.h index 223ae02ff..6f142c3f1 100644 --- a/vtkm/exec/CellLocatorUniformBins.h +++ b/vtkm/exec/CellLocatorUniformBins.h @@ -101,7 +101,8 @@ public: //See if it's in the last bin. if ((lastCell.BinIdx >= 0) && (lastCell.BinIdx < this->CellIds.GetNumberOfValues()) && - this->PointInBin(point, lastCell.BinIdx, cellId, pc) == vtkm::ErrorCode::Success) + this->PointInBin(point, lastCell.BinIdx, cellId, pc, lastCell.CellId) == + vtkm::ErrorCode::Success) { parametric = pc; lastCell.CellId = cellId; @@ -210,15 +211,16 @@ private: vtkm::ErrorCode PointInBin(const vtkm::Vec3f& point, const vtkm::Id& binIdx, vtkm::Id& cellId, - vtkm::Vec3f& parametric) const + vtkm::Vec3f& parametric, + const vtkm::Id& lastCellId = -1) const { auto binIds = this->CellIds.Get(binIdx); + vtkm::Vec3f pc; for (vtkm::IdComponent i = 0; i < binIds.GetNumberOfComponents(); i++) { vtkm::Id cid = binIds[i]; - vtkm::Vec3f pc; - if (this->PointInCell(point, cid, pc) == vtkm::ErrorCode::Success) + if (cid != lastCellId && this->PointInCell(point, cid, pc) == vtkm::ErrorCode::Success) { cellId = cid; parametric = pc;