summaryrefslogtreecommitdiff
path: root/src/Coxeter_triangulation/test/oracle_test.cpp
diff options
context:
space:
mode:
authorSiargey Kachanovich <siargey.kachanovich@inria.fr>2019-10-17 21:40:20 +0200
committerSiargey Kachanovich <siargey.kachanovich@inria.fr>2019-10-17 21:40:20 +0200
commitec9953f0dbe0f69074f25cc95442ea0012db7d98 (patch)
treeab4a6459bc3c4f9603ee19a8d21f733f0ebd942f /src/Coxeter_triangulation/test/oracle_test.cpp
parent1079b18ed23ad20b87ec194415ab31ba3091a271 (diff)
Added the files from the coxeter branch
Diffstat (limited to 'src/Coxeter_triangulation/test/oracle_test.cpp')
-rw-r--r--src/Coxeter_triangulation/test/oracle_test.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/Coxeter_triangulation/test/oracle_test.cpp b/src/Coxeter_triangulation/test/oracle_test.cpp
new file mode 100644
index 00000000..8d371656
--- /dev/null
+++ b/src/Coxeter_triangulation/test/oracle_test.cpp
@@ -0,0 +1,60 @@
+/* This file is part of the Gudhi Library. The Gudhi library
+ * (Geometric Understanding in Higher Dimensions) is a generic C++
+ * library for computational topology.
+ *
+ * Author(s): Siargey Kachanovich
+ *
+ * Copyright (C) 2019 Inria
+ *
+ * Modification(s):
+ * - YYYY/MM Author: Description of the modification
+ */
+
+#define BOOST_TEST_DYN_LINK
+#define BOOST_TEST_MODULE "oracle"
+#include <boost/test/unit_test.hpp>
+#include <gudhi/Unitary_tests_utils.h>
+
+#include <string>
+
+#include <gudhi/Implicit_manifold_intersection_oracle.h>
+
+#include <gudhi/Functions/Function_Sm_in_Rd.h>
+#include <gudhi/Functions/Cartesian_product.h>
+
+#include <gudhi/Coxeter_triangulation.h>
+
+#include <random>
+#include <cstdlib>
+
+using namespace Gudhi::coxeter_triangulation;
+
+BOOST_AUTO_TEST_CASE(oracle) {
+
+ Function_Sm_in_Rd fun_sph(5.1111, 2);
+ auto oracle = make_oracle(fun_sph);
+ Coxeter_triangulation<> cox_tr(oracle.amb_d());
+ // cox_tr.change_offset(Eigen::VectorXd::Random(oracle.amb_d()));
+
+ Eigen::VectorXd seed = fun_sph.seed();
+ auto s = cox_tr.locate_point(seed);
+
+ std::size_t num_intersected_edges = 0;
+ for (auto f: s.face_range(oracle.cod_d())) {
+ auto qr = oracle.intersects(f, cox_tr);
+ if (qr.success)
+ num_intersected_edges++;
+ auto vertex_it = f.vertex_range().begin();
+ Eigen::Vector3d p1 = cox_tr.cartesian_coordinates(*vertex_it++);
+ Eigen::Vector3d p2 = cox_tr.cartesian_coordinates(*vertex_it++);
+ BOOST_CHECK( vertex_it == f.vertex_range().end() );
+ Eigen::MatrixXd m(3,3);
+ if (qr.success) {
+ m.col(0) = qr.intersection;
+ m.col(1) = p1;
+ m.col(2) = p2;
+ GUDHI_TEST_FLOAT_EQUALITY_CHECK(m.determinant(), 0.0, 1e-10);
+ }
+ }
+ BOOST_CHECK( num_intersected_edges == 3 || num_intersected_edges == 4 );
+}