parula.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 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_PARULA_H
  9. #define IGL_PARULA_H
  10. #include "igl_inline.h"
  11. //#ifndef IGL_NO_EIGEN
  12. # include <Eigen/Dense>
  13. //#endif
  14. namespace igl
  15. {
  16. // PARULA like MATLAB's parula
  17. //
  18. // Inputs:
  19. // m number of colors
  20. // Outputs:
  21. // J m by list of RGB colors between 0 and 1
  22. //
  23. // Wrapper for directly computing [r,g,b] values for a given factor f between
  24. // 0 and 1
  25. //
  26. // Inputs:
  27. // f factor determining color value as if 0 was min and 1 was max
  28. // Outputs:
  29. // r red value
  30. // g green value
  31. // b blue value
  32. template <typename T>
  33. IGL_INLINE void parula(const T f, T * rgb);
  34. template <typename T>
  35. IGL_INLINE void parula(const T f, T & r, T & g, T & b);
  36. // Inputs:
  37. // Z #Z list of factors
  38. // normalize whether to normalize Z to be tightly between [0,1]
  39. // Outputs:
  40. // C #C by 3 list of rgb colors
  41. template <typename DerivedZ, typename DerivedC>
  42. IGL_INLINE void parula(
  43. const Eigen::MatrixBase<DerivedZ> & Z,
  44. const bool normalize,
  45. Eigen::PlainObjectBase<DerivedC> & C);
  46. // Inputs:
  47. // min_Z value at blue
  48. // max_Z value at red
  49. template <typename DerivedZ, typename DerivedC>
  50. IGL_INLINE void parula(
  51. const Eigen::MatrixBase<DerivedZ> & Z,
  52. const double min_Z,
  53. const double max_Z,
  54. Eigen::PlainObjectBase<DerivedC> & C);
  55. };
  56. #ifndef IGL_STATIC_LIBRARY
  57. # include "parula.cpp"
  58. #endif
  59. #endif