per_face_normals.cpp 809 B

12345678910111213141516171819202122232425262728293031
  1. #include <test_common.h>
  2. #include <igl/per_face_normals.h>
  3. #include <Eigen/Geometry>
  4. TEST_CASE("per_face_normals: dot", "[igl]")
  5. {
  6. const auto test_case = [](const std::string &param)
  7. {
  8. Eigen::MatrixXd V,N;
  9. Eigen::MatrixXi F;
  10. // Load example mesh: GetParam() will be name of mesh file
  11. test_common::load_mesh(param, V, F);
  12. igl::per_face_normals(V,F,N);
  13. REQUIRE (N.rows() == F.rows());
  14. for(int f = 0;f<N.rows();f++)
  15. {
  16. for(int c = 0;c<3;c++)
  17. {
  18. // Every half-edge dot the normal should be 0
  19. REQUIRE(std::abs((V.row(F(f,c))-V.row(F(f,(c+1)%3))).dot(N.row(f))) < 1e-12);
  20. }
  21. }
  22. // REQUIRE (b == a);
  23. // REQUIRE (a==b);
  24. // ASSERT_NEAR(a,b,1e-15)
  25. // REQUIRE (1e-12 > a);
  26. };
  27. test_common::run_test_cases(test_common::all_meshes(), test_case);
  28. }