2016-08-26 21:58:21 +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/rendering/CanvasRayTracer.h>
|
|
|
|
|
2016-08-29 20:26:02 +00:00
|
|
|
#include <vtkm/cont/TryExecute.h>
|
2016-08-26 21:58:21 +00:00
|
|
|
#include <vtkm/exec/ExecutionWholeArray.h>
|
|
|
|
#include <vtkm/rendering/Canvas.h>
|
|
|
|
#include <vtkm/rendering/Color.h>
|
|
|
|
#include <vtkm/worklet/DispatcherMapField.h>
|
2017-05-18 14:51:24 +00:00
|
|
|
#include <vtkm/worklet/WorkletMapField.h>
|
2016-08-26 21:58:21 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace rendering
|
|
|
|
{
|
2016-08-26 21:58:21 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace internal
|
|
|
|
{
|
2016-08-26 21:58:21 +00:00
|
|
|
|
|
|
|
class ClearBuffers : public vtkm::worklet::WorkletMapField
|
|
|
|
{
|
|
|
|
vtkm::rendering::Color ClearColor;
|
2017-05-18 14:29:41 +00:00
|
|
|
|
2016-08-26 21:58:21 +00:00
|
|
|
public:
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
ClearBuffers(const vtkm::rendering::Color& clearColor)
|
2016-08-26 21:58:21 +00:00
|
|
|
: ClearColor(clearColor)
|
2017-05-18 14:29:41 +00:00
|
|
|
{
|
|
|
|
}
|
2016-08-26 21:58:21 +00:00
|
|
|
typedef void ControlSignature(FieldOut<>, FieldOut<>);
|
|
|
|
typedef void ExecutionSignature(_1, _2);
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_EXEC
|
2017-05-18 14:29:41 +00:00
|
|
|
void operator()(vtkm::Vec<vtkm::Float32, 4>& color, vtkm::Float32& depth) const
|
2016-08-26 21:58:21 +00:00
|
|
|
{
|
|
|
|
color = this->ClearColor.Components;
|
|
|
|
depth = 1.001f;
|
|
|
|
}
|
|
|
|
}; //class ClearBuffers
|
|
|
|
|
2016-08-29 20:26:02 +00:00
|
|
|
struct ClearBuffersInvokeFunctor
|
|
|
|
{
|
|
|
|
typedef vtkm::rendering::Canvas::ColorBufferType ColorBufferType;
|
|
|
|
typedef vtkm::rendering::Canvas::DepthBufferType DepthBufferType;
|
|
|
|
|
|
|
|
ClearBuffers Worklet;
|
|
|
|
ColorBufferType ColorBuffer;
|
|
|
|
DepthBufferType DepthBuffer;
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
ClearBuffersInvokeFunctor(const vtkm::rendering::Color& backgroundColor,
|
2017-05-26 17:53:28 +00:00
|
|
|
const ColorBufferType& colorBuffer,
|
|
|
|
const DepthBufferType& depthBuffer)
|
2017-05-18 14:29:41 +00:00
|
|
|
: Worklet(backgroundColor)
|
|
|
|
, ColorBuffer(colorBuffer)
|
|
|
|
, DepthBuffer(depthBuffer)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Device>
|
|
|
|
VTKM_CONT bool operator()(Device) const
|
2016-08-29 20:26:02 +00:00
|
|
|
{
|
2016-08-29 21:50:47 +00:00
|
|
|
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::worklet::DispatcherMapField<ClearBuffers, Device> dispatcher(this->Worklet);
|
|
|
|
dispatcher.Invoke(this->ColorBuffer, this->DepthBuffer);
|
2016-08-29 20:26:02 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace internal
|
2016-08-26 21:58:21 +00:00
|
|
|
|
|
|
|
CanvasRayTracer::CanvasRayTracer(vtkm::Id width, vtkm::Id height)
|
|
|
|
: Canvas(width, height)
|
2017-05-18 14:29:41 +00:00
|
|
|
{
|
|
|
|
}
|
2016-08-26 21:58:21 +00:00
|
|
|
|
2016-09-08 23:08:17 +00:00
|
|
|
CanvasRayTracer::~CanvasRayTracer()
|
2017-05-18 14:29:41 +00:00
|
|
|
{
|
|
|
|
}
|
2016-09-08 23:08:17 +00:00
|
|
|
|
2016-08-26 21:58:21 +00:00
|
|
|
void CanvasRayTracer::Initialize()
|
|
|
|
{
|
|
|
|
// Nothing to initialize
|
|
|
|
}
|
|
|
|
|
|
|
|
void CanvasRayTracer::Activate()
|
|
|
|
{
|
|
|
|
// Nothing to activate
|
|
|
|
}
|
|
|
|
|
|
|
|
void CanvasRayTracer::Finish()
|
|
|
|
{
|
|
|
|
// Nothing to finish
|
|
|
|
}
|
|
|
|
|
|
|
|
void CanvasRayTracer::Clear()
|
|
|
|
{
|
2016-08-29 21:50:47 +00:00
|
|
|
// TODO: Should the rendering library support policies or some other way to
|
2016-08-29 20:26:02 +00:00
|
|
|
// configure with custom devices?
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::TryExecute(internal::ClearBuffersInvokeFunctor(
|
|
|
|
this->GetBackgroundColor(), this->GetColorBuffer(), this->GetDepthBuffer()));
|
2016-08-26 21:58:21 +00:00
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::rendering::Canvas* CanvasRayTracer::NewCopy() const
|
2016-09-01 18:33:28 +00:00
|
|
|
{
|
|
|
|
return new vtkm::rendering::CanvasRayTracer(*this);
|
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
void CanvasRayTracer::AddLine(const vtkm::Vec<vtkm::Float64, 2>&,
|
2017-05-26 17:53:28 +00:00
|
|
|
const vtkm::Vec<vtkm::Float64, 2>&,
|
|
|
|
vtkm::Float32,
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::rendering::Color&) const
|
2016-08-26 21:58:21 +00:00
|
|
|
{
|
|
|
|
// Not implemented
|
|
|
|
}
|
|
|
|
|
2017-05-26 17:53:28 +00:00
|
|
|
void CanvasRayTracer::AddColorBar(const vtkm::Bounds&,
|
|
|
|
const vtkm::rendering::ColorTable&,
|
2017-05-18 14:29:41 +00:00
|
|
|
bool) const
|
2016-08-26 21:58:21 +00:00
|
|
|
{
|
|
|
|
// Not implemented
|
|
|
|
}
|
|
|
|
|
2017-05-26 17:53:28 +00:00
|
|
|
void CanvasRayTracer::AddText(const vtkm::Vec<vtkm::Float32, 2>&,
|
|
|
|
vtkm::Float32,
|
|
|
|
vtkm::Float32,
|
|
|
|
vtkm::Float32,
|
|
|
|
const vtkm::Vec<vtkm::Float32, 2>&,
|
|
|
|
const vtkm::rendering::Color&,
|
|
|
|
const std::string&) const
|
2016-08-26 21:58:21 +00:00
|
|
|
{
|
|
|
|
// Not implemented
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|