| 1 |
#include <iostream> |
| 2 |
|
| 3 |
#include <gudhi/Coxeter_triangulation.h> |
| 4 |
#include <gudhi/Implicit_manifold_intersection_oracle.h> // for Gudhi::coxeter_triangulation::make_oracle |
| 5 |
#include <gudhi/Manifold_tracing.h> |
| 6 |
#include <gudhi/Coxeter_triangulation/Cell_complex/Cell_complex.h> |
| 7 |
#include <gudhi/Functions/Function_Sm_in_Rd.h> |
| 8 |
|
| 9 |
using namespace Gudhi::coxeter_triangulation; |
| 10 |
|
| 11 |
int main(int argc, char** argv) { |
| 12 |
// Oracle is a circle of radius 1 |
| 13 |
double radius = 1.; |
| 14 |
auto oracle = make_oracle(Function_Sm_in_Rd(radius, 1)); |
| 15 |
|
| 16 |
// Define a Coxeter triangulation. |
| 17 |
Coxeter_triangulation<> cox_tr(oracle.amb_d()); |
| 18 |
// Theory forbids that a vertex of the triangulation lies exactly on the circle. |
| 19 |
// Add some offset to avoid algorithm degeneracies. |
| 20 |
cox_tr.change_offset(-Eigen::VectorXd::Random(oracle.amb_d())); |
| 21 |
// For a better manifold approximation, one can change the circle radius value or change the linear transformation |
| 22 |
// matrix. |
| 23 |
// The number of points and edges will increase with a better resolution. |
| 24 |
//cox_tr.change_matrix(0.5 * cox_tr.matrix()); |
| 25 |
|
| 26 |
// Manifold tracing algorithm |
| 27 |
using Out_simplex_map = typename Manifold_tracing<Coxeter_triangulation<> >::Out_simplex_map; |
| 28 |
|
| 29 |
std::vector<Eigen::VectorXd> seed_points(1, oracle.seed()); |
| 30 |
Out_simplex_map interior_simplex_map; |
| 31 |
manifold_tracing_algorithm(seed_points, cox_tr, oracle, interior_simplex_map); |
| 32 |
|
| 33 |
// Constructing the cell complex |
| 34 |
std::size_t intr_d = oracle.amb_d() - oracle.cod_d(); |
| 35 |
Cell_complex<Out_simplex_map> cell_complex(intr_d); |
| 36 |
cell_complex.construct_complex(interior_simplex_map); |
| 37 |
|
| 38 |
// List of Hasse_cell pointers to retrieve vertices values from edges |
| 39 |
std::map<Cell_complex<Out_simplex_map>::Hasse_cell*, std::size_t> vi_map; |
| 40 |
std::size_t index = 0; |
| 41 |
|
| 42 |
std::clog << "Vertices:" << std::endl; |
| 43 |
for (const auto& cp_pair : cell_complex.cell_point_map()) { |
| 44 |
std::clog << index << " : (" << cp_pair.second(0) << ", " << cp_pair.second(1) << ")" << std::endl; |
| 45 |
vi_map.emplace(cp_pair.first, index++); |
| 46 |
} |
| 47 |
|
| 48 |
std::clog << "Edges:" << std::endl; |
| 49 |
for (const auto& sc_pair : cell_complex.interior_simplex_cell_map(1)) { |
| 50 |
Cell_complex<Out_simplex_map>::Hasse_cell* edge_cell = sc_pair.second; |
| 51 |
for (const auto& vi_pair : edge_cell->get_boundary()) std::clog << vi_map[vi_pair.first] << " "; |
| 52 |
std::clog << std::endl; |
| 53 |
} |
| 54 |
return 0; |
| 55 |
} |