Răsfoiți Sursa

viewer can take scalar field in set_colors

Former-commit-id: 5708777f65be0a768ec9bdaa58e20453e53ec933
Alec Jacobson 9 ani în urmă
părinte
comite
9244818d30
1 a modificat fișierele cu 7 adăugiri și 0 ștergeri
  1. 7 0
      include/igl/viewer/ViewerData.cpp

+ 7 - 0
include/igl/viewer/ViewerData.cpp

@@ -12,6 +12,7 @@
 
 #include <igl/per_face_normals.h>
 #include <igl/material_colors.h>
+#include <igl/parula.h>
 #include <igl/per_vertex_normals.h>
 
 #ifdef ENABLE_SERIALIZATION
@@ -154,6 +155,12 @@ IGL_INLINE void igl::viewer::ViewerData::set_colors(const Eigen::MatrixXd &C)
 {
   using namespace std;
   using namespace Eigen;
+  if(C.rows()>0 && C.cols() == 1)
+  {
+    Eigen::MatrixXd C3;
+    igl::parula(C,true,C3);
+    return set_colors(C3);
+  }
   // Ambient color should be darker color
   const auto ambient = [](const MatrixXd & C)->MatrixXd
   {