From 694b626f4c9303c9c6b246c612fb0971c36d83b8 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 30 Jul 2026 12:32:02 +0200 Subject: [PATCH 1/2] introduce to_triangulation_3_complex() to "drop" the Delaunay/Regular aspect of the underlying triangulation and have no more guarantees/requirements than T3 --- .../include/CGAL/to_triangulation_3_complex.h | 64 +++++++++++++++++++ .../mesh_and_remesh_c3t3.cpp | 9 +-- 2 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 SMDS_3/include/CGAL/to_triangulation_3_complex.h diff --git a/SMDS_3/include/CGAL/to_triangulation_3_complex.h b/SMDS_3/include/CGAL/to_triangulation_3_complex.h new file mode 100644 index 000000000000..ef4a84c6c0ea --- /dev/null +++ b/SMDS_3/include/CGAL/to_triangulation_3_complex.h @@ -0,0 +1,64 @@ +// Copyright (c) 2026 GeometryFactory (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Jane Tournois + +#ifndef CGAL_TO_TRIANGULATION_3_COMPLEX_H +#define CGAL_TO_TRIANGULATION_3_COMPLEX_H + +#include + +#include +#include + +namespace CGAL { + +/*! + * \ingroup PkgSMDS3Functions + * converts a `Mesh_complex_3_in_triangulation_3` + * to a `Mesh_complex_3_in_triangulation_3` with a `Triangulation_3` as + * underlying triangulation. + * + * @tparam Tr is the underlying triangulation of the input `Mesh_complex_3_in_triangulation_3` + * @tparam CornerIndex is the type of the corner indices + * @tparam CurveIndex is the type of the curve indices + * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" + * + * @todo + */ +template +CGAL::Mesh_complex_3_in_triangulation_3< + CGAL::Triangulation_3> +to_triangulation_3_complex( + CGAL::Mesh_complex_3_in_triangulation_3 c3t3, + const NamedParameters& np = parameters::default_values()) +{ + using GT = typename Tr::Geom_traits; + using TDS = typename Tr::Triangulation_data_structure; + using T3 = CGAL::Triangulation_3; + using C3t3 = CGAL::Mesh_complex_3_in_triangulation_3; + + T3 tr; + tr.swap(c3t3.triangulation()); + C3t3 c3t3_new; + c3t3_new.triangulation().swap(tr); + + // todo : port metadata from input c3t3 to the new one + + return c3t3_new; +} + +} // end namespace CGAL + +#endif // CGAL_TO_TRIANGULATION_3_COMPLEX_H \ No newline at end of file diff --git a/Tetrahedral_remeshing/examples/Tetrahedral_remeshing/mesh_and_remesh_c3t3.cpp b/Tetrahedral_remeshing/examples/Tetrahedral_remeshing/mesh_and_remesh_c3t3.cpp index ba0dbe1d30d2..091dec4f8758 100644 --- a/Tetrahedral_remeshing/examples/Tetrahedral_remeshing/mesh_and_remesh_c3t3.cpp +++ b/Tetrahedral_remeshing/examples/Tetrahedral_remeshing/mesh_and_remesh_c3t3.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -72,7 +73,7 @@ int main(int argc, char* argv[]) cell_radius_edge_ratio = 3, cell_size = 0.05); // Mesh generation - C3t3 c3t3 = CGAL::make_mesh_3(domain, criteria); + C3t3 c3t3_mesh_3 = CGAL::make_mesh_3(domain, criteria); // Property map of constraints Constraints_set constraints; @@ -81,7 +82,7 @@ int main(int argc, char* argv[]) Corners_set corners; Corners_pmap corners_pmap(corners); - Triangulation_3 tr = CGAL::convert_to_triangulation_3(std::move(c3t3), + auto c3t3 = CGAL::to_triangulation_3_complex(std::move(c3t3_mesh_3), edge_is_constrained_map(constraints_pmap). vertex_is_constrained_map(corners_pmap)); @@ -93,13 +94,13 @@ int main(int argc, char* argv[]) // Then the triangulation is copied and duplicated, and c3t3 remains as is. const double target_edge_length = 0.1;//coarsen the mesh - CGAL::tetrahedral_isotropic_remeshing(tr, target_edge_length, + CGAL::tetrahedral_isotropic_remeshing(c3t3, target_edge_length, number_of_iterations(5) .smooth_constrained_edges(true) .edge_is_constrained_map(constraints_pmap)); std::ofstream out("out_remeshed.mesh"); - CGAL::IO::write_MEDIT(out, tr); + CGAL::IO::write_MEDIT(out, c3t3); out.close(); return EXIT_SUCCESS; From 30db3098fc8a19605ed6c950cf72f1c8b515ae45 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 30 Jul 2026 12:53:23 +0200 Subject: [PATCH 2/2] change template parameter to C3t3 --- .../include/CGAL/to_triangulation_3_complex.h | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/SMDS_3/include/CGAL/to_triangulation_3_complex.h b/SMDS_3/include/CGAL/to_triangulation_3_complex.h index ef4a84c6c0ea..40d809660c78 100644 --- a/SMDS_3/include/CGAL/to_triangulation_3_complex.h +++ b/SMDS_3/include/CGAL/to_triangulation_3_complex.h @@ -18,7 +18,8 @@ #include #include -namespace CGAL { +namespace CGAL +{ /*! * \ingroup PkgSMDS3Functions @@ -26,34 +27,35 @@ namespace CGAL { * to a `Mesh_complex_3_in_triangulation_3` with a `Triangulation_3` as * underlying triangulation. * - * @tparam Tr is the underlying triangulation of the input `Mesh_complex_3_in_triangulation_3` + * @tparam C3t3 model of `MeshComplex_3InTriangulation_3` * @tparam CornerIndex is the type of the corner indices * @tparam CurveIndex is the type of the curve indices * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" * * @todo */ -template CGAL::Mesh_complex_3_in_triangulation_3< - CGAL::Triangulation_3> + CGAL::Triangulation_3> to_triangulation_3_complex( - CGAL::Mesh_complex_3_in_triangulation_3 c3t3, + C3t3 c3t3, const NamedParameters& np = parameters::default_values()) { - using GT = typename Tr::Geom_traits; - using TDS = typename Tr::Triangulation_data_structure; + using GT = typename C3t3::Triangulation::Geom_traits; + using TDS = typename C3t3::Triangulation::Triangulation_data_structure; + using Corner_index = typename C3t3::Corner_index; + using Curve_index = typename C3t3::Curve_index; + using T3 = CGAL::Triangulation_3; - using C3t3 = CGAL::Mesh_complex_3_in_triangulation_3; + using C3t3_new = CGAL::Mesh_complex_3_in_triangulation_3; T3 tr; tr.swap(c3t3.triangulation()); - C3t3 c3t3_new; + C3t3_new c3t3_new; c3t3_new.triangulation().swap(tr); - + // todo : port metadata from input c3t3 to the new one return c3t3_new; @@ -61,4 +63,4 @@ to_triangulation_3_complex( } // end namespace CGAL -#endif // CGAL_TO_TRIANGULATION_3_COMPLEX_H \ No newline at end of file +#endif // CGAL_TO_TRIANGULATION_3_COMPLEX_H