boundary_loop.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include <test_common.h>
  2. #include <igl/boundary_loop.h>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <iostream>
  6. TEST_CASE("boundary_loop: cube", "[igl]")
  7. {
  8. Eigen::MatrixXd V;
  9. Eigen::MatrixXi F;
  10. //This is a cube of dimensions 1.0x1.0x1.0
  11. test_common::load_mesh("cube.off", V, F);
  12. //Compute Boundary Loop
  13. Eigen::VectorXi boundary;
  14. igl::boundary_loop(F, boundary);
  15. //The cube has no boundary
  16. REQUIRE (boundary.size() == 0);
  17. }
  18. TEST_CASE("boundary_loop: bunny", "[igl]")
  19. {
  20. Eigen::MatrixXd V;
  21. Eigen::MatrixXi F;
  22. //Load the Stanford bunny
  23. test_common::load_mesh("bunny.off", V, F);
  24. //Compute list of ordered boundary loops for a manifold mesh
  25. std::vector<std::vector<int> >boundaries;
  26. igl::boundary_loop(F, boundaries);
  27. //Compare our result with known results taken from meshlab
  28. REQUIRE (boundaries.size() == 5);
  29. //Compute min, max and sum of boundaries
  30. size_t boundaryMin=9999999;
  31. size_t boundaryMax=0;
  32. size_t boundarySum=0;
  33. for(size_t i=0; i<boundaries.size(); i++)
  34. {
  35. boundarySum += boundaries[i].size();
  36. boundaryMax = std::max(boundaryMax, boundaries[i].size());
  37. boundaryMin = std::min(boundaryMin, boundaries[i].size());
  38. }
  39. //Total boundary has 223 vertex
  40. REQUIRE (boundarySum == 223);
  41. //Largest loop has 80 vertex
  42. REQUIRE (boundaryMax == 80);
  43. //Smallest loop has 22 vertex
  44. REQUIRE (boundaryMin == 22);
  45. }