GlasbeyLUT.h
Go to the documentation of this file.
1#pragma once
2
3#include <cmath>
4#include <type_traits>
5#include <vector>
6
7#include <SimoxUtility/color/Color.h>
8
9#include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
10
11namespace armarx
12{
13
14 struct DrawColor;
15 struct DrawColor24Bit;
16
17
18 DrawColor toDrawColor(Eigen::Vector4f c);
19 DrawColor toDrawColor(simox::Color c);
20 DrawColor24Bit toDrawColor24Bit(simox::Color c);
21
22 /**
23 * "Color lookup table consisting of 256 colors structured in a maximally
24 * discontinuous manner. Generated using the method of Glasbey et al.
25 * (see https://github.com/taketwo/glasbey)" [1]
26 *
27 *
28 * [1](https://github.com/PointCloudLibrary/pcl/blob/master/common/include/pcl/common/colors.h)
29 */
30 class GlasbeyLUT
31 {
32 public:
33 static DrawColor at(std::size_t id, float alpha = 1.f);
34 static DrawColor24Bit atByte(std::size_t id);
35
36 /**
37 * @brief Get a color from the lookup table with given ID (with float values).
38 * The ID is automaticall wrapped if greater than `size()`.
39 * If `id` is negative, its absolute value is used.
40 */
41 template <typename UIntT, std::enable_if_t<std::is_unsigned<UIntT>::value, int> = 0>
42 static DrawColor
43 at(UIntT id, float alpha = 1.f)
44 {
45 return at(static_cast<std::size_t>(id), alpha);
46 }
47
48 // If `id` is negative, its absolute value is used.
49 template <typename IntT, std::enable_if_t<std::is_signed<IntT>::value, int> = 0>
50 static DrawColor
51 at(IntT id, float alpha = 1.f)
52 {
53 return at(static_cast<std::size_t>(id >= 0 ? id : std::abs(id)), alpha);
54 }
55
56 /**
57 * @brief Get a color from the lookup table with given ID (with integer values).
58 * The ID is automaticall wrapped if greater than `size()`.
59 * If `id` is negative, its absolute value is used.
60 */
61 template <typename UIntT, std::enable_if_t<std::is_unsigned<UIntT>::value, int> = 0>
62 static DrawColor24Bit
63 atByte(UIntT id)
64 {
65 return atByte(static_cast<std::size_t>(id));
66 }
67
68 template <typename IntT, std::enable_if_t<std::is_signed<IntT>::value, int> = 0>
69 static DrawColor24Bit
70 atByte(IntT id)
71 {
72 return atByte(static_cast<std::size_t>(id >= 0 ? id : std::abs(id)));
73 }
74
75 /// Get the number of colors in the lookup table.;
76 static std::size_t size();
77
78 /// Get the raw lookup table (flat).
79 static const std::vector<unsigned char>& data();
80
81
82 private:
83 /// Private constructor.
84 GlasbeyLUT() = default;
85 };
86
87} // namespace armarx
constexpr T c
"Color lookup table consisting of 256 colors structured in a maximally discontinuous manner.
Definition GlasbeyLUT.h:31
static DrawColor at(IntT id, float alpha=1.f)
Definition GlasbeyLUT.h:51
static DrawColor at(std::size_t id, float alpha=1.f)
static DrawColor24Bit atByte(UIntT id)
Get a color from the lookup table with given ID (with integer values).
Definition GlasbeyLUT.h:63
static DrawColor24Bit atByte(std::size_t id)
static const std::vector< unsigned char > & data()
Get the raw lookup table (flat).
static std::size_t size()
Get the number of colors in the lookup table.;.
static DrawColor24Bit atByte(IntT id)
Definition GlasbeyLUT.h:70
static DrawColor at(UIntT id, float alpha=1.f)
Get a color from the lookup table with given ID (with float values).
Definition GlasbeyLUT.h:43
This file offers overloads of toIce() and fromIce() functions for STL container types.
DrawColor toDrawColor(Eigen::Vector4f c)
Definition GlasbeyLUT.cpp:6
DrawColor24Bit toDrawColor24Bit(simox::Color c)