polygon_corners.cpp 1.0 KB

12345678910111213141516171819202122232425262728
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2020 Alec Jacobson <[email protected]>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #include <test_common.h>
  9. #include <igl/polygon_corners.h>
  10. #include <igl/matrix_to_list.h>
  11. #include <igl/matlab_format.h>
  12. #include <iostream>
  13. TEST_CASE("polygon_corners: quads", "[igl]")
  14. {
  15. const Eigen::MatrixXi Q = (Eigen::MatrixXi(2,4)<< 0,1,2,3, 1,4,5,2).finished();
  16. std::vector<std::vector<int>> vQ;
  17. igl::matrix_to_list(Q,vQ);
  18. const Eigen::VectorXi Iexact = (Eigen::VectorXi(8)<<0,1,2,3,1,4,5,2).finished();
  19. const Eigen::VectorXi Cexact = (Eigen::VectorXi(3)<<0,4,8).finished();
  20. Eigen::VectorXi I,C;
  21. igl::polygon_corners(vQ,I,C);
  22. test_common::assert_eq(I,Iexact);
  23. test_common::assert_eq(C,Cexact);
  24. igl::polygon_corners( Q,I,C);
  25. test_common::assert_eq(I,Iexact);
  26. test_common::assert_eq(C,Cexact);
  27. }