path_to_edges.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include <test_common.h>
  2. #include <igl/path_to_edges.h>
  3. #include <vector>
  4. TEST_CASE("igl_path_to_edges: basic_test", "[igl]")
  5. {
  6. const Eigen::VectorXi I = (Eigen::VectorXi(6)<<0,1,2,3,4,5).finished();
  7. const Eigen::MatrixXi Eexpected = (Eigen::MatrixXi(5,2)<<0,1, 1,2, 2,3, 3,4, 4,5).finished();
  8. Eigen::MatrixXi Eactual;
  9. igl::path_to_edges(I, Eactual);
  10. test_common::assert_eq(Eactual, Eexpected);
  11. }
  12. #include <iostream>
  13. TEST_CASE("igl_path_to_edges: loop_test", "[igl]")
  14. {
  15. const Eigen::VectorXi I = (Eigen::VectorXi(6)<<0,1,2,3,4,5).finished();
  16. const Eigen::MatrixXi Eexpected = (Eigen::MatrixXi(6,2)<<0,1, 1,2, 2,3, 3,4, 4,5, 5,0).finished();
  17. Eigen::MatrixXi Eactual;
  18. const bool make_loop = true;
  19. igl::path_to_edges(I, Eactual, make_loop);
  20. std::cout << Eactual << std::endl;
  21. test_common::assert_eq(Eactual, Eexpected);
  22. }
  23. TEST_CASE("igl_path_to_edges: vector_basic_test", "[igl]")
  24. {
  25. const std::vector<int> I{0,1,2,3,4,5};
  26. const Eigen::MatrixXi Eexpected = (Eigen::MatrixXi(5,2)<<0,1, 1,2, 2,3, 3,4, 4,5).finished();
  27. Eigen::MatrixXi Eactual;
  28. igl::path_to_edges(I, Eactual);
  29. test_common::assert_eq(Eactual, Eexpected);
  30. }
  31. TEST_CASE("igl_path_to_edges: vector_loop_test", "[igl]")
  32. {
  33. const std::vector<int> I{0,1,2,3,4,5};
  34. const Eigen::MatrixXi Eexpected = (Eigen::MatrixXi(6,2)<<0,1, 1,2, 2,3, 3,4, 4,5, 5,0).finished();
  35. Eigen::MatrixXi Eactual;
  36. const bool make_loop = true;
  37. igl::path_to_edges(I, Eactual, make_loop);
  38. test_common::assert_eq(Eactual, Eexpected);
  39. }