2
0

main.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #include <igl/read_triangle_mesh.h>
  2. #include <igl/loop.h>
  3. #include <igl/upsample.h>
  4. #include <igl/false_barycentric_subdivision.h>
  5. #include <igl/opengl/glfw/Viewer.h>
  6. #include <Eigen/Core>
  7. #include <iostream>
  8. int main(int argc, char * argv[])
  9. {
  10. using namespace std;
  11. using namespace igl;
  12. Eigen::MatrixXi OF,F;
  13. Eigen::MatrixXd OV,V;
  14. bool show_swept_volume = false;
  15. read_triangle_mesh(
  16. TUTORIAL_SHARED_PATH "/decimated-knight.off",OV,OF);
  17. V = OV;
  18. F = OF;
  19. cout<<R"(Usage:
  20. 1 Restore Original mesh
  21. 2 Apply In-plane upsampled mesh
  22. 3 Apply Loop subdivided mesh
  23. 4 Apply False barycentric subdivision
  24. )";
  25. igl::opengl::glfw::Viewer viewer;
  26. viewer.data().set_mesh(V,F);
  27. viewer.data().set_face_based(true);
  28. viewer.callback_key_down =
  29. [&](igl::opengl::glfw::Viewer & viewer, unsigned char key, int mod)->bool
  30. {
  31. switch(key)
  32. {
  33. default:
  34. return false;
  35. case '1':
  36. {
  37. V = OV;
  38. F = OF;
  39. break;
  40. }
  41. case '2':
  42. {
  43. igl::upsample( Eigen::MatrixXd(V), Eigen::MatrixXi(F), V,F);
  44. break;
  45. }
  46. case '3':
  47. {
  48. igl::loop( Eigen::MatrixXd(V), Eigen::MatrixXi(F), V,F);
  49. break;
  50. }
  51. case '4':
  52. {
  53. igl::false_barycentric_subdivision(
  54. Eigen::MatrixXd(V),Eigen::MatrixXi(F),V,F);
  55. break;
  56. }
  57. }
  58. viewer.data().clear();
  59. viewer.data().set_mesh(V,F);
  60. viewer.data().set_face_based(true);
  61. return true;
  62. };
  63. viewer.launch();
  64. }