vtk-m/vtkm/rendering/Mapper.cxx

57 lines
1.4 KiB
C++
Raw Normal View History

//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
2019-04-15 23:24:21 +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/Mapper.h>
2017-05-18 14:29:41 +00:00
namespace vtkm
{
namespace rendering
{
Mapper::~Mapper() {}
void Mapper::SetActiveColorTable(const vtkm::cont::ColorTable& colorTable)
{
constexpr vtkm::Float32 conversionToFloatSpace = (1.0f / 255.0f);
vtkm::cont::ArrayHandle<vtkm::Vec4ui_8> temp;
{
vtkm::cont::ScopedRuntimeDeviceTracker tracker(vtkm::cont::DeviceAdapterTagSerial{});
colorTable.Sample(1024, temp);
}
this->ColorMap.Allocate(1024);
auto portal = this->ColorMap.WritePortal();
auto colorPortal = temp.ReadPortal();
for (vtkm::Id i = 0; i < 1024; ++i)
{
auto color = colorPortal.Get(i);
vtkm::Vec4f_32 t(color[0] * conversionToFloatSpace,
color[1] * conversionToFloatSpace,
color[2] * conversionToFloatSpace,
color[3] * conversionToFloatSpace);
portal.Set(i, t);
}
}
void Mapper::SetLogarithmX(bool l)
{
this->LogarithmX = l;
}
void Mapper::SetLogarithmY(bool l)
{
this->LogarithmY = l;
}
}
}