diff options
author | MathieuCarriere <mathieu.carriere3@gmail.com> | 2021-11-03 12:11:14 +0100 |
---|---|---|
committer | MathieuCarriere <mathieu.carriere3@gmail.com> | 2021-11-03 12:11:14 +0100 |
commit | 1597a5b4fc1aec9f825e430e80b2a843a9037043 (patch) | |
tree | 94bd919d17e6ea220bbddacee831ad1db6326603 /src/Coxeter_triangulation/example/cell_complex_from_basic_circle_manifold.cpp | |
parent | 6b16678c71daa2b9b56cc8fa79a18cde080298cc (diff) | |
parent | 728acf3e9ecfba29fc9be7fba5fc88f0a7f49880 (diff) |
Merge branch 'master' of https://github.com/GUDHI/gudhi-devel into diff
Diffstat (limited to 'src/Coxeter_triangulation/example/cell_complex_from_basic_circle_manifold.cpp')
-rw-r--r-- | src/Coxeter_triangulation/example/cell_complex_from_basic_circle_manifold.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/Coxeter_triangulation/example/cell_complex_from_basic_circle_manifold.cpp b/src/Coxeter_triangulation/example/cell_complex_from_basic_circle_manifold.cpp new file mode 100644 index 00000000..dfaaffa8 --- /dev/null +++ b/src/Coxeter_triangulation/example/cell_complex_from_basic_circle_manifold.cpp @@ -0,0 +1,55 @@ +#include <iostream> + +#include <gudhi/Coxeter_triangulation.h> +#include <gudhi/Implicit_manifold_intersection_oracle.h> // for Gudhi::coxeter_triangulation::make_oracle +#include <gudhi/Manifold_tracing.h> +#include <gudhi/Coxeter_triangulation/Cell_complex/Cell_complex.h> +#include <gudhi/Functions/Function_Sm_in_Rd.h> + +using namespace Gudhi::coxeter_triangulation; + +int main(int argc, char** argv) { + // Oracle is a circle of radius 1 + double radius = 1.; + auto oracle = make_oracle(Function_Sm_in_Rd(radius, 1)); + + // Define a Coxeter triangulation. + Coxeter_triangulation<> cox_tr(oracle.amb_d()); + // Theory forbids that a vertex of the triangulation lies exactly on the circle. + // Add some offset to avoid algorithm degeneracies. + cox_tr.change_offset(-Eigen::VectorXd::Random(oracle.amb_d())); + // For a better manifold approximation, one can change the circle radius value or change the linear transformation + // matrix. + // The number of points and edges will increase with a better resolution. + //cox_tr.change_matrix(0.5 * cox_tr.matrix()); + + // Manifold tracing algorithm + using Out_simplex_map = typename Manifold_tracing<Coxeter_triangulation<> >::Out_simplex_map; + + std::vector<Eigen::VectorXd> seed_points(1, oracle.seed()); + Out_simplex_map interior_simplex_map; + manifold_tracing_algorithm(seed_points, cox_tr, oracle, interior_simplex_map); + + // Constructing the cell complex + std::size_t intr_d = oracle.amb_d() - oracle.cod_d(); + Cell_complex<Out_simplex_map> cell_complex(intr_d); + cell_complex.construct_complex(interior_simplex_map); + + // List of Hasse_cell pointers to retrieve vertices values from edges + std::map<Cell_complex<Out_simplex_map>::Hasse_cell*, std::size_t> vi_map; + std::size_t index = 0; + + std::clog << "Vertices:" << std::endl; + for (const auto& cp_pair : cell_complex.cell_point_map()) { + std::clog << index << " : (" << cp_pair.second(0) << ", " << cp_pair.second(1) << ")" << std::endl; + vi_map.emplace(cp_pair.first, index++); + } + + std::clog << "Edges:" << std::endl; + for (const auto& sc_pair : cell_complex.interior_simplex_cell_map(1)) { + Cell_complex<Out_simplex_map>::Hasse_cell* edge_cell = sc_pair.second; + for (const auto& vi_pair : edge_cell->get_boundary()) std::clog << vi_map[vi_pair.first] << " "; + std::clog << std::endl; + } + return 0; +} |