main.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #include <igl/readOFF.h>
  2. #include <igl/viewer/Viewer.h>
  3. #include <igl/per_vertex_normals.h>
  4. #include <igl/per_face_normals.h>
  5. #include <igl/per_corner_normals.h>
  6. #include <igl/avg_edge_length.h>
  7. #include <igl/barycenter.h>
  8. #include <igl/principal_curvature.h>
  9. Eigen::MatrixXd V;
  10. Eigen::MatrixXi F;
  11. int main(int argc, char *argv[])
  12. {
  13. // Load a mesh in OFF format
  14. igl::readOFF("../shared/fertility.off", V, F);
  15. // Compute curvature directions via quadric fitting
  16. Eigen::MatrixXd PD1,PD2,PV1,PV2;
  17. igl::principal_curvature(V,F,PD1,PD2,PV1,PV2);
  18. // Plot the mesh
  19. igl::Viewer viewer;
  20. viewer.set_mesh(V, F);
  21. // Find the average edge length
  22. double avg = igl::avg_edge_length(V,F);
  23. // Draw a red segment on each vertex parallel to the minimal curvature direction
  24. viewer.add_edges(V + PD1*avg, V - PD1*avg, Eigen::RowVector3d(0,0,1));
  25. // Draw a blue segment on each vertex parallel to the maximal curvature direction
  26. viewer.add_edges(V + PD2*avg, V - PD2*avg, Eigen::RowVector3d(1,0,0));
  27. // Launch the viewer
  28. viewer.launch();
  29. }