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 <RobotAPI/interface/visualization/DebugDrawerInterface.h>
8 
9 #include <SimoxUtility/color/Color.h>
10 
11 
12 namespace armarx
13 {
14 
15  struct DrawColor;
16  struct DrawColor24Bit;
17 
18 
19  DrawColor toDrawColor(Eigen::Vector4f c);
20  DrawColor toDrawColor(simox::Color c);
21  DrawColor24Bit toDrawColor24Bit(simox::Color c);
22 
23 
24  /**
25  * "Color lookup table consisting of 256 colors structured in a maximally
26  * discontinuous manner. Generated using the method of Glasbey et al.
27  * (see https://github.com/taketwo/glasbey)" [1]
28  *
29  *
30  * [1](https://github.com/PointCloudLibrary/pcl/blob/master/common/include/pcl/common/colors.h)
31  */
32  class GlasbeyLUT
33  {
34  public:
35 
36  static DrawColor at(std::size_t id, float alpha = 1.f);
37  static DrawColor24Bit atByte(std::size_t id);
38 
39  /**
40  * @brief Get a color from the lookup table with given ID (with float values).
41  * The ID is automaticall wrapped if greater than `size()`.
42  * If `id` is negative, its absolute value is used.
43  */
45  static DrawColor at(UIntT id, float alpha = 1.f)
46  {
47  return at(static_cast<std::size_t>(id), alpha);
48  }
49 
50  // If `id` is negative, its absolute value is used.
52  static DrawColor at(IntT id, float alpha = 1.f)
53  {
54  return at(static_cast<std::size_t>(id >= 0 ? id : std::abs(id)), alpha);
55  }
56 
57 
58  /**
59  * @brief Get a color from the lookup table with given ID (with integer values).
60  * The ID is automaticall wrapped if greater than `size()`.
61  * If `id` is negative, its absolute value is used.
62  */
64  static DrawColor24Bit atByte(UIntT id)
65  {
66  return atByte(static_cast<std::size_t>(id));
67  }
68 
70  static DrawColor24Bit atByte(IntT id)
71  {
72  return atByte(static_cast<std::size_t>(id >= 0 ? id : std::abs(id)));
73  }
74 
75 
76  /// Get the number of colors in the lookup table.;
77  static std::size_t size();
78 
79  /// Get the raw lookup table (flat).
80  static const std::vector<unsigned char>& data();
81 
82 
83  private:
84 
85  /// Private constructor.
86  GlasbeyLUT() = default;
87 
88  };
89 
90 }
armarx::GlasbeyLUT::atByte
static DrawColor24Bit atByte(std::size_t id)
Definition: GlasbeyLUT.cpp:30
armarx::GlasbeyLUT::size
static std::size_t size()
Get the number of colors in the lookup table.;.
Definition: GlasbeyLUT.cpp:36
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:32
armarx::GlasbeyLUT::at
static DrawColor at(std::size_t id, float alpha=1.f)
Definition: GlasbeyLUT.cpp:25
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
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:45
Color
uint32_t Color
RGBA color.
Definition: color.h:8
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
armarx::abs
std::vector< T > abs(const std::vector< T > &v)
Definition: VectorHelpers.h:253
armarx::GlasbeyLUT::atByte
static DrawColor24Bit atByte(UIntT id)
Get a color from the lookup table with given ID (with integer values).
Definition: GlasbeyLUT.h:64
armarx::GlasbeyLUT::data
static const std::vector< unsigned char > & data()
Get the raw lookup table (flat).
Definition: GlasbeyLUT.cpp:41
armarx::GlasbeyLUT::at
static DrawColor at(IntT id, float alpha=1.f)
Definition: GlasbeyLUT.h:52
armarx::toDrawColor24Bit
DrawColor24Bit toDrawColor24Bit(simox::Color c)
Definition: GlasbeyLUT.cpp:16
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:28