mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-10-08 03:18:58 +00:00
Do not assume that LastCell initializes to -1
If an `ArrayHandle` of `LastCell`s is created, then the contents will be garbage. Just check to make sure that it is valid.
This commit is contained in:
parent
5d78780f6e
commit
bbdfd3d52b
@ -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.
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user