diff options
author | ROUVREAU Vincent <vincent.rouvreau@inria.fr> | 2020-11-17 11:45:32 +0100 |
---|---|---|
committer | ROUVREAU Vincent <vincent.rouvreau@inria.fr> | 2020-11-17 11:45:32 +0100 |
commit | f16921c170dee7a7f987afcfa5de923ac8d37dd5 (patch) | |
tree | 788299daa5068cac75019c91f33151b26add2d15 /src/Coxeter_triangulation | |
parent | 1d7c18e91a73a539e807d323a47d32bbba18dac7 (diff) |
Some doxygen improvements with a cell complex construction basic example
Diffstat (limited to 'src/Coxeter_triangulation')
5 files changed, 101 insertions, 4 deletions
diff --git a/src/Coxeter_triangulation/doc/intro_coxeter_triangulation.h b/src/Coxeter_triangulation/doc/intro_coxeter_triangulation.h index 5eb0cb22..3316bd81 100644 --- a/src/Coxeter_triangulation/doc/intro_coxeter_triangulation.h +++ b/src/Coxeter_triangulation/doc/intro_coxeter_triangulation.h @@ -196,20 +196,31 @@ the vertex cells in the cell complex to their Cartesian coordinates. \section example Examples +\subsection examplewithoutboundaries Basic example without boundaries +\include Coxeter_triangulation/cell_complex_from_basic_circle_manifold.cpp + +The program output is: + +\include Coxeter_triangulation/cell_complex_from_basic_circle_manifold_for_doc.txt + +\subsection exampleswithboundaries Example with boundaries + Here is an example of constructing a piecewise-linear approximation of a flat torus embedded in \f$\mathbb{R}^4\f$, rotated by a random rotation in \f$\mathbb{R}^4\f$ and cut by a hyperplane. \include Coxeter_triangulation/manifold_tracing_flat_torus_with_boundary.cpp -The output in medit is: +The output in <a target="_blank" href="https://www.ljll.math.upmc.fr/frey/software.html">medit</a> is: \image html "flat_torus_with_boundary.png" "Output from the example of a flat torus with boundary" +\subsection exampleswithcustomfunction Example with a custom function + In the following more complex example, we define a custom function for the implicit manifold. \include Coxeter_triangulation/manifold_tracing_custom_function.cpp -The output in medit looks as follows: +The output in <a target="_blank" href="https://www.ljll.math.upmc.fr/frey/software.html">medit</a> looks as follows: \image html "custom_function.png" "Output from the example with a custom function" diff --git a/src/Coxeter_triangulation/example/CMakeLists.txt b/src/Coxeter_triangulation/example/CMakeLists.txt index cbab2024..e7822ff7 100644 --- a/src/Coxeter_triangulation/example/CMakeLists.txt +++ b/src/Coxeter_triangulation/example/CMakeLists.txt @@ -13,3 +13,10 @@ if (TBB_FOUND) endif() add_test(NAME Coxeter_triangulation_manifold_tracing_custom_function_example COMMAND $<TARGET_FILE:Coxeter_triangulation_manifold_tracing_custom_function_example>) + +add_executable ( Coxeter_triangulation_cell_complex_from_basic_circle_manifold_example cell_complex_from_basic_circle_manifold.cpp ) +if (TBB_FOUND) + target_link_libraries(Coxeter_triangulation_cell_complex_from_basic_circle_manifold_example ${TBB_LIBRARIES}) +endif() +add_test(NAME Coxeter_triangulation_cell_complex_from_basic_circle_manifold_example + COMMAND $<TARGET_FILE:Coxeter_triangulation_cell_complex_from_basic_circle_manifold_example>) 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..0d32f916 --- /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/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(std::make_pair(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; +} diff --git a/src/Coxeter_triangulation/example/cell_complex_from_basic_circle_manifold_for_doc.txt b/src/Coxeter_triangulation/example/cell_complex_from_basic_circle_manifold_for_doc.txt new file mode 100644 index 00000000..b323cca3 --- /dev/null +++ b/src/Coxeter_triangulation/example/cell_complex_from_basic_circle_manifold_for_doc.txt @@ -0,0 +1,26 @@ +Vertices: +0 : (-0.680375, 0.523483) +1 : (0.147642, 0.887879) +2 : (-0.847996, 0.30801) +3 : (-0.881369, 0.0951903) +4 : (0.638494, -0.550215) +5 : (0.415344, 0.843848) +6 : (0.812453, -0.0815816) +7 : (0.319625, -0.7709) +8 : (0.319625, 0.889605) +9 : (0.579487, 0.638553) +10 : (-0.680375, -0.461325) +11 : (-0.364269, -0.760962) +Edges: +3 2 +3 10 +10 11 +11 7 +7 4 +2 0 +0 1 +6 9 +6 4 +1 8 +8 5 +5 9 diff --git a/src/Coxeter_triangulation/include/gudhi/Cell_complex/Hasse_diagram_cell.h b/src/Coxeter_triangulation/include/gudhi/Cell_complex/Hasse_diagram_cell.h index 24045c0c..04d50784 100644 --- a/src/Coxeter_triangulation/include/gudhi/Cell_complex/Hasse_diagram_cell.h +++ b/src/Coxeter_triangulation/include/gudhi/Cell_complex/Hasse_diagram_cell.h @@ -36,8 +36,6 @@ class Hasse_diagram; * It also allow to store any additional information of a type Additional_information which is a template parameter of * the class (set by default to void). * - * Please refer to \ref Hasse_diagram for examples. - * * The complex is a template class requiring the following parameters: * Incidence_type_ - determine the type of incidence coefficients. Use integers in most general case. * Filtration_type_ - type of filtration of cells. |