blue_noise.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. //}
  40. //
  41. //namespace blue_noise
  42. //{
  43. // template <typename DerivedA, typename DerivedB>
  44. // void assert_neq_different_sizes(
  45. // const Eigen::MatrixBase<DerivedA> & A,
  46. // const Eigen::MatrixBase<DerivedB> & B)
  47. // {
  48. // // test_common::assert_neq requires same sizes
  49. // if (A.rows() == B.rows() &&
  50. // A.cols() == B.cols())
  51. // {
  52. // test_common::assert_neq(A, B);
  53. // }
  54. // }
  55. //
  56. // template<typename URBG>
  57. // void test_reproduce()
  58. // {
  59. // Eigen::MatrixXd V;
  60. // Eigen::MatrixXi F;
  61. // igl::readOBJ(test_common::data_path("decimated-knight.obj"),V,F);
  62. //
  63. // static constexpr double r = 0.1;
  64. // static constexpr int seed = 0;
  65. // Eigen::MatrixXd P1, Px1;
  66. // {
  67. // Eigen::MatrixXd B;
  68. // Eigen::VectorXi I;
  69. // URBG rng1(seed);
  70. // igl::blue_noise(V,F,r,B,I, P1,rng1);
  71. // igl::blue_noise(V,F,r,B,I,Px1,rng1);
  72. // }
  73. // Eigen::MatrixXd P2, Px2;
  74. // {
  75. // Eigen::MatrixXd B;
  76. // Eigen::VectorXi I;
  77. // URBG rng2(seed);
  78. // igl::blue_noise(V,F,r,B,I, P2,rng2);
  79. // igl::blue_noise(V,F,r,B,I,Px2,rng2);
  80. // }
  81. //
  82. // test_common::assert_eq(P1, P2);
  83. // test_common::assert_eq(Px1, Px2);
  84. //
  85. // assert_neq_different_sizes(P1, Px1);
  86. // assert_neq_different_sizes(P2, Px2);
  87. // }
  88. //}
  89. //
  90. //
  91. //TEST_CASE("blue_noise: minstd_rand0_reproduce", "[igl]")
  92. //{
  93. // blue_noise::test_reproduce<std::minstd_rand0>();
  94. //}
  95. //TEST_CASE("blue_noise: minstd_rand_reproduce", "[igl]")
  96. //{
  97. // blue_noise::test_reproduce<std::minstd_rand>();
  98. //}
  99. //TEST_CASE("blue_noise: mt19937_reproduce", "[igl]")
  100. //{
  101. // blue_noise::test_reproduce<std::mt19937>();
  102. //}
  103. //TEST_CASE("blue_noise: mt19937_64_reproduce", "[igl]")
  104. //{
  105. // blue_noise::test_reproduce<std::mt19937_64>();
  106. //}