blue_noise.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2018 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/barycentric_interpolation.h>
  10. #include <igl/readOBJ.h>
  11. #include <igl/blue_noise.h>
  12. #include <igl/knn.h>
  13. #include <igl/octree.h>
  14. #include <igl/slice.h>
  15. TEST_CASE("blue_noise: decimated-knight", "[igl]")
  16. {
  17. Eigen::MatrixXd V;
  18. Eigen::MatrixXi F;
  19. igl::readOBJ(test_common::data_path("decimated-knight.obj"),V,F);
  20. const double r = 0.01;
  21. Eigen::MatrixXd B,P;
  22. {
  23. Eigen::VectorXi I;
  24. igl::blue_noise(V,F,r,B,I,P);
  25. }
  26. // There should be ~4000 samples on this model
  27. REQUIRE(P.rows() > 3000);
  28. std::vector<std::vector<int> > point_indices;
  29. Eigen::MatrixXi CH;
  30. Eigen::MatrixXd CN;
  31. Eigen::VectorXd W;
  32. igl::octree(P,point_indices,CH,CN,W);
  33. Eigen::MatrixXi I;
  34. igl::knn(P,2,point_indices,CH,CN,W,I);
  35. Eigen::MatrixXd P2;
  36. igl::slice(P,I.col(1).eval(),1,P2);
  37. Eigen::VectorXd D = (P-P2).rowwise().norm();
  38. REQUIRE(D.minCoeff() > r);
  39. }