diff --git a/test/test_shadwovolume_cache.cc b/test/test_shadowvolume.cc similarity index 58% rename from test/test_shadwovolume_cache.cc rename to test/test_shadowvolume.cc index 99277c29486df5b124b580e2e5830847b8e32ba6..5e4135bf98955564956b83775191192cd9b56701 100644 --- a/test/test_shadwovolume_cache.cc +++ b/test/test_shadowvolume.cc @@ -1,3 +1,4 @@ +#define EXPOSE_TREACHEROUS #include "newimage/newimageall.h" #include "utils/threading.h" #include <stdlib.h> @@ -132,3 +133,56 @@ BOOST_FIXTURE_TEST_CASE(test_splinterp, F) testvol[t].interpolate(5, 5, 5)); } } + +// test that changes to interp/extrap settings on a +// 4D volume are propagated to its ShadowVolume instances +BOOST_FIXTURE_TEST_CASE(test_interp_settings_delegated, F) +{ + testvol.setinterpolationmethod(nearestneighbour); + testvol.setextrapolationmethod(mirror); + testvol.setpadvalue(12345); + testvol.setsplineorder(5); + testvol.setextrapolationvalidity(false, true, false); + for (int i = 0; i < tsz; i++) { + BOOST_CHECK(testvol[i].getinterpolationmethod() == nearestneighbour); + BOOST_CHECK(testvol[i].getextrapolationmethod() == mirror); + BOOST_CHECK(testvol[i].getpadvalue() == 12345); + BOOST_CHECK(testvol[i].getsplineorder() == 5); + std::vector<bool> expvalidity = {false, true, false}; + BOOST_CHECK(testvol[i].getextrapolationvalidity() == expvalidity); + } + + testvol.setinterpolationmethod(sinc); + testvol.setextrapolationmethod(periodic); + testvol.setpadvalue(54321); + testvol.setsplineorder(2); + testvol.setextrapolationvalidity(true, false, true); + for (int i = 0; i < tsz; i++) { + BOOST_CHECK(testvol[i].getinterpolationmethod() == sinc); + BOOST_CHECK(testvol[i].getextrapolationmethod() == periodic); + BOOST_CHECK(testvol[i].getpadvalue() == 54321); + BOOST_CHECK(testvol[i].getsplineorder() == 2); + std::vector<bool> expvalidity = {true, false, true}; + BOOST_CHECK(testvol[i].getextrapolationvalidity() == expvalidity); + } + + // Force the ShadowVolume cache to be cleared + testvol.setinterpolationmethod(spline); + testvol.invalidateSplines(); + + // make sure settings still the same + for (int i = 0; i < tsz; i++) { + BOOST_CHECK(testvol[i].getinterpolationmethod() == spline); + BOOST_CHECK(testvol[i].getextrapolationmethod() == periodic); + BOOST_CHECK(testvol[i].getpadvalue() == 54321); + BOOST_CHECK(testvol[i].getsplineorder() == 2); + std::vector<bool> expvalidity = {true, false, true}; + BOOST_CHECK(testvol[i].getextrapolationvalidity() == expvalidity); + } + + // Attempting to change settings + // on a SV should error + BOOST_CHECK_THROW( + testvol[0].setinterpolationmethod(trilinear), + NEWMAT::Exception); +}