iMSTK
Interactive Medical Simulation Toolkit
imstkColorFunction.h
1 /*
2 ** This file is part of the Interactive Medical Simulation Toolkit (iMSTK)
3 ** iMSTK is distributed under the Apache License, Version 2.0.
4 ** See accompanying NOTICE for details.
5 */
6 
7 #pragma once
8 
9 #include "imstkColor.h"
10 #include "imstkMath.h"
11 
12 #include <vector>
13 
14 namespace imstk
15 {
23 {
24 public:
25  enum class ColorSpace
26  {
27  RGB,
28  DIVERING,
29  HSV,
30  LAB
31  };
32 
33 public:
34  ColorFunction() = default;
35  virtual ~ColorFunction() = default;
36 
37 public:
38  int getNumberOfColors() const { return static_cast<int>(m_table.size()); }
39  const Color& getColor(int i) const { return m_table[i]; }
40  const Vec2d& getRange() const { return m_range; }
41  const ColorSpace& getColorSpace() const { return m_colorSpace; }
42 
43  void setNumberOfColors(int numColors) { m_table.resize(numColors); }
44  void setColor(int i, const Color& color) { m_table[i] = color; }
45  void setRange(double min, double max) { setRange(Vec2d(min, max)); }
46  void setRange(const Vec2d& range) { this->m_range = range; }
47  void setColorSpace(const ColorSpace& space) { this->m_colorSpace = space; }
48 
52  void clear() { m_table.clear(); }
53 
54 protected:
55  std::vector<Color> m_table;
56  Vec2d m_range;
57  ColorSpace m_colorSpace;
58 };
59 } // namespace imstk
Compound Geometry.
A regularly/structured table of colors to lookup by value.
void clear()
Clears all colors from the lookup table.
Color in RGB space.
Definition: imstkColor.h:24