mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
Virtual methods are being deprecated, so remove their use from the ColorTable classes. Instead of using a virtual method to look up a value in the ColorTable, we essentially use a switch statement. This change also simplified the code quite a bit. The execution object used to use pointers to handle the virtual objects. That is no longer necessary, so a simple `vtkm::exec::ColorTable` is returned for execution objects. (Note that this `ColorTable` contains pointers that are specific for the particular device.) This is a non- backward compabible change. However, the only place (outside of the `ColorTable` implementation itself) was a single worklet for converting scalars to colors (`vtkm::worklet::colorconversion::TransferFunction`). This is unlikely to affect anyone. I also "fixed" some names in enum structs. There has been some inconsistencies in VTK-m on whether items in an enum struct are capitolized or camel case. We seem to moving toward camel case, so deprecate some old names.
135 lines
4.3 KiB
C++
135 lines
4.3 KiB
C++
//============================================================================
|
|
// 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.
|
|
//============================================================================
|
|
#ifndef vtk_m_exec_ColorTable_h
|
|
#define vtk_m_exec_ColorTable_h
|
|
|
|
#include <vtkm/Deprecated.h>
|
|
#include <vtkm/Types.h>
|
|
|
|
namespace vtkm
|
|
{
|
|
|
|
enum struct ColorSpace
|
|
{
|
|
RGB,
|
|
HSV,
|
|
HSVWrap,
|
|
Lab,
|
|
Diverging
|
|
};
|
|
|
|
} // namespace vtkm
|
|
|
|
namespace vtkm
|
|
{
|
|
namespace exec
|
|
{
|
|
|
|
class VTKM_ALWAYS_EXPORT ColorTable
|
|
{
|
|
public:
|
|
inline VTKM_EXEC vtkm::Vec3f_32 MapThroughColorSpace(vtkm::Float64) const;
|
|
|
|
inline VTKM_EXEC vtkm::Vec3f_32 MapThroughColorSpace(const vtkm::Vec3f_32& rgb1,
|
|
const vtkm::Vec3f_32& rgb2,
|
|
vtkm::Float32 weight) const;
|
|
|
|
inline VTKM_EXEC vtkm::Float32 MapThroughOpacitySpace(vtkm::Float64 value) const;
|
|
|
|
vtkm::ColorSpace Space;
|
|
|
|
vtkm::Float64 const* ColorNodes = nullptr;
|
|
vtkm::Vec3f_32 const* RGB = nullptr;
|
|
|
|
vtkm::Float64 const* ONodes = nullptr;
|
|
vtkm::Float32 const* Alpha = nullptr;
|
|
vtkm::Vec2f_32 const* MidSharp = nullptr;
|
|
|
|
vtkm::Int32 ColorSize = 0;
|
|
vtkm::Int32 OpacitySize = 0;
|
|
|
|
vtkm::Vec3f_32 NaNColor = { 0.5f, 0.0f, 0.0f };
|
|
vtkm::Vec3f_32 BelowRangeColor = { 0.0f, 0.0f, 0.0f };
|
|
vtkm::Vec3f_32 AboveRangeColor = { 0.0f, 0.0f, 0.0f };
|
|
|
|
bool UseClamping = true;
|
|
|
|
private:
|
|
inline VTKM_EXEC void FindColors(vtkm::Float64 value,
|
|
vtkm::Vec3f_32& first,
|
|
vtkm::Vec3f_32& second,
|
|
vtkm::Float32& weight) const;
|
|
|
|
inline VTKM_EXEC vtkm::Vec3f_32 MapThroughColorSpaceRGB(const vtkm::Vec3f_32& rgb1,
|
|
const vtkm::Vec3f_32& rgb2,
|
|
vtkm::Float32 weight) const;
|
|
|
|
inline VTKM_EXEC vtkm::Vec3f_32 MapThroughColorSpaceHSV(const vtkm::Vec3f_32& rgb1,
|
|
const vtkm::Vec3f_32& rgb2,
|
|
vtkm::Float32 weight) const;
|
|
|
|
inline VTKM_EXEC vtkm::Vec3f_32 MapThroughColorSpaceHSVWrap(const vtkm::Vec3f_32& rgb1,
|
|
const vtkm::Vec3f_32& rgb2,
|
|
vtkm::Float32 weight) const;
|
|
|
|
inline VTKM_EXEC vtkm::Vec3f_32 MapThroughColorSpaceLab(const vtkm::Vec3f_32& rgb1,
|
|
const vtkm::Vec3f_32& rgb2,
|
|
vtkm::Float32 weight) const;
|
|
|
|
inline VTKM_EXEC vtkm::Vec3f_32 MapThroughColorSpaceDiverging(const vtkm::Vec3f_32& rgb1,
|
|
const vtkm::Vec3f_32& rgb2,
|
|
vtkm::Float32 weight) const;
|
|
};
|
|
|
|
class VTKM_ALWAYS_EXPORT VTKM_DEPRECATED(1.6, "Use vtkm::exec::ColorTable.") ColorTableBase
|
|
: public vtkm::exec::ColorTable
|
|
{
|
|
};
|
|
|
|
class VTKM_ALWAYS_EXPORT VTKM_DEPRECATED(1.6, "Use vtkm::exec::ColorTable.") ColorTableRGB final
|
|
: public ColorTable
|
|
{
|
|
public:
|
|
ColorTableRGB() { this->Space = vtkm::ColorSpace::RGB; }
|
|
};
|
|
|
|
class VTKM_ALWAYS_EXPORT VTKM_DEPRECATED(1.6, "Use vtkm::exec::ColorTable.") ColorTableHSV final
|
|
: public ColorTable
|
|
{
|
|
public:
|
|
ColorTableHSV() { this->Space = vtkm::ColorSpace::HSV; }
|
|
};
|
|
|
|
class VTKM_ALWAYS_EXPORT VTKM_DEPRECATED(1.6, "Use vtkm::exec::ColorTable.") ColorTableHSVWrap final
|
|
: public ColorTable
|
|
{
|
|
public:
|
|
ColorTableHSVWrap() { this->Space = vtkm::ColorSpace::HSVWrap; }
|
|
};
|
|
|
|
class VTKM_ALWAYS_EXPORT VTKM_DEPRECATED(1.6, "Use vtkm::exec::ColorTable.") ColorTableLab final
|
|
: public ColorTable
|
|
{
|
|
public:
|
|
ColorTableLab() { this->Space = vtkm::ColorSpace::Lab; }
|
|
};
|
|
|
|
class VTKM_ALWAYS_EXPORT ColorTableDiverging final : public ColorTable
|
|
{
|
|
public:
|
|
ColorTableDiverging() { this->Space = vtkm::ColorSpace::Diverging; }
|
|
};
|
|
}
|
|
}
|
|
|
|
#include <vtkm/exec/ColorTable.hxx>
|
|
|
|
#endif
|