2017-08-06 02:11:28 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2017-08-06 02:11:28 +00:00
|
|
|
// 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/rendering/Actor.h>
|
|
|
|
#include <vtkm/rendering/Canvas.h>
|
|
|
|
#include <vtkm/rendering/CanvasRayTracer.h>
|
2017-08-06 18:59:19 +00:00
|
|
|
#include <vtkm/rendering/MapperConnectivity.h>
|
2017-08-06 02:11:28 +00:00
|
|
|
#include <vtkm/rendering/MapperRayTracer.h>
|
|
|
|
#include <vtkm/rendering/MapperVolume.h>
|
|
|
|
#include <vtkm/rendering/Scene.h>
|
|
|
|
#include <vtkm/rendering/View3D.h>
|
|
|
|
#include <vtkm/rendering/testing/RenderTest.h>
|
|
|
|
|
2022-07-06 19:36:00 +00:00
|
|
|
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
|
|
|
#include <vtkm/cont/testing/Testing.h>
|
2017-08-06 02:11:28 +00:00
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
|
2021-12-29 21:12:11 +00:00
|
|
|
// Multi-mapper rendering is something of a hack right now. A view only supports one mapper
|
|
|
|
// at a time, so to use different mapper types you have to render the mappers yourself.
|
|
|
|
template <typename MapperType1, typename MapperType2>
|
|
|
|
void MultiMapperRender(const vtkm::cont::DataSet& ds1,
|
|
|
|
const vtkm::cont::DataSet& ds2,
|
|
|
|
const std::string& fieldNm,
|
|
|
|
const vtkm::cont::ColorTable& colorTable1,
|
|
|
|
const vtkm::cont::ColorTable& colorTable2,
|
|
|
|
const std::string& outputFile)
|
|
|
|
{
|
|
|
|
MapperType1 mapper1;
|
|
|
|
MapperType2 mapper2;
|
|
|
|
|
|
|
|
vtkm::rendering::CanvasRayTracer canvas(300, 300);
|
|
|
|
canvas.SetBackgroundColor(vtkm::rendering::Color(0.8f, 0.8f, 0.8f, 1.0f));
|
|
|
|
canvas.Clear();
|
|
|
|
|
|
|
|
vtkm::Bounds totalBounds =
|
|
|
|
ds1.GetCoordinateSystem().GetBounds() + ds2.GetCoordinateSystem().GetBounds();
|
|
|
|
vtkm::rendering::Camera camera;
|
|
|
|
camera.ResetToBounds(totalBounds);
|
|
|
|
camera.Azimuth(45.0f);
|
|
|
|
camera.Elevation(45.0f);
|
|
|
|
|
|
|
|
mapper1.SetCanvas(&canvas);
|
|
|
|
mapper1.SetActiveColorTable(colorTable1);
|
|
|
|
mapper1.SetCompositeBackground(false);
|
|
|
|
|
|
|
|
mapper2.SetCanvas(&canvas);
|
|
|
|
mapper2.SetActiveColorTable(colorTable2);
|
|
|
|
|
|
|
|
const vtkm::cont::Field field1 = ds1.GetField(fieldNm);
|
|
|
|
vtkm::Range range1;
|
|
|
|
field1.GetRange(&range1);
|
|
|
|
|
|
|
|
const vtkm::cont::Field field2 = ds2.GetField(fieldNm);
|
|
|
|
vtkm::Range range2;
|
|
|
|
field2.GetRange(&range2);
|
|
|
|
|
|
|
|
mapper1.RenderCells(
|
|
|
|
ds1.GetCellSet(), ds1.GetCoordinateSystem(), field1, colorTable1, camera, range1);
|
|
|
|
|
|
|
|
mapper2.RenderCells(
|
|
|
|
ds2.GetCellSet(), ds2.GetCoordinateSystem(), field2, colorTable2, camera, range2);
|
|
|
|
|
|
|
|
VTKM_TEST_ASSERT(test_equal_images(canvas, outputFile));
|
|
|
|
}
|
|
|
|
|
2017-08-06 02:11:28 +00:00
|
|
|
void RenderTests()
|
|
|
|
{
|
2018-05-25 21:18:41 +00:00
|
|
|
using M1 = vtkm::rendering::MapperVolume;
|
|
|
|
using M2 = vtkm::rendering::MapperConnectivity;
|
|
|
|
using R = vtkm::rendering::MapperRayTracer;
|
2017-08-06 02:11:28 +00:00
|
|
|
|
|
|
|
vtkm::cont::testing::MakeTestDataSet maker;
|
2018-01-18 18:55:15 +00:00
|
|
|
vtkm::cont::ColorTable colorTable("inferno");
|
2017-08-06 02:11:28 +00:00
|
|
|
|
|
|
|
|
2018-01-18 18:55:15 +00:00
|
|
|
vtkm::cont::ColorTable colorTable2("cool to warm");
|
|
|
|
colorTable2.AddPointAlpha(0.0, .02f);
|
|
|
|
colorTable2.AddPointAlpha(1.0, .02f);
|
2017-08-06 02:11:28 +00:00
|
|
|
|
2021-12-29 21:12:11 +00:00
|
|
|
MultiMapperRender<R, M2>(maker.Make3DExplicitDataSetPolygonal(),
|
|
|
|
maker.Make3DRectilinearDataSet0(),
|
|
|
|
"pointvar",
|
|
|
|
colorTable,
|
|
|
|
colorTable2,
|
|
|
|
"rendering/multimapper/raytracer-connectivity.png");
|
|
|
|
|
|
|
|
MultiMapperRender<R, M1>(maker.Make3DExplicitDataSet4(),
|
|
|
|
maker.Make3DRectilinearDataSet0(),
|
|
|
|
"pointvar",
|
|
|
|
colorTable,
|
|
|
|
colorTable2,
|
|
|
|
"rendering/multimapper/raytracer-volume.png");
|
2017-08-06 02:11:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} //namespace
|
|
|
|
|
2019-01-03 02:14:17 +00:00
|
|
|
int UnitTestMultiMapper(int argc, char* argv[])
|
2017-08-06 02:11:28 +00:00
|
|
|
{
|
2019-01-03 02:14:17 +00:00
|
|
|
return vtkm::cont::testing::Testing::Run(RenderTests, argc, argv);
|
2017-08-06 02:11:28 +00:00
|
|
|
}
|