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..40d809660c78 --- /dev/null +++ b/SMDS_3/include/CGAL/to_triangulation_3_complex.h @@ -0,0 +1,66 @@ +// 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 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> +to_triangulation_3_complex( + C3t3 c3t3, + const NamedParameters& np = parameters::default_values()) +{ + 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_new = CGAL::Mesh_complex_3_in_triangulation_3; + + T3 tr; + tr.swap(c3t3.triangulation()); + C3t3_new 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 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;