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 
11 namespace 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  */
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.
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  */
62  static DrawColor24Bit
63  atByte(UIntT id)
64  {
65  return atByte(static_cast<std::size_t>(id));
66  }
67 
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
armarx::GlasbeyLUT::atByte
static DrawColor24Bit atByte(std::size_t id)
Definition: GlasbeyLUT.cpp:33
armarx::GlasbeyLUT::size
static std::size_t size()
Get the number of colors in the lookup table.;.
Definition: GlasbeyLUT.cpp:39
armarx::toDrawColor
DrawColor toDrawColor(Eigen::Vector4f c)
Definition: GlasbeyLUT.cpp:6
armarx::GlasbeyLUT
"Color lookup table consisting of 256 colors structured in a maximally discontinuous manner.
Definition: GlasbeyLUT.h:30
armarx::GlasbeyLUT::at
static DrawColor at(std::size_t id, float alpha=1.f)
Definition: GlasbeyLUT.cpp:27
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
armarx::GlasbeyLUT::at
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
Color
uint32_t Color
RGBA color.
Definition: color.h:8
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:855
armarx::abs
std::vector< T > abs(const std::vector< T > &v)
Definition: VectorHelpers.h:281
armarx::GlasbeyLUT::atByte
static DrawColor24Bit atByte(UIntT id)
Get a color from the lookup table with given ID (with integer values).
Definition: GlasbeyLUT.h:63
armarx::GlasbeyLUT::data
static const std::vector< unsigned char > & data()
Get the raw lookup table (flat).
Definition: GlasbeyLUT.cpp:45
armarx::GlasbeyLUT::at
static DrawColor at(IntT id, float alpha=1.f)
Definition: GlasbeyLUT.h:51
armarx::toDrawColor24Bit
DrawColor24Bit toDrawColor24Bit(simox::Color c)
Definition: GlasbeyLUT.cpp:18
armarx::GlasbeyLUT::atByte
static DrawColor24Bit atByte(IntT id)
Definition: GlasbeyLUT.h:70
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27