colormap.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2017 Joe Graus <jgraus@gmu.edu>, Alec Jacobson <alecjacobson@gmail.com>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_COLORMAP_H
  9. #define IGL_COLORMAP_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Dense>
  12. namespace igl {
  13. enum ColorMapType
  14. {
  15. COLOR_MAP_TYPE_INFERNO = 0,
  16. COLOR_MAP_TYPE_JET = 1,
  17. COLOR_MAP_TYPE_MAGMA = 2,
  18. COLOR_MAP_TYPE_PARULA = 3,
  19. COLOR_MAP_TYPE_PLASMA = 4,
  20. COLOR_MAP_TYPE_VIRIDIS = 5,
  21. NUM_COLOR_MAP_TYPES = 6
  22. };
  23. // Comput [r,g,b] values of the selected colormap for
  24. // a given factor f between 0 and 1
  25. //
  26. // Inputs:
  27. // c colormap enum
  28. // f factor determining color value as if 0 was min and 1 was max
  29. // Outputs:
  30. // rgb red, green, blue value
  31. template <typename T>
  32. IGL_INLINE void colormap(const ColorMapType cm, const T f, T * rgb);
  33. // Outputs:
  34. // r red value
  35. // g green value
  36. // b blue value
  37. template <typename T>
  38. IGL_INLINE void colormap(const ColorMapType cm, const T f, T & r, T & g, T & b);
  39. // Inputs:
  40. // palette 256 by 3 array of color values
  41. template <typename T>
  42. IGL_INLINE void colormap(
  43. const double palette[256][3], const T x_in, T & r, T & g, T & b);
  44. // Inputs:
  45. // cm selected colormap palette to interpolate from
  46. // Z #Z list of factors
  47. // normalize whether to normalize Z to be tightly between [0,1]
  48. // Outputs:
  49. // C #C by 3 list of rgb colors
  50. template <typename DerivedZ, typename DerivedC>
  51. IGL_INLINE void colormap(
  52. const ColorMapType cm,
  53. const Eigen::MatrixBase<DerivedZ> & Z,
  54. const bool normalize,
  55. Eigen::PlainObjectBase<DerivedC> & C);
  56. // Inputs:
  57. // min_z value at "0"
  58. // max_z value at "1"
  59. template <typename DerivedZ, typename DerivedC>
  60. IGL_INLINE void colormap(
  61. const ColorMapType cm,
  62. const Eigen::MatrixBase<DerivedZ> & Z,
  63. const double min_Z,
  64. const double max_Z,
  65. Eigen::PlainObjectBase<DerivedC> & C);
  66. };
  67. #ifndef IGL_STATIC_LIBRARY
  68. # include "colormap.cpp"
  69. #endif
  70. #endif