2016-09-14 13:19:57 +00:00
|
|
|
|
|
|
|
|
2016-01-20 22:40:54 +00:00
|
|
|
//============================================================================
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// Copyright 2015 Sandia Corporation.
|
|
|
|
// Copyright 2015 UT-Battelle, LLC.
|
|
|
|
// Copyright 2015 Los Alamos National Security.
|
|
|
|
//
|
|
|
|
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
|
|
|
// the U.S. Government retains certain rights in this software.
|
|
|
|
//
|
|
|
|
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
|
|
|
// Laboratory (LANL), the U.S. Government retains certain rights in
|
|
|
|
// this software.
|
|
|
|
//============================================================================
|
|
|
|
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
2016-06-02 21:43:30 +00:00
|
|
|
#include <vtkm/rendering/Actor.h>
|
2016-06-02 22:02:17 +00:00
|
|
|
#include <vtkm/rendering/Canvas.h>
|
|
|
|
#include <vtkm/rendering/CanvasRayTracer.h>
|
2016-06-02 19:41:14 +00:00
|
|
|
#include <vtkm/rendering/MapperVolume.h>
|
2016-04-18 20:42:59 +00:00
|
|
|
#include <vtkm/rendering/Scene.h>
|
2016-09-01 18:33:28 +00:00
|
|
|
#include <vtkm/rendering/View3D.h>
|
2016-01-20 22:40:54 +00:00
|
|
|
#include <vtkm/cont/DeviceAdapter.h>
|
|
|
|
#include <vtkm/cont/testing/Testing.h>
|
2016-04-18 20:42:59 +00:00
|
|
|
|
2016-01-20 22:40:54 +00:00
|
|
|
namespace {
|
|
|
|
|
2016-06-02 19:04:01 +00:00
|
|
|
void Set3DView(vtkm::rendering::Camera &camera,
|
2016-06-03 20:22:56 +00:00
|
|
|
const vtkm::cont::CoordinateSystem &coords)
|
2016-04-18 20:42:59 +00:00
|
|
|
{
|
2016-05-26 23:04:35 +00:00
|
|
|
vtkm::Bounds coordsBounds =
|
|
|
|
coords.GetBounds(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
2016-05-19 22:37:37 +00:00
|
|
|
//set up a default view
|
2016-06-03 23:27:03 +00:00
|
|
|
camera = vtkm::rendering::Camera();
|
|
|
|
camera.ResetToBounds(coordsBounds);
|
2016-06-14 19:52:55 +00:00
|
|
|
camera.Azimuth(45.0f);
|
|
|
|
camera.Elevation(45.0f);
|
2016-06-07 15:23:09 +00:00
|
|
|
|
|
|
|
std::cout << "Camera3d: pos: " << camera.GetPosition() << std::endl;
|
|
|
|
std::cout << " lookAt: " << camera.GetLookAt() << std::endl;
|
|
|
|
std::cout << " up: " << camera.GetViewUp() << std::endl;
|
|
|
|
std::cout << " near/far: " << camera.GetClippingRange() << std::endl;
|
|
|
|
std::cout << " fieldOfView: " << camera.GetFieldOfView() << std::endl;
|
2016-05-19 22:37:37 +00:00
|
|
|
}
|
2016-04-18 20:42:59 +00:00
|
|
|
|
|
|
|
void Render(const vtkm::cont::DataSet &ds,
|
|
|
|
const std::string &fieldNm,
|
|
|
|
const std::string &ctName,
|
2016-05-19 22:37:37 +00:00
|
|
|
const std::string &outputFile)
|
2016-01-20 22:40:54 +00:00
|
|
|
{
|
2016-04-18 20:42:59 +00:00
|
|
|
const vtkm::Int32 W = 512, H = 512;
|
|
|
|
const vtkm::cont::CoordinateSystem coords = ds.GetCoordinateSystem();
|
2016-08-29 21:50:47 +00:00
|
|
|
vtkm::rendering::MapperVolume mapper;
|
2016-05-19 22:37:37 +00:00
|
|
|
|
2016-06-02 19:04:01 +00:00
|
|
|
vtkm::rendering::Camera camera;
|
2016-06-03 20:22:56 +00:00
|
|
|
Set3DView(camera, coords);
|
2016-05-19 22:37:37 +00:00
|
|
|
|
2016-05-18 23:30:07 +00:00
|
|
|
vtkm::rendering::ColorTable colorTable(ctName);
|
|
|
|
colorTable.AddAlphaControlPoint(0.0f, .01f);
|
|
|
|
colorTable.AddAlphaControlPoint(1.0f, .01f);
|
2016-05-19 22:37:37 +00:00
|
|
|
|
2016-06-01 17:51:37 +00:00
|
|
|
vtkm::rendering::Scene scene;
|
2016-04-18 20:42:59 +00:00
|
|
|
vtkm::rendering::Color bg(0.2f, 0.2f, 0.2f, 1.0f);
|
2016-06-11 18:09:51 +00:00
|
|
|
vtkm::rendering::CanvasRayTracer canvas(W,H);
|
2016-05-26 14:38:55 +00:00
|
|
|
scene.AddActor(vtkm::rendering::Actor(ds.GetCellSet(),
|
|
|
|
ds.GetCoordinateSystem(),
|
|
|
|
ds.GetField(fieldNm),
|
|
|
|
colorTable));
|
2016-02-09 13:59:26 +00:00
|
|
|
|
2016-06-08 20:53:32 +00:00
|
|
|
vtkm::rendering::View3D view(scene, mapper, canvas, camera, bg);
|
2016-05-19 22:37:37 +00:00
|
|
|
|
2016-06-06 14:29:17 +00:00
|
|
|
view.Initialize();
|
|
|
|
view.Paint();
|
|
|
|
view.SaveAs(outputFile);
|
2016-05-19 22:37:37 +00:00
|
|
|
|
2016-04-18 20:42:59 +00:00
|
|
|
}
|
|
|
|
|
2016-05-18 17:25:05 +00:00
|
|
|
void RenderTests()
|
2016-04-18 20:42:59 +00:00
|
|
|
{
|
|
|
|
vtkm::cont::testing::MakeTestDataSet maker;
|
|
|
|
|
2016-05-18 17:25:05 +00:00
|
|
|
//3D tests.
|
|
|
|
Render(maker.Make3DRegularDataSet0(),
|
|
|
|
"pointvar", "thermal", "reg3D.pnm");
|
|
|
|
Render(maker.Make3DRectilinearDataSet0(),
|
|
|
|
"pointvar", "thermal", "rect3D.pnm");
|
2016-04-18 20:42:59 +00:00
|
|
|
}
|
|
|
|
|
2016-01-20 22:40:54 +00:00
|
|
|
} //namespace
|
2016-06-02 19:41:14 +00:00
|
|
|
int UnitTestMapperVolume(int, char *[])
|
2016-01-20 22:40:54 +00:00
|
|
|
{
|
2016-05-18 17:25:05 +00:00
|
|
|
return vtkm::cont::testing::Testing::Run(RenderTests);
|
2016-01-20 22:40:54 +00:00
|
|
|
}
|
2016-09-14 13:19:57 +00:00
|
|
|
|