Refactoring

This commit is contained in:
Manish Mathai 2017-08-21 14:45:48 -07:00
parent 44357d5113
commit b727377fd5
6 changed files with 43 additions and 517 deletions

@ -29,7 +29,6 @@ set(headers
Camera.h
Canvas.h
CanvasRayTracer.h
CanvasWireframer.h
Color.h
ColorBarAnnotation.h
ColorLegendAnnotation.h
@ -65,7 +64,6 @@ set(sources
Camera.cxx
Canvas.cxx
CanvasRayTracer.cxx
CanvasWireframer.cxx
Color.cxx
ColorBarAnnotation.cxx
ColorLegendAnnotation.cxx
@ -132,7 +130,6 @@ set(osmesa_sources
set(device_sources
Mapper.cxx
MapperWireframer.cxx
CanvasWireframer.cxx
CanvasRayTracer.cxx
ConnectivityProxy.cxx
raytracing/BoundingVolumeHierarchy.cxx

@ -1,404 +0,0 @@
//============================================================================
// 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/CanvasWireframer.h>
#include <fstream>
#include <vtkm/Assert.h>
#include <vtkm/Math.h>
#include <vtkm/cont/ArrayHandleCounting.h>
#include <vtkm/cont/TryExecute.h>
#include <vtkm/exec/ExecutionWholeArray.h>
#include <vtkm/worklet/DispatcherMapField.h>
#include <vtkm/worklet/WorkletMapField.h>
namespace vtkm
{
namespace rendering
{
namespace
{
class ClearBuffers : public vtkm::worklet::WorkletMapField
{
vtkm::rendering::Color ClearColor;
public:
VTKM_CONT
ClearBuffers(const vtkm::rendering::Color& clearColor)
: ClearColor(clearColor)
{
}
typedef void ControlSignature(FieldOut<>, FieldOut<>);
typedef void ExecutionSignature(_1, _2);
VTKM_EXEC
void operator()(vtkm::Vec<vtkm::Float32, 4>& color, vtkm::Float32& depth) const
{
color = this->ClearColor.Components;
// Set the depth buffer value to value slightly greater than 1.0f,
// marking it as invalid and ensuring future depth checks valid range
// of [0.0f, 1.0f] succeed.
depth = 1.001f;
}
}; //class ClearBuffers
struct ClearBuffersInvokeFunctor
{
typedef vtkm::rendering::Canvas::ColorBufferType ColorBufferType;
typedef vtkm::rendering::Canvas::DepthBufferType DepthBufferType;
ClearBuffers Worklet;
ColorBufferType ColorBuffer;
DepthBufferType DepthBuffer;
VTKM_CONT
ClearBuffersInvokeFunctor(const vtkm::rendering::Color& backgroundColor,
const ColorBufferType& colorBuffer,
const DepthBufferType& depthBuffer)
: Worklet(backgroundColor)
, ColorBuffer(colorBuffer)
, DepthBuffer(depthBuffer)
{
}
template <typename Device>
VTKM_CONT bool operator()(Device) const
{
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
vtkm::worklet::DispatcherMapField<ClearBuffers, Device> dispatcher(this->Worklet);
dispatcher.Invoke(this->ColorBuffer, this->DepthBuffer);
return true;
}
};
vtkm::Float32 IPart(vtkm::Float32 x)
{
return vtkm::Floor(x);
}
vtkm::Float32 FPart(vtkm::Float32 x)
{
return x - vtkm::Floor(x);
}
vtkm::Float32 RFPart(vtkm::Float32 x)
{
return 1.0f - FPart(x);
}
class LinePlotter : public vtkm::worklet::WorkletMapField
{
public:
typedef vtkm::rendering::Canvas::ColorBufferType ColorBufferType;
VTKM_CONT
LinePlotter(vtkm::Float32 x1,
vtkm::Float32 y1,
vtkm::Id width,
vtkm::Id height,
vtkm::Float32 gradient,
const vtkm::rendering::Color& color,
bool transposed)
: X1(x1)
, Y1(y1)
, Width(width)
, Height(height)
, Gradient(gradient)
, Color(color)
, Transposed(transposed)
{
}
typedef void ControlSignature(FieldIn<>, ExecObject);
typedef void ExecutionSignature(_1, _2);
VTKM_EXEC
void operator()(const vtkm::Id x,
vtkm::exec::ExecutionWholeArray<ColorBufferType::ValueType>& colorBuffer) const
{
vtkm::Float32 y = Y1 + (static_cast<vtkm::Float32>(x) - X1) * Gradient;
vtkm::Id yInt = static_cast<vtkm::Id>(y);
if (Transposed)
{
BlendPixel(yInt, x, colorBuffer, RFPart(y));
BlendPixel(yInt + 1, x, colorBuffer, FPart(y));
}
else
{
BlendPixel(x, yInt, colorBuffer, RFPart(y));
BlendPixel(x, yInt + 1, colorBuffer, FPart(y));
}
}
private:
VTKM_EXEC
inline vtkm::Id GetBufferIndex(vtkm::Id x, vtkm::Id y) const { return y * Width + x; }
VTKM_EXEC
inline void BlendPixel(vtkm::Id x,
vtkm::Id y,
vtkm::exec::ExecutionWholeArray<ColorBufferType::ValueType>& colorBuffer,
vtkm::Float32 intensity) const
{
if (y < 0 || y >= Height)
{
return;
}
vtkm::Id index = this->GetBufferIndex(x, y);
vtkm::Vec<vtkm::Float32, 4> dstColor(Color.Components);
vtkm::Vec<vtkm::Float32, 4> srcColor(colorBuffer.Get(index));
vtkm::Vec<vtkm::Float32, 4> blendedColor;
blendedColor[0] = dstColor[0] * intensity + srcColor[0] * (1 - intensity);
blendedColor[1] = dstColor[1] * intensity + srcColor[1] * (1 - intensity);
blendedColor[2] = dstColor[2] * intensity + srcColor[2] * (1 - intensity);
blendedColor[3] = 1.0f;
colorBuffer.Set(index, blendedColor);
}
vtkm::Float32 X1, Y1;
vtkm::Id Width, Height;
vtkm::Float32 Gradient;
vtkm::rendering::Color Color;
bool Transposed;
}; //class LinePlotter
struct LinePlotterInvokeFunctor
{
typedef vtkm::rendering::Canvas::ColorBufferType ColorBufferType;
typedef vtkm::rendering::Canvas::DepthBufferType DepthBufferType;
vtkm::Float32 X1, Y1;
vtkm::Id Width, Height;
vtkm::Float32 Gradient;
vtkm::rendering::Color Color;
bool Transposed;
LinePlotter Worklet;
vtkm::cont::ArrayHandleCounting<vtkm::Id> Arr;
vtkm::exec::ExecutionWholeArray<ColorBufferType::ValueType> Buffer;
VTKM_CONT
LinePlotterInvokeFunctor(vtkm::Float32 x1,
vtkm::Float32 y1,
vtkm::Id width,
vtkm::Id height,
vtkm::Float32 gradient,
const vtkm::rendering::Color& color,
bool transposed,
vtkm::cont::ArrayHandleCounting<vtkm::Id> arr,
ColorBufferType buffer)
: Worklet(x1, y1, width, height, gradient, color, transposed)
, Arr(arr)
, Buffer(buffer)
{
}
template <typename Device>
VTKM_CONT bool operator()(Device) const
{
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
vtkm::worklet::DispatcherMapField<LinePlotter, Device> dispatcher(this->Worklet);
dispatcher.Invoke(this->Arr, this->Buffer);
return true;
}
};
} // namespace
CanvasWireframer::CanvasWireframer(vtkm::Id width, vtkm::Id height)
: Canvas(width, height)
{
}
CanvasWireframer::~CanvasWireframer()
{
}
void CanvasWireframer::Initialize()
{
// Nothing to initialize
}
void CanvasWireframer::Activate()
{
// Nothing to activate
}
void CanvasWireframer::Finish()
{
// Nothing to finish
}
void CanvasWireframer::Clear()
{
vtkm::cont::TryExecute(ClearBuffersInvokeFunctor(
this->GetBackgroundColor(), this->GetColorBuffer(), this->GetDepthBuffer()));
}
vtkm::rendering::Canvas* CanvasWireframer::NewCopy() const
{
return new vtkm::rendering::CanvasWireframer(*this);
}
void CanvasWireframer::AddLine(const vtkm::Vec<vtkm::Float64, 2>& start,
const vtkm::Vec<vtkm::Float64, 2>& end,
vtkm::Float32 vtkmNotUsed(lineWidth),
const vtkm::rendering::Color& color) const
{
// Draw's a line from start to end using the specified color.
// lineWidth is ignored for now.
/*
VTKM_ASSERT(start[0] >= 0.0f && start[0] < this->GetWidth()
&& start[1] >= 0.0f && start[1] < this->GetHeight()
&& end[0] >= 0.0f && end[0] < this->GetWidth()
&& end[1] >= 0.0f && end[1] < this->GetHeight());
*/
vtkm::Float32 x1 = static_cast<vtkm::Float32>(start[0]);
vtkm::Float32 y1 = static_cast<vtkm::Float32>(start[1]);
vtkm::Float32 x2 = static_cast<vtkm::Float32>(end[0]);
vtkm::Float32 y2 = static_cast<vtkm::Float32>(end[1]);
// If the line is steep, i.e., the height is greater than the width, then
// transpose the co-ordinates to prevent "holes" in the line. This ensures
// that we pick the co-ordinate which grows at a lesser rate than the other.
bool transposed = std::fabs(y2 - y1) > std::fabs(x2 - x1);
if (transposed)
{
std::swap(x1, y1);
std::swap(x2, y2);
transposed = true;
}
// Ensure we are always going from left to right
if (x1 > x2)
{
std::swap(x1, x2);
std::swap(y1, y2);
}
vtkm::Float32 dx = x2 - x1;
vtkm::Float32 dy = y2 - y1;
vtkm::Float32 gradient = (dx == 0.0) ? 1.0f : (dy / dx);
vtkm::Float32 xEnd = vtkm::Round(x1);
vtkm::Float32 yEnd = y1 + gradient * (xEnd - x1);
vtkm::Float32 xGap = RFPart(x1 + 0.5f);
vtkm::Float32 xPxl1 = xEnd, yPxl1 = IPart(yEnd);
if (transposed)
{
BlendPixel(yPxl1, xPxl1, color, RFPart(yEnd) * xGap);
BlendPixel(yPxl1 + 1, xPxl1, color, FPart(yEnd) * xGap);
}
else
{
BlendPixel(xPxl1, yPxl1, color, RFPart(yEnd) * xGap);
BlendPixel(xPxl1, yPxl1 + 1, color, FPart(yEnd) * xGap);
}
xEnd = vtkm::Round(x2);
yEnd = y2 + gradient * (xEnd - x2);
xGap = FPart(x2 + 0.5f);
vtkm::Float32 xPxl2 = xEnd, yPxl2 = IPart(yEnd);
if (transposed)
{
BlendPixel(yPxl2, xPxl2, color, RFPart(yEnd) * xGap);
BlendPixel(yPxl2 + 1, xPxl2, color, FPart(yEnd) * xGap);
}
else
{
BlendPixel(xPxl2, yPxl2, color, RFPart(yEnd) * xGap);
BlendPixel(xPxl2, yPxl2 + 1, color, FPart(yEnd) * xGap);
}
vtkm::cont::ArrayHandleCounting<vtkm::Id> xCoords(static_cast<vtkm::Id>(xPxl1 + 1),
static_cast<vtkm::Id>(1),
static_cast<vtkm::Id>(xPxl2 - xPxl1 - 1));
ColorBufferType colorBuffer(this->GetColorBuffer());
vtkm::cont::TryExecute(LinePlotterInvokeFunctor(x1,
y1,
this->GetWidth(),
this->GetHeight(),
gradient,
color,
transposed,
xCoords,
colorBuffer));
}
void CanvasWireframer::BlendPixel(vtkm::Float32 x,
vtkm::Float32 y,
const vtkm::rendering::Color& color,
vtkm::Float32 intensity) const
{
vtkm::Id xi = static_cast<vtkm::Id>(x), yi = static_cast<vtkm::Id>(y);
if (!(xi >= 0 && xi < this->GetWidth() && yi >= 0 && yi < this->GetHeight()))
return;
vtkm::Id index = this->GetBufferIndex(static_cast<vtkm::Id>(x), static_cast<vtkm::Id>(y));
ColorBufferType buffer(this->GetColorBuffer());
vtkm::Vec<vtkm::Float32, 4> dstColor(color.Components);
vtkm::Vec<vtkm::Float32, 4> srcColor(buffer.GetPortalConstControl().Get(index));
vtkm::Vec<vtkm::Float32, 4> blendedColor;
blendedColor[0] = dstColor[0] * intensity + srcColor[0] * (1 - intensity);
blendedColor[1] = dstColor[1] * intensity + srcColor[1] * (1 - intensity);
blendedColor[2] = dstColor[2] * intensity + srcColor[2] * (1 - intensity);
blendedColor[3] = 1.0f;
buffer.GetPortalControl().Set(index, blendedColor);
}
void CanvasWireframer::AddColorBar(const vtkm::Bounds&,
const vtkm::rendering::ColorTable&,
bool) const
{
//TODO: Implement
}
void CanvasWireframer::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
{
//TODO: Implement
}
void CanvasWireframer::AddColorSwatch(const vtkm::Vec<vtkm::Float64, 2>&,
const vtkm::Vec<vtkm::Float64, 2>&,
const vtkm::Vec<vtkm::Float64, 2>&,
const vtkm::Vec<vtkm::Float64, 2>&,
const vtkm::rendering::Color&) const
{
//TODO: Implement
}
vtkm::Id CanvasWireframer::GetBufferIndex(vtkm::Id x, vtkm::Id y) const
{
return y * this->GetWidth() + x;
}
} // namespace rendering
} // namespace vtkm

@ -1,81 +0,0 @@
//============================================================================
// 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_CanvasWireframer_h
#define vtk_m_rendering_CanvasWireframer_h
#include <vtkm/rendering/Canvas.h>
#include <vtkm/rendering/vtkm_rendering_export.h>
namespace vtkm
{
namespace rendering
{
class VTKM_RENDERING_EXPORT CanvasWireframer : public Canvas
{
public:
CanvasWireframer(vtkm::Id width = 1024, vtkm::Id height = 1024);
~CanvasWireframer();
void Initialize() VTKM_OVERRIDE;
void Activate() VTKM_OVERRIDE;
void Finish() VTKM_OVERRIDE;
void Clear() VTKM_OVERRIDE;
vtkm::rendering::Canvas* NewCopy() const VTKM_OVERRIDE;
void AddLine(const vtkm::Vec<vtkm::Float64, 2>& start,
const vtkm::Vec<vtkm::Float64, 2>& end,
vtkm::Float32 linewidth,
const vtkm::rendering::Color& color) const VTKM_OVERRIDE;
virtual void AddColorBar(const vtkm::Bounds& bounds,
const vtkm::rendering::ColorTable& colorTable,
bool horizontal) const VTKM_OVERRIDE;
virtual void AddText(const vtkm::Vec<vtkm::Float32, 2>& position,
vtkm::Float32 scale,
vtkm::Float32 angle,
vtkm::Float32 windowAspect,
const vtkm::Vec<vtkm::Float32, 2>& anchor,
const vtkm::rendering::Color& color,
const std::string& text) const VTKM_OVERRIDE;
virtual void AddColorSwatch(const vtkm::Vec<vtkm::Float64, 2>& point0,
const vtkm::Vec<vtkm::Float64, 2>& point1,
const vtkm::Vec<vtkm::Float64, 2>& point2,
const vtkm::Vec<vtkm::Float64, 2>& point3,
const vtkm::rendering::Color& color) const VTKM_OVERRIDE;
private:
vtkm::Id GetBufferIndex(vtkm::Id x, vtkm::Id y) const;
void BlendPixel(vtkm::Float32 x,
vtkm::Float32 y,
const vtkm::rendering::Color& color,
vtkm::Float32 intensity) const;
};
}
} //namespace vtkm::rendering
#endif //vtk_m_rendering_CanvasWireframer_h

@ -105,13 +105,13 @@ private:
ScatterType Scatter;
}; // struct EdgesExtracter
struct ExtractEdgesFunctor
struct ExtractUniqueEdges
{
vtkm::cont::DynamicCellSet CellSet;
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Id, 2>> EdgeIndices;
VTKM_CONT
ExtractEdgesFunctor(const vtkm::cont::DynamicCellSet& cellSet)
ExtractUniqueEdges(const vtkm::cont::DynamicCellSet& cellSet)
: CellSet(cellSet)
{
}
@ -131,7 +131,7 @@ struct ExtractEdgesFunctor
vtkm::cont::DeviceAdapterAlgorithm<DeviceTag>::template Unique<vtkm::Id2>(EdgeIndices);
return true;
}
}; // struct ExtractEdgesFunctor
}; // struct ExtractUniqueEdges
} // namespace
struct MapperWireframer::InternalsType
@ -216,9 +216,9 @@ void MapperWireframer::RenderCells(const vtkm::cont::DynamicCellSet& inCellSet,
}
// Extract unique edges from the cell set.
ExtractEdgesFunctor functor(cellSet);
vtkm::cont::TryExecute(functor);
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Id, 2>> edgeIndices = functor.EdgeIndices;
ExtractUniqueEdges extracter(cellSet);
vtkm::cont::TryExecute(extracter);
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Id, 2>> edgeIndices = extracter.EdgeIndices;
Wireframer renderer(this->Internals->Canvas, this->Internals->ShowInternalZones);
// Render the cell set using a raytracer, on a separate canvas, and use the generated depth

