main.cpp 748 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include <igl/viewer/Viewer.h>
  2. #include <igl/triangle/triangulate.h>
  3. // Input polygon
  4. Eigen::MatrixXd V;
  5. Eigen::MatrixXi E;
  6. Eigen::MatrixXd H;
  7. // Triangulated interior
  8. Eigen::MatrixXd V2;
  9. Eigen::MatrixXi F2;
  10. int main(int argc, char *argv[])
  11. {
  12. using namespace Eigen;
  13. using namespace std;
  14. // Create the boundary of a square
  15. V.resize(8,2);
  16. E.resize(8,2);
  17. H.resize(1,2);
  18. V << -1,-1, 1,-1, 1,1, -1, 1,
  19. -2,-2, 2,-2, 2,2, -2, 2;
  20. E << 0,1, 1,2, 2,3, 3,0,
  21. 4,5, 5,6, 6,7, 7,4;
  22. H << 0,0;
  23. // Triangulate the interior
  24. igl::triangle::triangulate(V,E,H,"a0.005q",V2,F2);
  25. // Plot the generated mesh
  26. igl::viewer::Viewer viewer;
  27. viewer.data.set_mesh(V2,F2);
  28. viewer.launch();
  29. }