per_face_normals.cpp 886 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include <test_common.h>
  2. #include <igl/per_face_normals.h>
  3. #include <Eigen/Geometry>
  4. class per_face_normals : public ::testing::TestWithParam<std::string> {};
  5. TEST_P(per_face_normals, dot)
  6. {
  7. Eigen::MatrixXd V,N;
  8. Eigen::MatrixXi F;
  9. // Load example mesh: GetParam() will be name of mesh file
  10. test_common::load_mesh(GetParam(), V, F);
  11. igl::per_face_normals(V,F,N);
  12. ASSERT_EQ(F.rows(),N.rows());
  13. for(int f = 0;f<N.rows();f++)
  14. {
  15. for(int c = 0;c<3;c++)
  16. {
  17. // Every half-edge dot the normal should be 0
  18. ASSERT_LT(
  19. std::abs((V.row(F(f,c))-V.row(F(f,(c+1)%3))).dot(N.row(f))),
  20. 1e-12);
  21. }
  22. }
  23. // ASSERT_EQ(a,b);
  24. // ASSERT_TRUE(a==b);
  25. // ASSERT_NEAR(a,b,1e-15)
  26. // ASSERT_LT(a,1e-12);
  27. }
  28. INSTANTIATE_TEST_CASE_P
  29. (
  30. all_meshes,
  31. per_face_normals,
  32. ::testing::ValuesIn(test_common::all_meshes()),
  33. test_common::string_test_name
  34. );