@ -21,6 +21,7 @@
#ifndef vtk_m_rendering_Wireframer_h
#define vtk_m_rendering_Wireframer_h
#include <vtkm/Assert.h>
#include <vtkm/Math.h>
#include <vtkm/Types.h>
#include <vtkm/VectorAnalysis.h>
@ -135,15 +136,14 @@ public:
typedef void ExecutionSignature(_1, _2, _3);
using InputDomain = _1;
vtkm::Vec<vtkm::Float32, 3> Color;
VTKM_CONT
EdgePlotter(const vtkm::Matrix<vtkm::Float32, 4, 4>& worldToProjection,
vtkm::Id width,
vtkm::Id height,
const vtkm::Range& fieldRange,
const ColorMapHandle& colorMap,
const AtomicPackedFrameBufferHandle& frameBuffer)
const AtomicPackedFrameBufferHandle& frameBuffer,
const vtkm::Range& clippingRange)
: WorldToProjection(worldToProjection)
, Width(width)
, Height(height)
@ -153,6 +153,7 @@ public:
, FieldMin(vtkm::Float32(fieldRange.Min))
{
InverseFieldDelta = 1.0f / vtkm::Float32(fieldRange.Length());
Offset = vtkm::Max(0.03f / vtkm::Float32(clippingRange.Length()), 0.000001f);
}
template <typename CoordinatesPortalType, typename ScalarFieldPortalType>
@ -285,7 +286,7 @@ private:
point[2] = point[2] * 0.5f + 0.5f;
// Offset the point to a bit towards the camera. This is to ensure that the front faces of
// the wireframe wins the z-depth check against the surface render.
point[2] -= 0.001f;
point[2] -= Offset;
}
VTKM_EXEC vtkm::Vec<vtkm::Float32, 4> GetColor(vtkm::Float64 fieldValue) const
@ -312,13 +313,14 @@ private:
current.Raw = ClearValue;
next.Floats.Depth = depth;
vtkm::Vec<vtkm::Float32, 3> blendedColor;
vtkm::Vec<vtkm::Float32, 4> srcColor;
vtkm::Vec<vtkm::Float32, 3> srcColor;
do
{
UnpackColor(current.Ints.Color, srcColor[0], srcColor[1], srcColor[2]);
blendedColor[0] = color[0] * intensity + srcColor[0] * (1.0f - intensity);
blendedColor[1] = color[1] * intensity + srcColor[1] * (1.0f - intensity);
blendedColor[2] = color[2] * intensity + srcColor[2] * (1.0f - intensity);
vtkm::Float32 inverseIntensity = (1.0f - intensity);
blendedColor[0] = color[0] * intensity + srcColor[0] * inverseIntensity;
blendedColor[1] = color[1] * intensity + srcColor[1] * inverseIntensity;
blendedColor[2] = color[2] * intensity + srcColor[2] * inverseIntensity;
next.Ints.Color = PackColor(blendedColor[0], blendedColor[1], blendedColor[2]);
current.Raw = FrameBuffer.CompareAndSwap(index, next.Raw, current.Raw);
} while (current.Floats.Depth > next.Floats.Depth);
@ -332,13 +334,17 @@ private:
AtomicPackedFrameBufferHandle FrameBuffer;
vtkm::Float32 FieldMin;
vtkm::Float32 InverseFieldDelta;
vtkm::Float32 Offset;
};
struct BufferConverter : public vtkm::worklet::WorkletMapField
{
public:
VTKM_CONT
BufferConverter() {}
BufferConverter(vtkm::Vec<vtkm::Float32, 4> backgroundColor)
: BackgroundColor(backgroundColor)
{
}
typedef void ControlSignature(FieldIn<>, ExecObject, ExecObject);
typedef void ExecutionSignature(_1, _2, _3, WorkIndex);
@ -362,9 +368,12 @@ public:
}
else
{
colorBuffer.Set(index, vtkm::make_Vec(1.0f, 1.0f, 1.0f, 1.0f));
colorBuffer.Set(index, BackgroundColor);
}
}
private:
vtkm::Vec<vtkm::Float32, 4> BackgroundColor;
};
} // namespace
@ -407,10 +416,6 @@ public:
VTKM_CONT
void Render()
{
WorldToProjection =
vtkm::MatrixMultiply(Camera.CreateProjectionMatrix(Canvas->GetWidth(), Canvas->GetHeight()),
Camera.CreateViewMatrix());
RenderWithDeviceFunctor functor(this);
vtkm::cont::TryExecute(functor);
}
@ -424,33 +429,43 @@ private:
throw vtkm::cont::ErrorBadValue("Field is not associated with points");
}
vtkm::Matrix<vtkm::Float32, 4, 4> WorldToProjection =
vtkm::MatrixMultiply(Camera.CreateProjectionMatrix(Canvas->GetWidth(), Canvas->GetHeight()),
Camera.CreateViewMatrix());
vtkm::Id width = static_cast<vtkm::Id>(Canvas->GetWidth());
vtkm::Id height = static_cast<vtkm::Id>(Canvas->GetHeight());
vtkm::Id pixelCount = width * height;
FrameBuffer.PrepareForOutput(pixelCount, DeviceTag());
vtkm::Vec<vtkm::Float32, 4> clearColor = Canvas->GetBackgroundColor().Components;
vtkm::UInt32 packedClearColor = PackColor(clearColor[0], clearColor[1], clearColor[2]);
if (ShowInternalZones)
{
using MemSet =
typename vtkm::rendering::Triangulator<DeviceTag>::template MemSet<vtkm::Int64>;
MemSet memSet(ClearValue);
vtkm::Int64 clearValue = (static_cast<vtkm::Int64>(0x3F800000) << 32) | packedClearColor;
MemSet memSet(clearValue);
vtkm::worklet::DispatcherMapField<MemSet>(memSet).Invoke(FrameBuffer);
}
else
{
vtkm::Vec<vtkm::Float32, 4> clearColor = Canvas->GetBackgroundColor().Components;
vtkm::UInt32 packedClearColor = PackColor(clearColor[0], clearColor[1], clearColor[2]);
VTKM_ASSERT(SolidDepthBuffer.GetNumberOfValues() == pixelCount);
DepthBufferCopy bufferCopy(packedClearColor);
vtkm::worklet::DispatcherMapField<DepthBufferCopy>(bufferCopy)
.Invoke(SolidDepthBuffer, FrameBuffer);
}
EdgePlotter<DeviceTag> plotter(
WorldToProjection, width, height, ScalarFieldRange, ColorMap, FrameBuffer);
EdgePlotter<DeviceTag> plotter(WorldToProjection,
width,
height,
ScalarFieldRange,
ColorMap,
FrameBuffer,
Camera.GetClippingRange());
vtkm::worklet::DispatcherMapField<EdgePlotter<DeviceTag>, DeviceTag>(plotter).Invoke(
PointIndices, Coordinates, ScalarField.GetData());
BufferConverter converter;
BufferConverter converter(clearColor);
vtkm::worklet::DispatcherMapField<BufferConverter, DeviceTag>(converter).Invoke(
FrameBuffer,
vtkm::exec::ExecutionWholeArray<vtkm::Float32>(Canvas->GetDepthBuffer()),
@ -486,7 +501,6 @@ private:
vtkm::cont::Field ScalarField;
vtkm::Range ScalarFieldRange;
vtkm::cont::ArrayHandle<vtkm::Float32> SolidDepthBuffer;
vtkm::Matrix<vtkm::Float32, 4, 4> WorldToProjection;
PackedFrameBufferHandle FrameBuffer;
}; // class Wireframer
}

@ -20,7 +20,7 @@
#include <vtkm/cont/DeviceAdapter.h>
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/rendering/CanvasWireframer.h>
#include <vtkm/rendering/CanvasRayTracer.h>
#include <vtkm/rendering/MapperWireframer.h>
#include <vtkm/rendering/testing/RenderTest.h>
@ -30,7 +30,7 @@ namespace
void RenderTests()
{
typedef vtkm::rendering::MapperWireframer M;
typedef vtkm::rendering::CanvasWireframer C;
typedef vtkm::rendering::CanvasRayTracer C;
typedef vtkm::rendering::View3D V3;
vtkm::cont::testing::MakeTestDataSet maker;