main.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include "get_mesh.h"
  2. #include <igl/read_triangle_mesh.h>
  3. #include <igl/opengl/glfw/Viewer.h>
  4. #include <igl/jet.h>
  5. #include <Eigen/Core>
  6. int main(int argc, char * argv[])
  7. {
  8. using namespace Eigen;
  9. using namespace std;
  10. using namespace igl;
  11. cout<<R"(
  12. [,] Toggle between boolean sub-tree operations
  13. )";
  14. MatrixXi FA,FB,FC,FD,FE;
  15. MatrixXd VA,VB,VC,VD,VE;
  16. // Read in inputs as double precision floating point meshes
  17. read_triangle_mesh(TUTORIAL_SHARED_PATH "/cube.obj" ,VA,FA);
  18. read_triangle_mesh(TUTORIAL_SHARED_PATH "/sphere.obj" ,VB,FB);
  19. read_triangle_mesh(TUTORIAL_SHARED_PATH "/xcylinder.obj",VC,FC);
  20. read_triangle_mesh(TUTORIAL_SHARED_PATH "/ycylinder.obj",VD,FD);
  21. read_triangle_mesh(TUTORIAL_SHARED_PATH "/zcylinder.obj",VE,FE);
  22. igl::opengl::glfw::Viewer viewer;
  23. int num_views = 5+4;
  24. int view_id = num_views-1;
  25. const auto & update = [&]()
  26. {
  27. viewer.data().clear();
  28. Eigen::MatrixXd V;
  29. Eigen::MatrixXi F;
  30. Eigen::VectorXd I;
  31. get_mesh(VA,FA,VB,FB,VC,FC,VD,FD,VE,FE,view_id,V,F,I);
  32. viewer.data().set_mesh(V,F);
  33. MatrixXd C;
  34. jet(I,1,5,C);
  35. viewer.data().set_colors(C);
  36. };
  37. update();
  38. viewer.callback_key_down =
  39. [&](igl::opengl::glfw::Viewer &viewer, unsigned char key, int mods)->bool
  40. {
  41. switch(key)
  42. {
  43. case ']':
  44. view_id = (view_id+1)%num_views;
  45. break;
  46. case '[':
  47. view_id = (view_id+num_views-1)%num_views;
  48. break;
  49. default:
  50. return false;
  51. }
  52. update();
  53. return true;
  54. };
  55. viewer.launch();
  56. }