Loading...
Searching...
No Matches
manifold_tracing_flat_torus_with_boundary.cpp
// workaround for the annoying boost message in boost 1.69
#define BOOST_PENDING_INTEGER_LOG2_HPP
#include <boost/integer/integer_log2.hpp>
// end workaround
#include <iostream>
#include <gudhi/Coxeter_triangulation.h>
#include <gudhi/Functions/Function_affine_plane_in_Rd.h>
#include <gudhi/Functions/Function_Sm_in_Rd.h>
#include <gudhi/Functions/Cartesian_product.h>
#include <gudhi/Functions/Linear_transformation.h>
#include <gudhi/Implicit_manifold_intersection_oracle.h>
#include <gudhi/Manifold_tracing.h>
#include <gudhi/Coxeter_triangulation/Cell_complex/Cell_complex.h>
#include <gudhi/Functions/random_orthogonal_matrix.h> // requires CGAL
#include <gudhi/IO/build_mesh_from_cell_complex.h>
#include <gudhi/IO/output_meshes_to_medit.h>
using namespace Gudhi::coxeter_triangulation;
int main(int argc, char** argv) {
// Creating a circle S1 in R2 of specified radius
double radius = 1.0;
Function_Sm_in_Rd fun_circle(radius, 1);
// Creating a flat torus S1xS1 in R4 from two circle functions
auto fun_flat_torus = make_product_function(fun_circle, fun_circle);
// Apply a random rotation in R4
auto matrix = random_orthogonal_matrix(4);
auto fun_flat_torus_rotated = make_linear_transformation(fun_flat_torus, matrix);
// Computing the seed of the function fun_flat_torus
Eigen::VectorXd seed = fun_flat_torus_rotated.seed();
// Defining a domain function that defines the boundary, which is a hyperplane passing by the origin and orthogonal to
// x.
Eigen::MatrixXd normal_matrix = Eigen::MatrixXd::Zero(4, 1);
for (std::size_t i = 0; i < 4; i++) normal_matrix(i, 0) = -seed(i);
Function_affine_plane_in_Rd fun_bound(normal_matrix, -seed / 2);
// Defining the intersection oracle
auto oracle = make_oracle(fun_flat_torus_rotated, fun_bound);
// Define a Coxeter triangulation scaled by a factor lambda.
// The triangulation is translated by a random vector to avoid violating the genericity hypothesis.
double lambda = 0.2;
Coxeter_triangulation<> cox_tr(oracle.amb_d());
cox_tr.change_offset(Eigen::VectorXd::Random(oracle.amb_d()));
cox_tr.change_matrix(lambda * cox_tr.matrix());
// Manifold tracing algorithm
using MT = Manifold_tracing<Coxeter_triangulation<> >;
using Out_simplex_map = typename MT::Out_simplex_map;
std::vector<Eigen::VectorXd> seed_points(1, seed);
Out_simplex_map interior_simplex_map, boundary_simplex_map;
manifold_tracing_algorithm(seed_points, cox_tr, oracle, interior_simplex_map, boundary_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, boundary_simplex_map);
// Output the cell complex to a file readable by medit
output_meshes_to_medit(3, "flat_torus_with_boundary",
build_mesh_from_cell_complex(cell_complex, Configuration(true, true, true, 1, 5, 3),
Configuration(true, true, true, 2, 13, 14)));
return 0;
}
Gudhi::coxeter_triangulation::Cell_complex
A class that constructs the cell complex from the output provided by the class Gudhi::coxeter_triangu...
Definition Cell_complex.h:38
Gudhi::coxeter_triangulation::Cell_complex::construct_complex
void construct_complex(const Out_simplex_map_ &out_simplex_map)
Constructs the the cell complex that approximates an -dimensional manifold without boundary embedded ...
Definition Cell_complex.h:199
Gudhi::coxeter_triangulation::Coxeter_triangulation
A class that stores Coxeter triangulation of type . This triangulation has the greatest simplex quali...
Definition Coxeter_triangulation.h:45
Gudhi::coxeter_triangulation::Freudenthal_triangulation::change_offset
void change_offset(const Eigen::VectorXd &offset)
Change the offset vector to a given value.
Definition Freudenthal_triangulation.h:113
Gudhi::coxeter_triangulation::Freudenthal_triangulation::matrix
const Matrix & matrix() const
Matrix that defines the linear transformation of the triangulation.
Definition Freudenthal_triangulation.h:96
Gudhi::coxeter_triangulation::Freudenthal_triangulation::change_matrix
void change_matrix(const Eigen::MatrixXd &matrix)
Change the linear transformation matrix to a given value.
Definition Freudenthal_triangulation.h:104
Gudhi::coxeter_triangulation::Manifold_tracing
A class that assembles methods for manifold tracing algorithm.
Definition Manifold_tracing.h:39
Gudhi::coxeter_triangulation::manifold_tracing_algorithm
void manifold_tracing_algorithm(const Point_range &seed_points, const Triangulation &triangulation, const Intersection_oracle &oracle, Out_simplex_map &out_simplex_map)
Static method for Manifold_tracing<Triangulation_>::manifold_tracing_algorithm that computes the set ...
Definition Manifold_tracing.h:223
Gudhi::coxeter_triangulation::make_linear_transformation
Linear_transformation< Function_ > make_linear_transformation(const Function_ &function, const Eigen::MatrixXd &matrix)
Static constructor of a linearly transformed function.
Definition Linear_transformation.h:80
Gudhi::coxeter_triangulation::output_meshes_to_medit
void output_meshes_to_medit(std::size_t amb_d, std::string file_name, const Meshes &... meshes)
Outputs a text file with specified meshes that can be visualized in Medit.
Definition output_meshes_to_medit.h:81
Gudhi::coxeter_triangulation::build_mesh_from_cell_complex
Mesh_medit build_mesh_from_cell_complex(const Cell_complex &cell_complex, Configuration i_configuration=Configuration(), Configuration b_configuration=Configuration())
Builds a Gudhi::coxeter_triangulation::Mesh_medit from a Gudhi::coxeter_triangulation::Cell_complex.
Definition build_mesh_from_cell_complex.h:122
Gudhi::coxeter_triangulation::make_oracle
Implicit_manifold_intersection_oracle< Function_, Domain_function_ > make_oracle(const Function_ &function, const Domain_function_ &domain_function)
Static constructor of an intersection oracle from a function with a domain.
Definition Implicit_manifold_intersection_oracle.h:240
Gudhi::coxeter_triangulation::make_product_function
Cartesian_product< Functions... > make_product_function(const Functions &... functions)
Static constructor of a Cartesian product function.
Definition Cartesian_product.h:149
Gudhi::coxeter_triangulation::Function_Sm_in_Rd
A class for the function that defines an m-dimensional implicit sphere embedded in the d-dimensional ...
Definition Function_Sm_in_Rd.h:27
Gudhi::coxeter_triangulation::Function_affine_plane_in_Rd
A class for the function that defines an m-dimensional implicit affine plane embedded in d-dimensiona...
Definition Function_affine_plane_in_Rd.h:27