Mapper.cxx 1.57 KB
Newer Older
1 2 3 4
//============================================================================
//  Copyright (c) Kitware, Inc.
//  All rights reserved.
//  See LICENSE.txt for details.
5
//
6 7 8 9 10 11 12
//  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>

13 14
#include <vtkm/cont/ColorTable.hxx>

15 16 17 18
namespace vtkm
{
namespace rendering
{
19

20 21 22
Mapper::~Mapper()
{
}
23

24
void Mapper::SetActiveColorTable(const vtkm::cont::ColorTable& colorTable)
25
{
26

27 28 29
  constexpr vtkm::Float32 conversionToFloatSpace = (1.0f / 255.0f);

  vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 4>> temp;
30 31

  {
32
    vtkm::cont::ScopedRuntimeDeviceTracker tracker;
33
    tracker.ForceDevice(vtkm::cont::DeviceAdapterTagSerial());
34 35
    colorTable.Sample(1024, temp);
  }
36 37 38 39 40 41 42 43 44 45 46 47 48

  this->ColorMap.Allocate(1024);
  auto portal = this->ColorMap.GetPortalControl();
  auto colorPortal = temp.GetPortalConstControl();
  for (vtkm::Id i = 0; i < 1024; ++i)
  {
    auto color = colorPortal.Get(i);
    vtkm::Vec<vtkm::Float32, 4> t(color[0] * conversionToFloatSpace,
                                  color[1] * conversionToFloatSpace,
                                  color[2] * conversionToFloatSpace,
                                  color[3] * conversionToFloatSpace);
    portal.Set(i, t);
  }
49
}
50 51 52 53 54 55 56 57 58 59

void Mapper::SetLogarithmX(bool l)
{
  this->LogarithmX = l;
}

void Mapper::SetLogarithmY(bool l)
{
  this->LogarithmY = l;
}
60 61
}
}