Add test for PerlinNoise source

This commit is contained in:
Kenneth Moreland 2021-12-14 14:09:09 -07:00
parent de14629c1f
commit c92f9cf15e
6 changed files with 78 additions and 4 deletions

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:23325fa15322c944b3ffae737accc32cc9b44288fd156870974c8eb47f0a09c3
size 44080

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:80e7e0264064b2ea3f64353db07f6b39177d837110989558395f52c2c12747f2
size 40865

@ -39,7 +39,7 @@ vtkm_library(
DEVICE_SOURCES ${library_sources}
HEADERS ${headers}
)
target_link_libraries(vtkm_rendering_testing PUBLIC vtkm_cont_testing)
target_link_libraries(vtkm_rendering_testing PRIVATE vtkm_io vtkm_rendering)
target_link_libraries(vtkm_rendering_testing PUBLIC vtkm_cont_testing vtkm_rendering)
target_link_libraries(vtkm_rendering_testing PRIVATE vtkm_io)
vtkm_unit_tests(SOURCES ${unit_tests} ALL_BACKENDS LIBRARIES vtkm_rendering vtkm_rendering_testing)

@ -155,7 +155,7 @@ private:
{
std::mt19937_64 rng;
rng.seed(this->Seed);
std::uniform_int_distribution<vtkm::Id> distribution(0, this->TableSize - 1);
std::uniform_int_distribution<vtkm::IdComponent> distribution(0, this->TableSize - 1);
vtkm::cont::ArrayHandle<vtkm::Id> perms;
perms.Allocate(this->TableSize);

@ -14,7 +14,25 @@ set(unit_tests
UnitTestWaveletSource.cxx
)
set(libraries
vtkm_source
)
if (VTKm_ENABLE_RENDERING)
list(APPEND libraries vtkm_rendering_testing)
list(APPEND unit_tests
RenderTestPerlinNoise.cxx
)
# Currently to use the rendering in VTK-m, you have to compile with a device compiler.
# We hope to change that in the near future, but until then we need to add the
# `ALL_BACKENDS` flag to `vtkm_unit_tests` to compile with the device compiler. Here
# is a hack to add it.
list(APPEND unit_tests ALL_BACKENDS)
endif()
vtkm_unit_tests(
SOURCES ${unit_tests}
LIBRARIES vtkm_source
LIBRARIES ${libraries}
)

@ -0,0 +1,50 @@
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/source/PerlinNoise.h>
#include <vtkm/filter/Contour.h>
#include <vtkm/rendering/CanvasRayTracer.h>
#include <vtkm/rendering/MapperRayTracer.h>
#include <vtkm/rendering/View3D.h>
#include <vtkm/rendering/testing/RenderTest.h>
#include <vtkm/rendering/testing/Testing.h>
namespace
{
void TestPerlinNoise()
{
vtkm::source::PerlinNoise noiseSource(vtkm::Id3(16), 77698);
vtkm::cont::DataSet noise = noiseSource.Execute();
noise.PrintSummary(std::cout);
vtkm::filter::Contour contourFilter;
contourFilter.SetIsoValues({ 0.3, 0.4, 0.5, 0.6, 0.7 });
contourFilter.SetActiveField("perlinnoise");
vtkm::cont::DataSet contours = contourFilter.Execute(noise);
// CUDA seems to make the contour slightly different, so relax comparison options.
vtkm::rendering::testing::RenderTestOptions options;
options.AllowedPixelErrorRatio = 0.01f;
options.Threshold = 0.1f;
vtkm::rendering::testing::RenderTest(contours, "perlinnoise", "source/perlin-noise.png", options);
}
} // anonymous namespace
int RenderTestPerlinNoise(int argc, char* argv[])
{
return vtkm::cont::testing::Testing::Run(TestPerlinNoise, argc, argv);
}