From 1736edf75cdcf02fa4cacd943eef06a9868e6aec Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Wed, 25 Jun 2025 14:53:57 +0200 Subject: [PATCH 1/3] add a test that does make_mesh_3 + write + read + tetrahedral_remeshing --- .../test/Tetrahedral_remeshing/CMakeLists.txt | 3 + .../test_mesh_and_remesh_with_io.cpp | 77 +++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_mesh_and_remesh_with_io.cpp diff --git a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/CMakeLists.txt b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/CMakeLists.txt index 63bc0c06023..47c0b213956 100644 --- a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/CMakeLists.txt +++ b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/CMakeLists.txt @@ -38,6 +38,9 @@ if(TARGET CGAL::Eigen3_support) create_single_source_cgal_program("features_and_adaptive_sizing.cpp") target_link_libraries(features_and_adaptive_sizing PRIVATE CGAL::Eigen3_support) + + create_single_source_cgal_program("test_mesh_and_remesh_with_io.cpp") + target_link_libraries(test_mesh_and_remesh_with_io PRIVATE CGAL::Eigen3_support) # with MLS projection add_executable(test_mesh_and_remesh_polyhedron_with_features_mls diff --git a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_mesh_and_remesh_with_io.cpp b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_mesh_and_remesh_with_io.cpp new file mode 100644 index 00000000000..ae25746ac5b --- /dev/null +++ b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_mesh_and_remesh_with_io.cpp @@ -0,0 +1,77 @@ +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include + +#include + +// Domain +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; + +typedef CGAL::Image_3 Image; +typedef CGAL::Labeled_mesh_domain_3 Mesh_domain; + +// Triangulation +typedef CGAL::Mesh_triangulation_3::type Tr; +typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; + +// Mesh Criteria +typedef CGAL::Mesh_criteria_3 Mesh_criteria; +typedef Mesh_criteria::Facet_criteria Facet_criteria; +typedef Mesh_criteria::Cell_criteria Cell_criteria; + +typedef Tr::Geom_traits Gt; +typedef CGAL::Triangulation_3 T3; +typedef CGAL::Tetrahedral_remeshing::Remeshing_triangulation_3 Remeshing_triangulation; + +using namespace CGAL::parameters; + +int main() +{ + const std::string filename = CGAL::data_file_path("images/liver.inr.gz"); + + CGAL::Image_3 image; + if(!image.read(filename)) { + std::cerr << "Error: Cannot read file " << filename << std::endl; + return EXIT_FAILURE; + } + Mesh_domain domain = Mesh_domain::create_labeled_image_mesh_domain(image, relative_error_bound = 1e-9); + + // Mesh criteria + Facet_criteria facet_criteria(25, 20, 2); // angle, size, approximation + Cell_criteria cell_criteria(3, 20); // radius-edge ratio, size + Mesh_criteria criteria(facet_criteria, cell_criteria); + + // Mesh + C3t3 c3t3 = CGAL::make_mesh_3(domain, criteria, no_exude(), no_perturb()); + + std::cout << "Meshing done." << std::endl; + + // Write + std::ofstream os("after_meshing_io.mesh"); + CGAL::IO::write_MEDIT(os, c3t3); + os.close(); + + // Read + Remeshing_triangulation tr; + std::ifstream is("after_meshing_io.mesh"); + CGAL::IO::read_MEDIT(is, tr); + + // Remesh + double target_edge_length = 10.; + CGAL::tetrahedral_isotropic_remeshing(tr, target_edge_length); + + std::cout << "Remeshing done." << std::endl; + + return 0; +} From bb6dde46d601c3e0179c276e3ada93a7fdedbb01 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Wed, 25 Jun 2025 15:06:48 +0200 Subject: [PATCH 2/3] add typedef --- SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h b/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h index da33e68756b..a627a80c7f8 100644 --- a/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h +++ b/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h @@ -566,6 +566,7 @@ bool build_triangulation_from_file(std::istream& is, { using Point_3 = typename Tr::Point; using Subdomain_index = typename Tr::Cell::Subdomain_index; + using Surface_patch_index = typename Tr::Cell::Surface_patch_index; using Facet = std::array; // 3 = id using Tet_with_ref = std::array; // 4 = id @@ -576,7 +577,7 @@ bool build_triangulation_from_file(std::istream& is, std::vector finite_cells; std::vector subdomains; std::vector points; - boost::unordered_map border_facets; + boost::unordered_map border_facets; int dim; int nv, nf, ntet, ref; @@ -632,7 +633,7 @@ bool build_triangulation_from_file(std::istream& is, if(line.find("Triangles") != std::string::npos) { bool has_negative_surface_patch_ids = false; - typename Tr::Cell::Surface_patch_index max_surface_patch_id = 0; + Surface_patch_index max_surface_patch_id{0}; is >> nf; if(verbose) @@ -641,7 +642,7 @@ bool build_triangulation_from_file(std::istream& is, for(int i=0; i> n[0] >> n[1] >> n[2] >> surface_patch_id)) { if(verbose) From 0001e5c96d144aba289f1cfffcc2a152a558d3fe Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Wed, 25 Jun 2025 15:33:46 +0200 Subject: [PATCH 3/3] trailing whitespaces --- Tetrahedral_remeshing/test/Tetrahedral_remeshing/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/CMakeLists.txt b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/CMakeLists.txt index 47c0b213956..0cbfa1acc28 100644 --- a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/CMakeLists.txt +++ b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/CMakeLists.txt @@ -38,7 +38,7 @@ if(TARGET CGAL::Eigen3_support) create_single_source_cgal_program("features_and_adaptive_sizing.cpp") target_link_libraries(features_and_adaptive_sizing PRIVATE CGAL::Eigen3_support) - + create_single_source_cgal_program("test_mesh_and_remesh_with_io.cpp") target_link_libraries(test_mesh_and_remesh_with_io PRIVATE CGAL::Eigen3_support)