diff --git a/vtkm/exec/CellLocatorBoundingIntervalHierarchy.h b/vtkm/exec/CellLocatorBoundingIntervalHierarchy.h index c314f18d8..620c7754d 100644 --- a/vtkm/exec/CellLocatorBoundingIntervalHierarchy.h +++ b/vtkm/exec/CellLocatorBoundingIntervalHierarchy.h @@ -107,7 +107,7 @@ public: cellId = -1; //Check the last cell. - if (lastCell.CellId != -1) + if ((lastCell.CellId >= 0) && (lastCell.CellId < this->CellSet.GetNumberOfElements())) { if (this->PointInCell(point, lastCell.CellId, parametric) == vtkm::ErrorCode::Success) { @@ -117,7 +117,7 @@ public: } //Check the last leaf node. - if (lastCell.NodeIdx != -1) + if ((lastCell.NodeIdx >= 0) && (lastCell.NodeIdx < this->Nodes.GetNumberOfValues())) { const auto& node = this->Nodes.Get(lastCell.NodeIdx); VTKM_ASSERT(node.ChildIndex < 0); //should be a leaf node. diff --git a/vtkm/exec/CellLocatorTwoLevel.h b/vtkm/exec/CellLocatorTwoLevel.h index cafafaaba..d432c98f7 100644 --- a/vtkm/exec/CellLocatorTwoLevel.h +++ b/vtkm/exec/CellLocatorTwoLevel.h @@ -174,7 +174,7 @@ public: { vtkm::Vec3f pc; //See if point is inside the last cell. - if (lastCell.CellId != -1 && + if ((lastCell.CellId >= 0) && (lastCell.CellId < this->CellSet.GetNumberOfElements()) && this->PointInCell(point, lastCell.CellId, pc) == vtkm::ErrorCode::Success) { parametric = pc; @@ -183,7 +183,7 @@ public: } //See if it's in the last leaf. - if (lastCell.LeafIdx != -1 && + if ((lastCell.LeafIdx >= 0) && (lastCell.LeafIdx < this->CellCount.GetNumberOfValues()) && this->PointInLeaf(point, lastCell.LeafIdx, cellId, pc) == vtkm::ErrorCode::Success) { parametric = pc;