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.
|
|
|
|
//============================================================================
|
|
|
|
#ifndef vtk_m_rendering_SceneRendererVolume_h
|
|
|
|
#define vtk_m_rendering_SceneRendererVolume_h
|
2016-04-18 20:42:59 +00:00
|
|
|
|
2016-01-20 22:40:54 +00:00
|
|
|
#include <vtkm/rendering/ColorTable.h>
|
|
|
|
#include <vtkm/rendering/Triangulator.h>
|
|
|
|
#include <vtkm/rendering/SceneRenderer.h>
|
2016-05-18 23:30:07 +00:00
|
|
|
#include <vtkm/rendering/raytracing/VolumeRendererStructured.h>
|
2016-01-20 22:40:54 +00:00
|
|
|
#include <vtkm/rendering/raytracing/Camera.h>
|
2016-05-18 17:25:05 +00:00
|
|
|
#include <vtkm/rendering/RenderSurfaceRayTracer.h>
|
2016-01-20 22:40:54 +00:00
|
|
|
#include <vtkm/rendering/View.h>
|
|
|
|
|
|
|
|
#include <typeinfo>
|
|
|
|
|
|
|
|
namespace vtkm {
|
|
|
|
namespace rendering {
|
|
|
|
template<typename DeviceAdapter = VTKM_DEFAULT_DEVICE_ADAPTER_TAG>
|
|
|
|
class SceneRendererVolume : public SceneRenderer
|
|
|
|
{
|
|
|
|
protected:
|
2016-05-18 23:30:07 +00:00
|
|
|
vtkm::rendering::raytracing::VolumeRendererStructured<DeviceAdapter> Tracer;
|
2016-05-18 17:25:05 +00:00
|
|
|
RenderSurfaceRayTracer *Surface;
|
2016-01-20 22:40:54 +00:00
|
|
|
public:
|
|
|
|
VTKM_CONT_EXPORT
|
|
|
|
SceneRendererVolume()
|
2016-05-18 17:25:05 +00:00
|
|
|
{
|
|
|
|
Surface = NULL;
|
|
|
|
}
|
2016-01-20 22:40:54 +00:00
|
|
|
|
|
|
|
VTKM_CONT_EXPORT
|
|
|
|
void SetNumberOfSamples(const vtkm::Int32 &numSamples)
|
|
|
|
{
|
|
|
|
Tracer.SetNumberOfSamples(numSamples);
|
|
|
|
}
|
2016-05-18 17:25:05 +00:00
|
|
|
|
|
|
|
VTKM_CONT_EXPORT
|
|
|
|
void SetRenderSurface(RenderSurface *surface)
|
|
|
|
{
|
|
|
|
if(surface != NULL)
|
|
|
|
{
|
|
|
|
|
|
|
|
Surface = dynamic_cast<RenderSurfaceRayTracer*>(surface);
|
|
|
|
if(Surface == NULL)
|
|
|
|
{
|
|
|
|
throw vtkm::cont::ErrorControlBadValue(
|
|
|
|
"Volume Render: bad surface type. Must be RenderSurfaceRayTracer");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-01-20 22:40:54 +00:00
|
|
|
|
|
|
|
VTKM_CONT_EXPORT
|
|
|
|
virtual void RenderCells(const vtkm::cont::DynamicCellSet &cellset,
|
|
|
|
const vtkm::cont::CoordinateSystem &coords,
|
2016-02-09 13:59:26 +00:00
|
|
|
vtkm::cont::Field &scalarField,
|
|
|
|
const vtkm::rendering::ColorTable &, //colorTable
|
2016-04-18 20:42:59 +00:00
|
|
|
vtkm::rendering::View &view,
|
2016-02-12 18:42:54 +00:00
|
|
|
vtkm::Float64 *scalarBounds=NULL) //scalarBounds=NULL)
|
2016-01-20 22:40:54 +00:00
|
|
|
{
|
|
|
|
vtkm::cont::DynamicArrayHandleCoordinateSystem dynamicCoordsHandle = coords.GetData();
|
|
|
|
vtkm::Float64 coordsBounds[6]; // Xmin,Xmax,Ymin..
|
|
|
|
coords.GetBounds(coordsBounds,DeviceAdapter());
|
|
|
|
|
|
|
|
bool isExplicit = false;
|
|
|
|
bool isUniform = false;
|
2016-02-12 18:42:54 +00:00
|
|
|
if(!cellset.IsSameType(vtkm::cont::CellSetStructured<3>()))
|
2016-01-20 22:40:54 +00:00
|
|
|
{
|
|
|
|
std::cerr<<"ERROR cell set type not currently supported\n";
|
|
|
|
std::string theType = typeid(cellset).name();
|
|
|
|
std::cerr<<"Type : "<<theType<<std::endl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-02-12 18:42:54 +00:00
|
|
|
vtkm::cont::CellSetStructured<3> cellSetStructured3D = cellset.Cast<vtkm::cont::CellSetStructured<3> >();
|
2016-05-18 17:25:05 +00:00
|
|
|
//vtkm::cont::ArrayHandleUniformPointCoordinates vertices;
|
|
|
|
//vertices = dynamicCoordsHandle.Cast<vtkm::cont::ArrayHandleUniformPointCoordinates>();
|
2016-01-20 22:40:54 +00:00
|
|
|
vtkm::rendering::raytracing::Camera<DeviceAdapter> &camera = Tracer.GetCamera();
|
2016-04-18 20:42:59 +00:00
|
|
|
camera.SetParameters(view);
|
2016-05-18 17:25:05 +00:00
|
|
|
Tracer.SetData(coords, scalarField, coordsBounds, cellSetStructured3D, scalarBounds);
|
2016-01-20 22:40:54 +00:00
|
|
|
Tracer.SetColorMap(ColorMap);
|
|
|
|
Tracer.SetBackgroundColor(this->BackgroundColor);
|
2016-05-18 17:25:05 +00:00
|
|
|
Tracer.Render(Surface);
|
2016-01-20 22:40:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}} //namespace vtkm::rendering
|
|
|
|
#endif //vtk_m_rendering_SceneRendererVolume_h
|