Skip to content
Snippets Groups Projects
Commit c1a790db authored by Kenneth Moreland's avatar Kenneth Moreland
Browse files

Fix BIH split calculations for empty regions

When computing the cost for splitting, if a regions was empty you would
get a floating point error when multiplying the (invalid) region bound
(inf or -inf) with the number of points (0). It would then check for NaN
costs and reset that. This worked but caused a floating point exception,
which is problematic for some users.

Instead, check for empty regions before computing the cost and reset the
cost that way.
parent 9ce97352
Branches
Tags
2 merge requests!2615Draft: DONTMERGE ME: TEST FOR 1.7.0-rc1 is our 9th official release of VTK-m.,!2527Turn on floating point exception trapping for GCC in tests
......@@ -221,9 +221,12 @@ public:
split.NumRightPoints = pointsToRight;
split.LMax = static_cast<vtkm::FloatDefault>(lMaxRanges.Max);
split.RMin = static_cast<vtkm::FloatDefault>(rMinRanges.Min);
split.Cost = vtkm::Abs(split.LMax * static_cast<vtkm::FloatDefault>(pointsToLeft) -
split.RMin * static_cast<vtkm::FloatDefault>(pointsToRight));
if (vtkm::IsNan(split.Cost))
if (lMaxRanges.IsNonEmpty() && rMinRanges.IsNonEmpty())
{
split.Cost = vtkm::Abs(split.LMax * static_cast<vtkm::FloatDefault>(pointsToLeft) -
split.RMin * static_cast<vtkm::FloatDefault>(pointsToRight));
}
else
{
split.Cost = vtkm::Infinity<vtkm::FloatDefault>();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment