Fix issue (findBinIdx won't fail if point outside dataset).
This commit is contained in:
parent
6996466752
commit
7fb1821b7c
@ -89,11 +89,17 @@ public:
|
|||||||
vtkm::Vec3f& parametric,
|
vtkm::Vec3f& parametric,
|
||||||
LastCell& lastCell) const
|
LastCell& lastCell) const
|
||||||
{
|
{
|
||||||
if (this->LastCellValid(lastCell))
|
|
||||||
{
|
|
||||||
//See if the point is still in the same bin.
|
|
||||||
vtkm::Id binIdx = this->FindBinIdx(point);
|
vtkm::Id binIdx = this->FindBinIdx(point);
|
||||||
if (binIdx == lastCell.BinIdx)
|
|
||||||
|
if (binIdx == -1)
|
||||||
|
{
|
||||||
|
lastCell.CellId = -1;
|
||||||
|
lastCell.BinIdx = -1;
|
||||||
|
cellId = -1;
|
||||||
|
return vtkm::ErrorCode::CellNotFound;
|
||||||
|
}
|
||||||
|
//See if the point is still in the same bin.
|
||||||
|
else if (binIdx == lastCell.BinIdx && this->LastCellValid(lastCell))
|
||||||
{
|
{
|
||||||
vtkm::Vec3f pc;
|
vtkm::Vec3f pc;
|
||||||
//Check the last cell first.
|
//Check the last cell first.
|
||||||
@ -110,10 +116,10 @@ public:
|
|||||||
return vtkm::ErrorCode::Success;
|
return vtkm::ErrorCode::Success;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//LastCell not initialized, or not in the same bin: do a full test.
|
//LastCell not initialized, or not in the same bin: do a full test.
|
||||||
return this->FindCellImpl(point, cellId, parametric, lastCell);
|
//Since already computed the binIdx, re-use it.
|
||||||
|
return this->FindCellImpl(point, cellId, parametric, lastCell, binIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_DEPRECATED(1.6, "Locators are no longer pointers. Use . operator.")
|
VTKM_DEPRECATED(1.6, "Locators are no longer pointers. Use . operator.")
|
||||||
@ -124,6 +130,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
VTKM_EXEC vtkm::Id FindBinIdx(const vtkm::Vec3f& point) const
|
VTKM_EXEC vtkm::Id FindBinIdx(const vtkm::Vec3f& point) const
|
||||||
{
|
{
|
||||||
|
if (!this->IsInside(point))
|
||||||
|
return -1;
|
||||||
|
|
||||||
vtkm::Vec3f temp;
|
vtkm::Vec3f temp;
|
||||||
temp = point - this->Origin;
|
temp = point - this->Origin;
|
||||||
temp = temp * this->InvSpacing;
|
temp = temp * this->InvSpacing;
|
||||||
@ -159,20 +168,27 @@ private:
|
|||||||
vtkm::ErrorCode FindCellImpl(const vtkm::Vec3f& point,
|
vtkm::ErrorCode FindCellImpl(const vtkm::Vec3f& point,
|
||||||
vtkm::Id& cellId,
|
vtkm::Id& cellId,
|
||||||
vtkm::Vec3f& parametric,
|
vtkm::Vec3f& parametric,
|
||||||
LastCell& lastCell) const
|
LastCell& lastCell,
|
||||||
|
vtkm::Id ptBinIdx = -1) const
|
||||||
{
|
{
|
||||||
lastCell.CellId = -1;
|
lastCell.CellId = -1;
|
||||||
lastCell.BinIdx = -1;
|
lastCell.BinIdx = -1;
|
||||||
|
|
||||||
if (!this->IsInside(point))
|
//if ptBinIdx is set, use it. Otherwise, compute the bin idx.
|
||||||
|
vtkm::Id binIdx = -1;
|
||||||
|
if (ptBinIdx == -1)
|
||||||
|
binIdx = this->FindBinIdx(point);
|
||||||
|
else
|
||||||
|
binIdx = ptBinIdx;
|
||||||
|
|
||||||
|
//point not in a bin. return not found.
|
||||||
|
if (binIdx == -1)
|
||||||
{
|
{
|
||||||
cellId = -1;
|
cellId = -1;
|
||||||
return vtkm::ErrorCode::CellNotFound;
|
return vtkm::ErrorCode::CellNotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Find the bin containing the point.
|
//search cells in the bin.
|
||||||
vtkm::Id binIdx = this->FindBinIdx(point);
|
|
||||||
|
|
||||||
vtkm::Vec3f pc;
|
vtkm::Vec3f pc;
|
||||||
if (this->PointInBin(point, binIdx, cellId, pc))
|
if (this->PointInBin(point, binIdx, cellId, pc))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user