upsample.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include <test_common.h>
  2. #include <igl/upsample.h>
  3. // class upsample : public ::testing::TestWithParam<std::string> {};
  4. TEST_CASE("upsample: single_triangle", "[igl]")
  5. {
  6. Eigen::MatrixXi NF_groundtruth(4,3);
  7. NF_groundtruth << 0,3,5 ,1,4,3 ,3,4,5 ,4,2,5;
  8. Eigen::MatrixXd NV_groundtruth(6,2);
  9. NV_groundtruth <<0,0 ,1,0 ,0,1 ,0.5,0 ,0.5,0.5 ,0,0.5;
  10. Eigen::MatrixXd S_groundtruth(6,3);
  11. S_groundtruth<<1,0,0 ,0,1,0 ,0,0,1 ,0.5,0.5,0 ,0,0.5,0.5 ,0.5,0,0.5;
  12. Eigen::MatrixXi F(1,3);
  13. F<<0,1,2;
  14. Eigen::MatrixXd V(3,2);
  15. V<<0,0,1,0,0,1;
  16. Eigen::MatrixXi NF;
  17. Eigen::MatrixXd NV;
  18. Eigen::SparseMatrix<double> S;
  19. igl::upsample(V.rows(),F,S,NF);
  20. test_common::assert_eq(NF_groundtruth,NF);
  21. test_common::assert_eq(S_groundtruth,Eigen::MatrixXd(S));
  22. igl::upsample(V,F,NV,NF);
  23. test_common::assert_eq(NF_groundtruth,NF);
  24. test_common::assert_eq(NV_groundtruth,NV);
  25. }
  26. // TEST_P(upsample, V_comes_first_F_ordering)
  27. // {
  28. // Eigen::MatrixXd V,NV;
  29. // Eigen::MatrixXi F,NF;
  30. // // Load example mesh: GetParam() will be name of mesh file
  31. // test_common::load_mesh(GetParam(), V, F);
  32. // igl::upsample(V,F,NV,NF);
  33. // REQUIRE (V.rows() <= NV.rows());
  34. // REQUIRE (4*F.rows() == NF.rows());
  35. // // V should be first part of V
  36. // test_common::assert_eq(V,NV.topLeftCorner(V.rows(),V.cols()));
  37. // // Expect a particular order
  38. // for(int f = 0;f<F.rows();f++)
  39. // {
  40. // REQUIRE (NF((f*4)+0,0) == F(f,0));
  41. // REQUIRE (NF((f*4)+1,0) == F(f,1));
  42. // REQUIRE (NF((f*4)+3,1) == F(f,2));
  43. // }
  44. // }
  45. // INSTANTIATE_TEST_CASE_P
  46. // (
  47. // manifold_meshes,
  48. // upsample,
  49. // ::testing::ValuesIn(test_common::manifold_meshes()),
  50. // test_common::string_test_name
  51. // );