add an example with IO for a .mesh file

This commit is contained in:
Jane Tournois 2020-08-18 10:42:20 +02:00
parent 5e3521a12f
commit 0a7d8cfd25
4 changed files with 5101 additions and 0 deletions

View File

@ -893,6 +893,26 @@ output_to_medit(std::ostream& os,
}
}
template<typename T3>
void
output_triangulation_to_medit(std::ostream& os, const T3& t3)
{
CGAL::Mesh_complex_3_in_triangulation_3<T3, int, int> c3t3;
c3t3.triangulation() = t3;
c3t3.rescan_after_load_of_triangulation();
output_to_medit(os, c3t3);
}
template<typename T3>
bool input_medit(std::istream& in, T3& t3)
{
// in.open(fileinfo.filePath().toUtf8(), std::ios_base::in);//not binary
CGAL_assertion(!(!in));
return CGAL::build_triangulation_from_file<T3, true>(in, t3);
}
} // end namespace CGAL
#endif // CGAL_IO_FILE_MEDIT_H

View File

@ -28,6 +28,7 @@ include(CGAL_Eigen_support)
create_single_source_cgal_program( "tetrahedral_remeshing_example.cpp" )
create_single_source_cgal_program( "tetrahedral_remeshing_with_features.cpp")
create_single_source_cgal_program( "tetrahedral_remeshing_of_one_subdomain.cpp")
create_single_source_cgal_program( "tetrahedral_remeshing_from_mesh.cpp")
create_single_source_cgal_program( "mesh_and_remesh_polyhedral_domain_with_features.cpp" )
target_link_libraries(mesh_and_remesh_polyhedral_domain_with_features PUBLIC CGAL::Eigen_support)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,34 @@
#define CGAL_TETRAHEDRAL_REMESHING_VERBOSE
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Tetrahedral_remeshing/Remeshing_triangulation_3.h>
#include <CGAL/tetrahedral_remeshing.h>
#include <CGAL/IO/File_medit.h>
#include <iostream>
#include <fstream>
#include <string>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Tetrahedral_remeshing::Remeshing_triangulation_3<K> Remeshing_triangulation;
int main(int argc, char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/sphere.mesh";
const double target_edge_length = (argc > 2) ? atof(argv[2]) : 0.1;
std::ifstream is(filename, std::ios_base::in);
Remeshing_triangulation tr;
CGAL::input_medit(is, tr);
CGAL::tetrahedral_isotropic_remeshing(tr, target_edge_length);
std::ofstream os("after_remeshing.mesh");
CGAL::output_triangulation_to_medit(os, tr);
return EXIT_SUCCESS;
}