Browse Source

uncomment tests

Francis Williams 6 years ago
parent
commit
e94a8e98a1

+ 18 - 18
tests/include/igl/bbw.cpp

@@ -5,22 +5,22 @@
 #include <igl/readTGF.h>
 #include <igl/bbw.h>
 
-// TEST_CASE("bbw: decimated_knight", "[igl]")
-// {
-//   Eigen::MatrixXd V,C;
-//   Eigen::MatrixXi T,F,E;
-//   igl::readMESH(test_common::data_path("decimated-knight.mesh"),V,T,F);
-//   igl::readTGF(test_common::data_path("decimated-knight.tgf"),C,E);
-//   Eigen::MatrixXd W_groundtruth, Was, Wmo;
-//   igl::readDMAT(
-//     test_common::data_path("decimated-knight-matlab-active-set.dmat"),W_groundtruth);
-//   Eigen::VectorXi b;
-//   Eigen::MatrixXd bc;
-//   igl::boundary_conditions(V,T,C,Eigen::VectorXi(),E,Eigen::MatrixXi(),b,bc);
-//   igl::BBWData params;
-//   params.active_set_params.max_iter = 100;
-//   igl::bbw(V,T,b,bc,params,Was);
-//   // igl::writeDMAT("decimated-knight-as.dmat",Was);
-//   REQUIRE (1e-4 > (Was-W_groundtruth).array().abs().maxCoeff());
-// }
+TEST_CASE("bbw: decimated_knight", "[igl]")
+{
+  Eigen::MatrixXd V,C;
+  Eigen::MatrixXi T,F,E;
+  igl::readMESH(test_common::data_path("decimated-knight.mesh"),V,T,F);
+  igl::readTGF(test_common::data_path("decimated-knight.tgf"),C,E);
+  Eigen::MatrixXd W_groundtruth, Was, Wmo;
+  igl::readDMAT(
+    test_common::data_path("decimated-knight-matlab-active-set.dmat"),W_groundtruth);
+  Eigen::VectorXi b;
+  Eigen::MatrixXd bc;
+  igl::boundary_conditions(V,T,C,Eigen::VectorXi(),E,Eigen::MatrixXi(),b,bc);
+  igl::BBWData params;
+  params.active_set_params.max_iter = 100;
+  igl::bbw(V,T,b,bc,params,Was);
+  // igl::writeDMAT("decimated-knight-as.dmat",Was);
+  REQUIRE (1e-4 > (Was-W_groundtruth).array().abs().maxCoeff());
+}
 

+ 85 - 85
tests/include/igl/copyleft/comiso/miq.cpp

@@ -17,114 +17,114 @@
 #include <sstream>
 #include <igl/writeDMAT.h>
 
