mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-10-05 01:49:02 +00:00
Implement additional wireframer rendering regression tests
This commit is contained in:
parent
8875645da1
commit
d254531657
3
data/baseline/rendering/wireframer/wf_expl3D.png
Normal file
3
data/baseline/rendering/wireframer/wf_expl3D.png
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1292bc18adcf13474e946f9c0ceb42ff50c96448875706a6178b992f8b7d142f
|
||||
size 15803
|
3
data/baseline/rendering/wireframer/wf_lines1D.png
Normal file
3
data/baseline/rendering/wireframer/wf_lines1D.png
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:d92ef6c38069b17cf8451183e65d94efae63061034561e2341816183972f9cc9
|
||||
size 19399
|
3
data/baseline/rendering/wireframer/wf_lines2D.png
Normal file
3
data/baseline/rendering/wireframer/wf_lines2D.png
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:641b0b9262ba61e633da957547e062c51e1d6d34183144d5d6f4e000c160b679
|
||||
size 6339
|
3
data/baseline/rendering/wireframer/wf_linesLogY1D.png
Normal file
3
data/baseline/rendering/wireframer/wf_linesLogY1D.png
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:c50e282a46344bbfe99b95fa0ca07ea635d644af270a26b456ee9257cc6498a0
|
||||
size 14055
|
3
data/baseline/rendering/wireframer/wf_rect3D.png
Normal file
3
data/baseline/rendering/wireframer/wf_rect3D.png
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:32707fba1446b67c443dd9cfa7a2e96e8135040856194e3231849ecf1869deeb
|
||||
size 17005
|
3
data/baseline/rendering/wireframer/wf_reg3D.png
Normal file
3
data/baseline/rendering/wireframer/wf_reg3D.png
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a1ec3267e92303f5988de714017574fde1e7b4d4e1c1d60caa6fe18ac26468f1
|
||||
size 17151
|
3
data/baseline/rendering/wireframer/wf_uniform3D.png
Normal file
3
data/baseline/rendering/wireframer/wf_uniform3D.png
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:814e5d4df064deceb334cb9e3d9de707cb052ebf2fea7fd8e3dd3229cdc245e9
|
||||
size 48370
|
@ -50,13 +50,8 @@ void TestContourFilterWedge()
|
||||
|
||||
result.PrintSummary(std::cout);
|
||||
|
||||
C canvas(512, 512);
|
||||
M mapper;
|
||||
vtkm::rendering::Scene scene;
|
||||
auto view = vtkm::rendering::testing::GetViewPtr<M, C, V3>(
|
||||
result, "gyroid", canvas, mapper, scene, colorTable, static_cast<vtkm::FloatDefault>(0.08));
|
||||
|
||||
VTKM_TEST_ASSERT(test_equal_images(view, "contour-wedge.png"));
|
||||
vtkm::rendering::testing::RenderAndRegressionTest<M, C, V3>(
|
||||
result, "gyroid", colorTable, "contour-wedge.png", static_cast<vtkm::FloatDefault>(0.08));
|
||||
}
|
||||
|
||||
void TestContourFilterUniform()
|
||||
@ -84,14 +79,9 @@ void TestContourFilterUniform()
|
||||
|
||||
result.PrintSummary(std::cout);
|
||||
|
||||
C canvas(512, 512);
|
||||
M mapper;
|
||||
vtkm::rendering::Scene scene;
|
||||
auto view = vtkm::rendering::testing::GetViewPtr<M, C, V3>(
|
||||
result, "pointvar", canvas, mapper, scene, colorTable);
|
||||
|
||||
//Y axis Flying Edge algorithm has subtle differences at a couple of boundaries
|
||||
VTKM_TEST_ASSERT(test_equal_images(view, "contour-uniform.png"));
|
||||
vtkm::rendering::testing::RenderAndRegressionTest<M, C, V3>(
|
||||
result, "pointvar", colorTable, "contour-uniform.png");
|
||||
}
|
||||
|
||||
void TestContourFilterTangle()
|
||||
@ -117,14 +107,9 @@ void TestContourFilterTangle()
|
||||
|
||||
result.PrintSummary(std::cout);
|
||||
|
||||
C canvas(512, 512);
|
||||
M mapper;
|
||||
vtkm::rendering::Scene scene;
|
||||
auto view = vtkm::rendering::testing::GetViewPtr<M, C, V3>(
|
||||
result, "nodevar", canvas, mapper, scene, colorTable);
|
||||
|
||||
//Y axis Flying Edge algorithm has subtle differences at a couple of boundaries
|
||||
VTKM_TEST_ASSERT(test_equal_images(view, "contour-tangle.png"));
|
||||
vtkm::rendering::testing::RenderAndRegressionTest<M, C, V3>(
|
||||
result, "nodevar", colorTable, "contour-tangle.png");
|
||||
}
|
||||
|
||||
void TestContourFilter()
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <vtkm/rendering/View1D.h>
|
||||
#include <vtkm/rendering/View2D.h>
|
||||
#include <vtkm/rendering/View3D.h>
|
||||
#include <vtkm/rendering/testing/Testing.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
@ -87,6 +88,11 @@ void Render(ViewType& view, const std::string& outputFile)
|
||||
view.SaveAs(outputFile);
|
||||
}
|
||||
|
||||
// Different methods in which to create a View when provided with different
|
||||
// field names, colors, and other utilities for testing 1D, 2D, and 3D views
|
||||
|
||||
// Testing Methods for working with what are normally 3D datasets
|
||||
// --------------------------------------------------------------
|
||||
template <typename MapperType, typename CanvasType, typename ViewType>
|
||||
std::shared_ptr<ViewType> GetViewPtr(const vtkm::cont::DataSet& ds,
|
||||
const std::string& fieldNm,
|
||||
@ -117,44 +123,66 @@ template <typename MapperType, typename CanvasType, typename ViewType>
|
||||
void Render(const vtkm::cont::DataSet& ds,
|
||||
const std::string& fieldNm,
|
||||
const vtkm::cont::ColorTable& colorTable,
|
||||
const std::string& outputFile)
|
||||
const std::string& outputFile,
|
||||
const vtkm::Float64& dataViewPadding = 0)
|
||||
{
|
||||
MapperType mapper;
|
||||
CanvasType canvas(512, 512);
|
||||
vtkm::rendering::Scene scene;
|
||||
|
||||
auto view =
|
||||
GetViewPtr<MapperType, CanvasType, ViewType>(ds, fieldNm, canvas, mapper, scene, colorTable);
|
||||
Render<MapperType, CanvasType, ViewType>(*view.get(), outputFile);
|
||||
auto view = GetViewPtr<MapperType, CanvasType, ViewType>(
|
||||
ds, fieldNm, canvas, mapper, scene, colorTable, dataViewPadding);
|
||||
Render<MapperType, CanvasType, ViewType>(*view, outputFile);
|
||||
}
|
||||
|
||||
// A render test that allows for testing different mapper params
|
||||
template <typename MapperType, typename CanvasType, typename ViewType>
|
||||
void Render(MapperType& mapper,
|
||||
const vtkm::cont::DataSet& ds,
|
||||
const std::string& fieldNm,
|
||||
const vtkm::cont::ColorTable& colorTable,
|
||||
const std::string& outputFile,
|
||||
const vtkm::Float64& dataViewPadding = 0)
|
||||
void RenderAndRegressionTest(const vtkm::cont::DataSet& ds,
|
||||
const std::string& fieldNm,
|
||||
const vtkm::cont::ColorTable& colorTable,
|
||||
const std::string& outputFile,
|
||||
const vtkm::Float64& dataViewPadding = 0)
|
||||
{
|
||||
MapperType mapper;
|
||||
CanvasType canvas(512, 512);
|
||||
vtkm::rendering::Scene scene;
|
||||
|
||||
scene.AddActor(vtkm::rendering::Actor(
|
||||
ds.GetCellSet(), ds.GetCoordinateSystem(), ds.GetField(fieldNm), colorTable));
|
||||
auto view = GetViewPtr<MapperType, CanvasType, ViewType>(
|
||||
ds, fieldNm, canvas, mapper, scene, colorTable, dataViewPadding);
|
||||
VTKM_TEST_ASSERT(test_equal_images(view, outputFile));
|
||||
}
|
||||
// --------------------------------------------------------------
|
||||
|
||||
// Testing Methods for working with what are normally 2D datasets
|
||||
// --------------------------------------------------------------
|
||||
template <typename MapperType, typename CanvasType, typename ViewType>
|
||||
std::shared_ptr<ViewType> GetViewPtr(const vtkm::cont::DataSet& ds,
|
||||
const std::vector<std::string>& fields,
|
||||
const std::vector<vtkm::rendering::Color>& colors,
|
||||
const CanvasType& canvas,
|
||||
const MapperType& mapper,
|
||||
vtkm::rendering::Scene& scene,
|
||||
const vtkm::Float64& dataViewPadding = 0)
|
||||
{
|
||||
size_t numFields = fields.size();
|
||||
for (size_t i = 0; i < numFields; ++i)
|
||||
{
|
||||
scene.AddActor(vtkm::rendering::Actor(
|
||||
ds.GetCellSet(), ds.GetCoordinateSystem(), ds.GetField(fields[i]), colors[i]));
|
||||
}
|
||||
vtkm::rendering::Camera camera;
|
||||
SetCamera<ViewType>(
|
||||
camera, ds.GetCoordinateSystem().GetBounds(), ds.GetField(fieldNm), dataViewPadding);
|
||||
camera, ds.GetCoordinateSystem().GetBounds(), ds.GetField(fields[0]), dataViewPadding);
|
||||
|
||||
vtkm::rendering::Color background(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
vtkm::rendering::Color foreground(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
ViewType view(scene, mapper, canvas, camera, background, foreground);
|
||||
auto view = std::make_shared<ViewType>(scene, mapper, canvas, camera, background, foreground);
|
||||
|
||||
// Print the title
|
||||
std::unique_ptr<vtkm::rendering::TextAnnotationScreen> titleAnnotation(
|
||||
new vtkm::rendering::TextAnnotationScreen(
|
||||
"Test Plot", vtkm::rendering::Color(1, 1, 1, 1), .075f, vtkm::Vec2f_32(-.11f, .92f), 0.f));
|
||||
view.AddAnnotation(std::move(titleAnnotation));
|
||||
Render<MapperType, CanvasType, ViewType>(view, outputFile);
|
||||
view->AddAnnotation(std::move(titleAnnotation));
|
||||
return view;
|
||||
}
|
||||
|
||||
template <typename MapperType, typename CanvasType, typename ViewType>
|
||||
@ -169,26 +197,59 @@ void Render(const vtkm::cont::DataSet& ds,
|
||||
canvas.SetBackgroundColor(vtkm::rendering::Color::white);
|
||||
vtkm::rendering::Scene scene;
|
||||
|
||||
size_t numFields = fields.size();
|
||||
for (size_t i = 0; i < numFields; ++i)
|
||||
{
|
||||
scene.AddActor(vtkm::rendering::Actor(
|
||||
ds.GetCellSet(), ds.GetCoordinateSystem(), ds.GetField(fields[i]), colors[i]));
|
||||
}
|
||||
auto view = GetViewPtr<MapperType, CanvasType, ViewType>(
|
||||
ds, fields, colors, canvas, mapper, scene, dataViewPadding);
|
||||
Render<MapperType, CanvasType, ViewType>(*view, outputFile);
|
||||
}
|
||||
|
||||
template <typename MapperType, typename CanvasType, typename ViewType>
|
||||
void RenderAndRegressionTest(const vtkm::cont::DataSet& ds,
|
||||
const std::vector<std::string>& fields,
|
||||
const std::vector<vtkm::rendering::Color>& colors,
|
||||
const std::string& outputFile,
|
||||
const vtkm::Float64& dataViewPadding = 0)
|
||||
{
|
||||
MapperType mapper;
|
||||
CanvasType canvas(512, 512);
|
||||
canvas.SetBackgroundColor(vtkm::rendering::Color::white);
|
||||
vtkm::rendering::Scene scene;
|
||||
|
||||
auto view = GetViewPtr<MapperType, CanvasType, ViewType>(
|
||||
ds, fields, colors, canvas, mapper, scene, dataViewPadding);
|
||||
VTKM_TEST_ASSERT(test_equal_images(view, outputFile));
|
||||
}
|
||||
// --------------------------------------------------------------
|
||||
|
||||
// Testing Methods for working with what are normally 1D datasets
|
||||
// --------------------------------------------------------------
|
||||
template <typename MapperType, typename CanvasType, typename ViewType>
|
||||
std::shared_ptr<ViewType> GetViewPtr(const vtkm::cont::DataSet& ds,
|
||||
const std::string& fieldNm,
|
||||
const CanvasType& canvas,
|
||||
const MapperType& mapper,
|
||||
vtkm::rendering::Scene& scene,
|
||||
const vtkm::rendering::Color& color,
|
||||
const bool logY = false,
|
||||
const vtkm::Float64& dataViewPadding = 0)
|
||||
{
|
||||
//DRP Actor? no field? no colortable (or a constant colortable) ??
|
||||
scene.AddActor(
|
||||
vtkm::rendering::Actor(ds.GetCellSet(), ds.GetCoordinateSystem(), ds.GetField(fieldNm), color));
|
||||
vtkm::rendering::Camera camera;
|
||||
SetCamera<ViewType>(
|
||||
camera, ds.GetCoordinateSystem().GetBounds(), ds.GetField(fields[0]), dataViewPadding);
|
||||
camera, ds.GetCoordinateSystem().GetBounds(), ds.GetField(fieldNm), dataViewPadding);
|
||||
|
||||
vtkm::rendering::Color background(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
vtkm::rendering::Color foreground(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
ViewType view(scene, mapper, canvas, camera, background, foreground);
|
||||
auto view = std::make_shared<ViewType>(scene, mapper, canvas, camera, background, foreground);
|
||||
|
||||
// Print the title
|
||||
std::unique_ptr<vtkm::rendering::TextAnnotationScreen> titleAnnotation(
|
||||
new vtkm::rendering::TextAnnotationScreen(
|
||||
"Test Plot", vtkm::rendering::Color(1, 1, 1, 1), .075f, vtkm::Vec2f_32(-.11f, .92f), 0.f));
|
||||
view.AddAnnotation(std::move(titleAnnotation));
|
||||
Render<MapperType, CanvasType, ViewType>(view, outputFile);
|
||||
"1D Test Plot", foreground, .1f, vtkm::Vec2f_32(-.27f, .87f), 0.f));
|
||||
view->AddAnnotation(std::move(titleAnnotation));
|
||||
view->SetLogY(logY);
|
||||
return view;
|
||||
}
|
||||
|
||||
template <typename MapperType, typename CanvasType, typename ViewType>
|
||||
@ -203,26 +264,49 @@ void Render(const vtkm::cont::DataSet& ds,
|
||||
CanvasType canvas(512, 512);
|
||||
vtkm::rendering::Scene scene;
|
||||
|
||||
//DRP Actor? no field? no colortable (or a constant colortable) ??
|
||||
scene.AddActor(
|
||||
vtkm::rendering::Actor(ds.GetCellSet(), ds.GetCoordinateSystem(), ds.GetField(fieldNm), color));
|
||||
vtkm::rendering::Camera camera;
|
||||
SetCamera<ViewType>(
|
||||
camera, ds.GetCoordinateSystem().GetBounds(), ds.GetField(fieldNm), dataViewPadding);
|
||||
|
||||
vtkm::rendering::Color background(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
vtkm::rendering::Color foreground(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
ViewType view(scene, mapper, canvas, camera, background, foreground);
|
||||
// Print the title
|
||||
std::unique_ptr<vtkm::rendering::TextAnnotationScreen> titleAnnotation(
|
||||
new vtkm::rendering::TextAnnotationScreen(
|
||||
"1D Test Plot", foreground, .1f, vtkm::Vec2f_32(-.27f, .87f), 0.f));
|
||||
view.AddAnnotation(std::move(titleAnnotation));
|
||||
view.SetLogY(logY);
|
||||
auto view = GetViewPtr<MapperType, CanvasType, ViewType>(
|
||||
ds, fieldNm, canvas, mapper, scene, color, logY, dataViewPadding);
|
||||
Render<MapperType, CanvasType, ViewType>(view, outputFile);
|
||||
}
|
||||
|
||||
template <typename MapperType, typename CanvasType, typename ViewType>
|
||||
void RenderAndRegressionTest(const vtkm::cont::DataSet& ds,
|
||||
const std::string& fieldNm,
|
||||
const vtkm::rendering::Color& color,
|
||||
const std::string& outputFile,
|
||||
const bool logY = false,
|
||||
const vtkm::Float64& dataViewPadding = 0)
|
||||
{
|
||||
MapperType mapper;
|
||||
CanvasType canvas(512, 512);
|
||||
vtkm::rendering::Scene scene;
|
||||
|
||||
auto view = GetViewPtr<MapperType, CanvasType, ViewType>(
|
||||
ds, fieldNm, canvas, mapper, scene, color, logY, dataViewPadding);
|
||||
VTKM_TEST_ASSERT(test_equal_images(view, outputFile));
|
||||
}
|
||||
// --------------------------------------------------------------
|
||||
|
||||
|
||||
// A render test that allows for testing different mapper params
|
||||
template <typename MapperType, typename CanvasType, typename ViewType>
|
||||
void Render(MapperType& mapper,
|
||||
const vtkm::cont::DataSet& ds,
|
||||
const std::string& fieldNm,
|
||||
const vtkm::cont::ColorTable& colorTable,
|
||||
const std::string& outputFile,
|
||||
const vtkm::Float64& dataViewPadding = 0)
|
||||
{
|
||||
CanvasType canvas(512, 512);
|
||||
vtkm::rendering::Scene scene;
|
||||
|
||||
auto view = GetViewPtr<MapperType, CanvasType, ViewType>(
|
||||
ds, fieldNm, canvas, mapper, scene, colorTable, dataViewPadding);
|
||||
Render<MapperType, CanvasType, ViewType>(*view, outputFile);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <typename MapperType1, typename MapperType2, typename CanvasType, typename ViewType>
|
||||
void MultiMapperRender(const vtkm::cont::DataSet& ds1,
|
||||
const vtkm::cont::DataSet& ds2,
|
||||
|
@ -118,12 +118,16 @@ void RenderTests()
|
||||
std::vector<vtkm::rendering::Color> colors;
|
||||
colors.push_back(vtkm::rendering::Color(1.f, 0.f, 0.f));
|
||||
colors.push_back(vtkm::rendering::Color(0.f, 1.f, 0.f));
|
||||
vtkm::rendering::testing::Render<M, C, V1>(
|
||||
maker.Make1DUniformDataSet0(), fields, colors, "wf_lines1D.pnm");
|
||||
vtkm::rendering::testing::RenderAndRegressionTest<M, C, V1>(
|
||||
maker.Make1DUniformDataSet0(), fields, colors, "rendering/wireframer/wf_lines1D.png");
|
||||
//test log y
|
||||
vtkm::rendering::Color red = vtkm::rendering::Color::red;
|
||||
vtkm::rendering::testing::Render<M, C, V1>(
|
||||
maker.Make1DUniformDataSet1(), "pointvar", red, "wf_linesLogY1D.pnm", true);
|
||||
vtkm::rendering::testing::RenderAndRegressionTest<M, C, V1>(
|
||||
maker.Make1DUniformDataSet1(),
|
||||
"pointvar",
|
||||
red,
|
||||
"rendering/wireframer/wf_linesLogY1D.png",
|
||||
true);
|
||||
}
|
||||
|
||||
} //namespace
|
||||
|
Loading…
Reference in New Issue
Block a user