Merge topic 'union-empty-ranges'

e7e39e9e Fix including empty range

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Matt Larsen <mlarsen@cs.uoregon.edu>
Merge-request: !1086
This commit is contained in:
Kenneth Moreland 2018-02-20 17:27:19 +00:00 committed by Kitware Robot
commit 7a8e469d23
3 changed files with 18 additions and 2 deletions

@ -144,8 +144,11 @@ struct Range
VTKM_EXEC_CONT
void Include(const vtkm::Range& range)
{
this->Include(range.Min);
this->Include(range.Max);
if (range.IsNonEmpty())
{
this->Include(range.Min);
this->Include(range.Max);
}
}
/// \b Return the union of this and another range.

@ -33,6 +33,13 @@ void TestBounds()
vtkm::Bounds emptyBounds;
VTKM_TEST_ASSERT(!emptyBounds.IsNonEmpty(), "Non empty bounds not empty.");
vtkm::Bounds emptyBounds2;
VTKM_TEST_ASSERT(!emptyBounds2.IsNonEmpty(), "2nd empty bounds not empty.");
VTKM_TEST_ASSERT(!emptyBounds.Union(emptyBounds2).IsNonEmpty(),
"Union of empty bounds not empty.");
emptyBounds2.Include(emptyBounds);
VTKM_TEST_ASSERT(!emptyBounds2.IsNonEmpty(), "Include empty in empty is not empty.");
std::cout << "Single value bounds." << std::endl;
vtkm::Bounds singleValueBounds(1.0, 1.0, 2.0, 2.0, 3.0, 3.0);
VTKM_TEST_ASSERT(singleValueBounds.IsNonEmpty(), "Empty?");

@ -32,6 +32,12 @@ void TestRange()
VTKM_TEST_ASSERT(!emptyRange.IsNonEmpty(), "Non empty range not empty.");
VTKM_TEST_ASSERT(test_equal(emptyRange.Length(), 0.0), "Bad length.");
vtkm::Range emptyRange2;
VTKM_TEST_ASSERT(!emptyRange2.IsNonEmpty(), "2nd empty range not empty.");
VTKM_TEST_ASSERT(!emptyRange.Union(emptyRange2).IsNonEmpty(), "Union of empty ranges not empty.");
emptyRange2.Include(emptyRange);
VTKM_TEST_ASSERT(!emptyRange2.IsNonEmpty(), "Include empty in empty is not empty.");
std::cout << "Single value range." << std::endl;
vtkm::Range singleValueRange(5.0, 5.0);
VTKM_TEST_ASSERT(singleValueRange.IsNonEmpty(), "Empty?");