-// TEST_CASE("miq: 3_holes", "[igl/copyleft/comiso]")
-// {
-// using namespace Eigen;
-
-// // Input mesh
-// Eigen::MatrixXd V;
-// Eigen::MatrixXi F;
+TEST_CASE("miq: 3_holes", "[igl/copyleft/comiso]")
+{
+using namespace Eigen;
+
+// Input mesh
+Eigen::MatrixXd V;
+Eigen::MatrixXi F;
 
-// // Face barycenters
-// Eigen::MatrixXd B;
+// Face barycenters
+Eigen::MatrixXd B;
 
-// // Cross field
-// Eigen::MatrixXd X1,X2;
+// Cross field
+Eigen::MatrixXd X1,X2;
 
-// // Bisector field
-// Eigen::MatrixXd BIS1, BIS2;
+// Bisector field
+Eigen::MatrixXd BIS1, BIS2;
 
-// // Combed bisector
-// Eigen::MatrixXd BIS1_combed, BIS2_combed;
+// Combed bisector
+Eigen::MatrixXd BIS1_combed, BIS2_combed;
 
-// // Per-corner, integer mismatches
-// Eigen::Matrix<int, Eigen::Dynamic, 3> MMatch;
+// Per-corner, integer mismatches
+Eigen::Matrix<int, Eigen::Dynamic, 3> MMatch;
 
-// // Field singularities
-// Eigen::Matrix<int, Eigen::Dynamic, 1> isSingularity, singularityIndex;
+// Field singularities
+Eigen::Matrix<int, Eigen::Dynamic, 1> isSingularity, singularityIndex;
 
-// // Per corner seams
-// Eigen::Matrix<int, Eigen::Dynamic, 3> Seams;
+// Per corner seams
+Eigen::Matrix<int, Eigen::Dynamic, 3> Seams;
 
-// // Combed field
-// Eigen::MatrixXd X1_combed, X2_combed;
+// Combed field
+Eigen::MatrixXd X1_combed, X2_combed;
 
-// // Global parametrization
-// Eigen::MatrixXd UV;
-// Eigen::MatrixXi FUV;
+// Global parametrization
+Eigen::MatrixXd UV;
+Eigen::MatrixXi FUV;
 
-// // Global parametrization (reference)
-// Eigen::MatrixXd UV_ref;
-// Eigen::MatrixXi FUV_ref;
+// Global parametrization (reference)
+Eigen::MatrixXd UV_ref;
+Eigen::MatrixXi FUV_ref;
 
-// // Load a mesh in OFF format
-// igl::readOFF(test_common::data_path("3holes.off"), V, F);
+// Load a mesh in OFF format
+igl::readOFF(test_common::data_path("3holes.off"), V, F);
 
-// double gradient_size = 50;
-// double iter = 0;
-// double stiffness = 5.0;
-// bool direct_round = 0;
+double gradient_size = 50;
+double iter = 0;
+double stiffness = 5.0;
+bool direct_round = 0;
 
-// // Compute face barycenters
-// igl::barycenter(V, F, B);
+// Compute face barycenters
+igl::barycenter(V, F, B);
 
-// // Contrain one face
-// VectorXi b(1);
-// b << 0;
-// MatrixXd bc(1, 3);
-// bc << 1, 0, 0;
+// Contrain one face
+VectorXi b(1);
+b << 0;
+MatrixXd bc(1, 3);
+bc << 1, 0, 0;
 
-// // Create a smooth 4-RoSy field
-// VectorXd S;
-// igl::copyleft::comiso::nrosy(V, F, b, bc, VectorXi(), VectorXd(), MatrixXd(), 4, 0.5, X1, S);
+// Create a smooth 4-RoSy field
+VectorXd S;
+igl::copyleft::comiso::nrosy(V, F, b, bc, VectorXi(), VectorXd(), MatrixXd(), 4, 0.5, X1, S);
 
-// // Find the orthogonal vector
-// MatrixXd B1, B2, B3;
-// igl::local_basis(V, F, B1, B2, B3);
-// X2 = igl::rotate_vectors(X1, VectorXd::Constant(1, igl::PI / 2), B1, B2);
+// Find the orthogonal vector
+MatrixXd B1, B2, B3;
+igl::local_basis(V, F, B1, B2, B3);
+X2 = igl::rotate_vectors(X1, VectorXd::Constant(1, igl::PI / 2), B1, B2);
 
-// // Always work on the bisectors, it is more general
-// igl::compute_frame_field_bisectors(V, F, X1, X2, BIS1, BIS2);
+// Always work on the bisectors, it is more general
+igl::compute_frame_field_bisectors(V, F, X1, X2, BIS1, BIS2);
 
-// // Comb the field, implicitly defining the seams
-// igl::comb_cross_field(V, F, BIS1, BIS2, BIS1_combed, BIS2_combed);
+// Comb the field, implicitly defining the seams
+igl::comb_cross_field(V, F, BIS1, BIS2, BIS1_combed, BIS2_combed);
 
-// // Find the integer mismatches
-//     igl::cross_field_mismatch(V, F, BIS1_combed, BIS2_combed, true, MMatch);
+// Find the integer mismatches
+    igl::cross_field_mismatch(V, F, BIS1_combed, BIS2_combed, true, MMatch);
 
-// // Find the singularities
-// igl::find_cross_field_singularities(V, F, MMatch, isSingularity, singularityIndex);
+// Find the singularities
+igl::find_cross_field_singularities(V, F, MMatch, isSingularity, singularityIndex);
 
-// // Cut the mesh, duplicating all vertices on the seams
-// igl::cut_mesh_from_singularities(V, F, MMatch, Seams);
+// Cut the mesh, duplicating all vertices on the seams
+igl::cut_mesh_from_singularities(V, F, MMatch, Seams);
 
-// // Comb the frame-field accordingly
-// igl::comb_frame_field(V, F, X1, X2, BIS1_combed, BIS2_combed, X1_combed, X2_combed);
+// Comb the frame-field accordingly
+igl::comb_frame_field(V, F, X1, X2, BIS1_combed, BIS2_combed, X1_combed, X2_combed);
 
-// // Global parametrization
-// igl::copyleft::comiso::miq(V,
-//           F,
-//           X1_combed,
-//           X2_combed,
-//           MMatch,
-//           isSingularity,
-//           Seams,
-//           UV,
-//           FUV,
-//           gradient_size,
-//           stiffness,
-//           direct_round,
-//           iter,
-//           5,
-//           true);
+// Global parametrization
+igl::copyleft::comiso::miq(V,
+          F,
+          X1_combed,
+          X2_combed,
+          MMatch,
+          isSingularity,
+          Seams,
+          UV,
+          FUV,
+          gradient_size,
+          stiffness,
+          direct_round,
+          iter,
+          5,
+          true);
 
-//   // Refresh the test data
-//   // igl::writeDMAT(test_common::data_path("3holes-miq-UV.dmat"),UV);
-//   // igl::writeDMAT(test_common::data_path("3holes-miq-FUV.dmat"),FUV);
+  // Refresh the test data
+  // igl::writeDMAT(test_common::data_path("3holes-miq-UV.dmat"),UV);
+  // igl::writeDMAT(test_common::data_path("3holes-miq-FUV.dmat"),FUV);
 
-//   igl::readDMAT(test_common::data_path("3holes-miq-UV.dmat"),UV_ref);
-//   igl::readDMAT(test_common::data_path("3holes-miq-FUV.dmat"),FUV_ref);
+  igl::readDMAT(test_common::data_path("3holes-miq-UV.dmat"),UV_ref);
+  igl::readDMAT(test_common::data_path("3holes-miq-FUV.dmat"),FUV_ref);
 
-//   REQUIRE (1e-6 > (UV-UV_ref).array().abs().maxCoeff());
-//   REQUIRE (1e-6 > (FUV-FUV_ref).array().abs().maxCoeff());
-// }
+  REQUIRE (1e-6 > (UV-UV_ref).array().abs().maxCoeff());
+  REQUIRE (1e-6 > (FUV-FUV_ref).array().abs().maxCoeff());
+}

