5 : source_mesh(std::make_unique<
GEO::Mesh>()),
13 CmdLine::import_arg_group(
"standard");
14 CmdLine::import_arg_group(
"algo");
15 CmdLine::import_arg_group(
"opt");
16 CmdLine::declare_arg(
"nb_iter", 1000,
"number of iterations for OTM");
18 CmdLine::declare_arg_group(
19 "RVD",
"RVD output options", CmdLine::ARG_ADVANCED);
20 CmdLine::declare_arg(
"RVD",
false,
"save restricted Voronoi diagram");
22 "RVD_iter",
false,
"save restricted Voronoi diagram at each iteration");
24 "RVD:borders_only",
false,
"save only border of RVD");
26 "RVD:integration_simplices",
true,
"export RVD as integration simplices");
28 CmdLine::declare_arg(
"multilevel",
true,
"use multilevel algorithm");
29 CmdLine::declare_arg(
"BRIO",
true,
30 "use BRIO reordering to compute the levels");
31 CmdLine::declare_arg(
"ratio", 0.125,
"ratio between levels");
32 CmdLine::declare_arg(
"epsilon", 0.01,
"relative measure error in a cell");
34 "lock",
true,
"Lock lower levels when sampling shape");
36 "fitting_degree", 2,
"degree for interpolating weights");
38 "project",
true,
"project sampling on border");
40 "feature_sensitive",
true,
"attempt to recover hard edges");
42 "singular",
false,
"compute and save singular surface");
43 CmdLine::set_arg(
"algo:delaunay",
"BPOW");
45 "recenter",
true,
"recenter target onto source mesh");
47 "rescale",
true,
"rescale target to match source volume");
53 GEO::MeshIOFlags flags;
54 flags.set_element(GEO::MESH_CELLS);
55 flags.set_attribute(GEO::MESH_CELL_REGION);
57 std::cout <<
"Loading mesh from " << filename << std::endl;
58 if (!GEO::mesh_load(filename, mesh, flags)) {
62 if (!mesh.cells.are_simplices()) {
63 std::cerr <<
"File " << filename
64 <<
" should only have tetrahedra" << std::endl;
68 if (mesh.cells.nb() == 0) {
69 std::cout <<
"File " << filename
70 <<
" does not contain a volume" << std::endl;
71 std::cout <<
"Trying to tetrahedralize..." << std::endl;
72 if (!GEO::mesh_tetrahedralize(mesh,
true,
false)) {
96 std::cerr <<
"No target points loaded. Please load target points before running." << std::endl;
100 std::cout <<
"Setting up optimal transport computation..." << std::endl;
103 GEO::Attribute<double> density(
source_mesh->vertices.attributes(),
"density");
104 for(GEO::index_t v=0; v <
source_mesh->vertices.nb(); ++v) {
111 std::cout <<
"Source mesh vertices dimension: " <<
source_mesh->vertices.dimension() << std::endl;
115 std::cout <<
"Optimal transport map created" << std::endl;
118 std::vector<double> target_points_data;
121 target_points_data.push_back(point[0]);
122 target_points_data.push_back(point[1]);
123 target_points_data.push_back(point[2]);
128 target_points_data.data()
134 <<
" iterations and epsilon = " <<
epsilon_ << std::endl;
141 for (GEO::index_t i = 0; i < OTM.nb_points(); ++i) {
145 std::cout <<
"Optimization completed successfully" << std::endl;
147 }
catch (
const std::exception& e) {
148 std::cerr <<
"Error during computation: " << e.what() << std::endl;
162 const std::string& points_file,
163 const std::string& io_coding)
const {
165 std::cout <<
"Saving potential to " << potential_file << std::endl;
170 std::cout <<
"Saving points to " << points_file << std::endl;
174 std::cout <<
"Results saved successfully" << std::endl;
176 }
catch (
const std::exception& e) {
177 std::cerr <<
"Error saving results: " << e.what() << std::endl;
std::vector< double > get_potential() const
Get computed potential.
std::vector< dealii::Point< 3 > > target_points
bool set_source_mesh(const std::string &filename)
Set source mesh from file.
bool save_results(const std::string &potential_file, const std::string &points_file, const std::string &io_coding="txt") const
Save computation results to files.
void set_parameters(unsigned int max_iterations=1000, double epsilon=0.01)
Set parameters for the solver.
GEO::vector< double > potential
bool set_target_points(const std::string &filename, const std::string &io_coding)
Set target points from file.
bool load_volume_mesh(const std::string &filename, GEO::Mesh &mesh)
unsigned int max_iterations_
bool run()
Run the exact SOT computation.
std::unique_ptr< GEO::Mesh > source_mesh
std::vector< dealii::Point< 3 > > get_target_points() const
Get target points.
void write_vector(const VectorContainer &points, const std::string &filepath, const std::string &fileMode="txt")
Write a vector container to a file in binary or text format.
bool read_vector(VectorContainer &points, const std::string &filepath, const std::string &fileMode="")
Read a vector container from a file in binary or text format.