+ 80 - 80
tests/include/igl/embree/EmbreeIntersector.cpp

@@ -1,97 +1,97 @@
 #include <test_common.h>
 #include <igl/embree/EmbreeIntersector.h>
 
-// TEST_CASE("EmbreeIntersector: cube", "[igl/embree]")
-// {
-//   //The allowed error for this test
-//   const double epsilon = 1e-6;
+TEST_CASE("EmbreeIntersector: cube", "[igl/embree]")
+{
+  //The allowed error for this test
+  const double epsilon = 1e-6;
 
-//   Eigen::MatrixXd V;
-//   Eigen::MatrixXi F;
-//   // This is a cube of dimensions 1.0x1.0x1.0
-//   test_common::load_mesh("cube.obj", V, F);
+  Eigen::MatrixXd V;
+  Eigen::MatrixXi F;
+  // This is a cube of dimensions 1.0x1.0x1.0
+  test_common::load_mesh("cube.obj", V, F);
 
-//   // Initialize embree
-//   igl::embree::EmbreeIntersector embree;
-//   embree.init(V.cast<float>(),F.cast<int>());
+  // Initialize embree
+  igl::embree::EmbreeIntersector embree;
+  embree.init(V.cast<float>(),F.cast<int>());
 
-//   const int expected_id[] = {4,8,5,2,7,0};
-//   const float expected_u[] = {0.5,0.5,0.5,0.5,0.5,0.5};
-//   const float expected_v[] = {0.5,0.0,0.0,0.0,0.5,0.0};
+  const int expected_id[] = {4,8,5,2,7,0};
+  const float expected_u[] = {0.5,0.5,0.5,0.5,0.5,0.5};
+  const float expected_v[] = {0.5,0.0,0.0,0.0,0.5,0.0};
 
-//   // Shoot ray from inside out
-//   for (int dim=0; dim<6; ++dim)
-//   {
-//     Eigen::Vector3f pos(0,0,0);
-//     Eigen::Vector3f dir(0,0,0);
-//     // test each dimension, pos and neg
-//     dir[dim/2] = dim%2 ? -1 : 1;
-//     igl::Hit hit;
-//     bool hitP = embree.intersectRay(pos, dir, hit);
-//     CHECK(hitP);
-//     REQUIRE(hit.t == Approx(0.5).margin(epsilon));
-//     REQUIRE(hit.id == expected_id[dim]);
-//     REQUIRE(hit.u == Approx(expected_u[dim]).margin(epsilon));
-//     REQUIRE(hit.v == Approx(expected_v[dim]).margin(epsilon));
-//   }
+  // Shoot ray from inside out
+  for (int dim=0; dim<6; ++dim)
+  {
+    Eigen::Vector3f pos(0,0,0);
+    Eigen::Vector3f dir(0,0,0);
+    // test each dimension, pos and neg
+    dir[dim/2] = dim%2 ? -1 : 1;
+    igl::Hit hit;
+    bool hitP = embree.intersectRay(pos, dir, hit);
+    CHECK(hitP);
+    REQUIRE(hit.t == Approx(0.5).margin(epsilon));
+    REQUIRE(hit.id == expected_id[dim]);
+    REQUIRE(hit.u == Approx(expected_u[dim]).margin(epsilon));
+    REQUIRE(hit.v == Approx(expected_v[dim]).margin(epsilon));
+  }
 
-//   // Shoot ray from outside in
-//   for (int dim=0; dim<6; ++dim)
-//   {
-//     Eigen::Vector3f dir(0,0,0);
-//     // test each dimension, pos and neg
-//     dir[dim/2] = dim%2 ? 1 : -1;
+  // Shoot ray from outside in
+  for (int dim=0; dim<6; ++dim)
+  {
+    Eigen::Vector3f dir(0,0,0);
+    // test each dimension, pos and neg
+    dir[dim/2] = dim%2 ? 1 : -1;
 
-//     Eigen::Vector3f pos = -dir;
+    Eigen::Vector3f pos = -dir;
 
-//     igl::Hit hit;
-//     bool hitP = embree.intersectRay(pos, dir, hit);
-//     CHECK(hitP);
-//     REQUIRE(hit.t == Approx(0.5).margin(epsilon));
-//     REQUIRE(hit.id == expected_id[dim]);
-//     REQUIRE(hit.u == Approx(expected_u[dim]).margin(epsilon));
-//     REQUIRE(hit.v == Approx(expected_v[dim]).margin(epsilon));
-//   }
+    igl::Hit hit;
+    bool hitP = embree.intersectRay(pos, dir, hit);
+    CHECK(hitP);
+    REQUIRE(hit.t == Approx(0.5).margin(epsilon));
+    REQUIRE(hit.id == expected_id[dim]);
+    REQUIRE(hit.u == Approx(expected_u[dim]).margin(epsilon));
+    REQUIRE(hit.v == Approx(expected_v[dim]).margin(epsilon));
+  }
 
-//   // Rays that miss
-//   for (int dim=0; dim<6; ++dim)
-//   {
-//     Eigen::Vector3f pos(0,0,0);
-//     Eigen::Vector3f dir(0,0,0);
-//     // test each dimension, pos and neg
-//     dir[dim/2] = dim%2 ? -1 : 1;
-//     pos[(dim/2+1)%3] = dir[dim/2];
+  // Rays that miss
+  for (int dim=0; dim<6; ++dim)
+  {
+    Eigen::Vector3f pos(0,0,0);
+    Eigen::Vector3f dir(0,0,0);
+    // test each dimension, pos and neg
+    dir[dim/2] = dim%2 ? -1 : 1;
+    pos[(dim/2+1)%3] = dir[dim/2];
 
-//     igl::Hit hit;
-//     bool hitP = embree.intersectRay(pos, dir, hit);
-//     CHECK_FALSE(hitP);
-//   }
+    igl::Hit hit;
+    bool hitP = embree.intersectRay(pos, dir, hit);
+    CHECK_FALSE(hitP);
+  }
 
-//   // intersect beam
-//   {
-//     Eigen::Vector3f pos(-0.5,-0.5,1);
-//     Eigen::Vector3f dir(0,0,-1);
+  // intersect beam
+  {
+    Eigen::Vector3f pos(-0.5,-0.5,1);
+    Eigen::Vector3f dir(0,0,-1);
 
-//     igl::Hit hit;
-//     bool hitP = embree.intersectBeam(pos, dir, hit);
-//     CHECK(hitP);
-//     REQUIRE(hit.t == Approx(0.5).margin(epsilon));
-//     REQUIRE(hit.id == 7);
-//     REQUIRE(hit.u == Approx(0).margin(epsilon));
-//     REQUIRE(hit.v == Approx(1).margin(epsilon));
-//   }
+    igl::Hit hit;
+    bool hitP = embree.intersectBeam(pos, dir, hit);
+    CHECK(hitP);
+    REQUIRE(hit.t == Approx(0.5).margin(epsilon));
+    REQUIRE(hit.id == 7);
+    REQUIRE(hit.u == Approx(0).margin(epsilon));
+    REQUIRE(hit.v == Approx(1).margin(epsilon));
+  }
 
-//   {
-//     Eigen::Vector3f pos(0.5,-1,0.5);
-//     Eigen::Vector3f dir(0,1,0);
+  {
+    Eigen::Vector3f pos(0.5,-1,0.5);
+    Eigen::Vector3f dir(0,1,0);
 
-//     igl::Hit hit;
-//     bool hitP = embree.intersectBeam(pos, dir, hit);
-//     CHECK(hitP);
-//     REQUIRE(hit.t == Approx(0.5).margin(epsilon));
-//     REQUIRE(hit.id == 2);
-//     REQUIRE(hit.u == Approx(0).margin(epsilon));
-//     REQUIRE(hit.v == Approx(0).margin(epsilon));
-//   }
-// }
+    igl::Hit hit;
+    bool hitP = embree.intersectBeam(pos, dir, hit);
+    CHECK(hitP);
+    REQUIRE(hit.t == Approx(0.5).margin(epsilon));
+    REQUIRE(hit.id == 2);
+    REQUIRE(hit.u == Approx(0).margin(epsilon));
+    REQUIRE(hit.v == Approx(0).margin(epsilon));
+  }
+}