From e86c4027af1981b271a18044445485011b012033 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 12 Jan 2021 10:57:37 +0100 Subject: [PATCH 01/79] move C3T3 headers to MDS_3 new package MDS_3 is "3D Mesh Data Structure" --- .../Mesh_complex_3_in_triangulation_3_fwd.h | 0 Installation/include/CGAL/license/MDS_3.h | 55 +++++++++++++++++++ .../include/CGAL/IO/File_medit.h | 2 +- .../include/CGAL/MDS_3}/Dump_c3t3.h | 4 +- .../Mesh_complex_3_in_triangulation_3_base.h | 0 .../include/CGAL/MDS_3}/tet_soup_to_c3t3.h | 0 .../CGAL/Mesh_complex_3_in_triangulation_3.h | 6 +- ...sh_3D_image_with_custom_initialization.cpp | 2 +- .../Mesh_3/mesh_hybrid_mesh_domain.cpp | 2 +- Mesh_3/include/CGAL/Mesh_3/Mesher_3.h | 2 +- Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h | 2 +- Mesh_3/include/CGAL/refine_mesh_3.h | 2 +- .../test/Mesh_3/test_c3t3_into_facegraph.cpp | 2 +- Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp | 2 +- .../test/Mesh_3/test_meshing_polyhedron.cpp | 2 +- .../Mesh_3/test_meshing_unit_tetrahedron.cpp | 2 +- .../Plugins/Mesh_3/C3t3_io_plugin.cpp | 2 +- .../internal/collapse_short_edges.h | 2 +- ...t_tetrahedral_remeshing_from_mesh_file.cpp | 2 +- 19 files changed, 73 insertions(+), 18 deletions(-) rename Installation/include/CGAL/{Mesh_3 => MDS_3}/Mesh_complex_3_in_triangulation_3_fwd.h (100%) create mode 100644 Installation/include/CGAL/license/MDS_3.h rename {Mesh_3 => MDS_3}/include/CGAL/IO/File_medit.h (99%) rename {Mesh_3/include/CGAL/Mesh_3 => MDS_3/include/CGAL/MDS_3}/Dump_c3t3.h (97%) rename {Mesh_3/include/CGAL/Mesh_3 => MDS_3/include/CGAL/MDS_3}/Mesh_complex_3_in_triangulation_3_base.h (100%) rename {Mesh_3/include/CGAL/Mesh_3 => MDS_3/include/CGAL/MDS_3}/tet_soup_to_c3t3.h (100%) rename {Mesh_3 => MDS_3}/include/CGAL/Mesh_complex_3_in_triangulation_3.h (99%) diff --git a/Installation/include/CGAL/Mesh_3/Mesh_complex_3_in_triangulation_3_fwd.h b/Installation/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h similarity index 100% rename from Installation/include/CGAL/Mesh_3/Mesh_complex_3_in_triangulation_3_fwd.h rename to Installation/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h diff --git a/Installation/include/CGAL/license/MDS_3.h b/Installation/include/CGAL/license/MDS_3.h new file mode 100644 index 00000000000..41a1e9194f5 --- /dev/null +++ b/Installation/include/CGAL/license/MDS_3.h @@ -0,0 +1,55 @@ +// Copyright (c) 2016 GeometryFactory SARL (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org) +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// +// Author(s) : Andreas Fabri +// +// Warning: this file is generated, see include/CGAL/licence/README.md + +#ifndef CGAL_LICENSE_MDS_3_H +#define CGAL_LICENSE_MDS_3_H + +#include +#include + +#ifdef CGAL_MDS_3_COMMERCIAL_LICENSE + +# if CGAL_MDS_3_COMMERCIAL_LICENSE < CGAL_RELEASE_DATE + +# if defined(CGAL_LICENSE_WARNING) + + CGAL_pragma_warning("Your commercial license for CGAL does not cover " + "this release of the 3D Mesh Data Structure package.") +# endif + +# ifdef CGAL_LICENSE_ERROR +# error "Your commercial license for CGAL does not cover this release \ + of the 3D Mesh Data Structure package. \ + You get this error, as you defined CGAL_LICENSE_ERROR." +# endif // CGAL_LICENSE_ERROR + +# endif // CGAL_MDS_3_COMMERCIAL_LICENSE < CGAL_RELEASE_DATE + +#else // no CGAL_MDS_3_COMMERCIAL_LICENSE + +# if defined(CGAL_LICENSE_WARNING) + CGAL_pragma_warning("\nThe macro CGAL_MDS_3_COMMERCIAL_LICENSE " + "is not defined." + "\nYou use the CGAL 3D Mesh Generation package under " + "the terms of the GPLv3+.") +# endif // CGAL_LICENSE_WARNING + +# ifdef CGAL_LICENSE_ERROR +# error "The macro CGAL_MDS_3_COMMERCIAL_LICENSE is not defined.\ + You use the CGAL 3D Mesh Data Structure package under the terms of \ + the GPLv3+. You get this error, as you defined CGAL_LICENSE_ERROR." +# endif // CGAL_LICENSE_ERROR + +#endif // no CGAL_MDS_3_COMMERCIAL_LICENSE + +#endif // CGAL_LICENSE_MDS_3_H diff --git a/Mesh_3/include/CGAL/IO/File_medit.h b/MDS_3/include/CGAL/IO/File_medit.h similarity index 99% rename from Mesh_3/include/CGAL/IO/File_medit.h rename to MDS_3/include/CGAL/IO/File_medit.h index bac7e7b2560..a7d08616b3f 100644 --- a/Mesh_3/include/CGAL/IO/File_medit.h +++ b/MDS_3/include/CGAL/IO/File_medit.h @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include diff --git a/Mesh_3/include/CGAL/Mesh_3/Dump_c3t3.h b/MDS_3/include/CGAL/MDS_3/Dump_c3t3.h similarity index 97% rename from Mesh_3/include/CGAL/Mesh_3/Dump_c3t3.h rename to MDS_3/include/CGAL/MDS_3/Dump_c3t3.h index 147d4ac59f4..bb9e11080aa 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Dump_c3t3.h +++ b/MDS_3/include/CGAL/MDS_3/Dump_c3t3.h @@ -13,12 +13,12 @@ #ifndef CGAL_MESH_3_DUMP_C3T3_H #define CGAL_MESH_3_DUMP_C3T3_H -#include +#include #include #include -#include +#include #include #include diff --git a/Mesh_3/include/CGAL/Mesh_3/Mesh_complex_3_in_triangulation_3_base.h b/MDS_3/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_base.h similarity index 100% rename from Mesh_3/include/CGAL/Mesh_3/Mesh_complex_3_in_triangulation_3_base.h rename to MDS_3/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_base.h diff --git a/Mesh_3/include/CGAL/Mesh_3/tet_soup_to_c3t3.h b/MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h similarity index 100% rename from Mesh_3/include/CGAL/Mesh_3/tet_soup_to_c3t3.h rename to MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h diff --git a/Mesh_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h similarity index 99% rename from Mesh_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h rename to MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 0eb11a1f3c6..e934cec6ce9 100644 --- a/Mesh_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -18,13 +18,13 @@ #ifndef CGAL_MESH_COMPLEX_3_IN_TRIANGULATION_3_H #define CGAL_MESH_COMPLEX_3_IN_TRIANGULATION_3_H -#include +#include -#include +#include #include #include #include -#include +#include #include #include diff --git a/Mesh_3/examples/Mesh_3/mesh_3D_image_with_custom_initialization.cpp b/Mesh_3/examples/Mesh_3/mesh_3D_image_with_custom_initialization.cpp index 7a326ee1b2f..5de1774377f 100644 --- a/Mesh_3/examples/Mesh_3/mesh_3D_image_with_custom_initialization.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_3D_image_with_custom_initialization.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include // Domain typedef CGAL::Exact_predicates_inexact_constructions_kernel K; diff --git a/Mesh_3/examples/Mesh_3/mesh_hybrid_mesh_domain.cpp b/Mesh_3/examples/Mesh_3/mesh_hybrid_mesh_domain.cpp index 7e6cc3202ed..33ab594d1f0 100644 --- a/Mesh_3/examples/Mesh_3/mesh_hybrid_mesh_domain.cpp +++ b/Mesh_3/examples/Mesh_3/mesh_hybrid_mesh_domain.cpp @@ -13,7 +13,7 @@ #include // Ouput -#include +#include // Read 1D features from input file #include "read_polylines.h" diff --git a/Mesh_3/include/CGAL/Mesh_3/Mesher_3.h b/Mesh_3/include/CGAL/Mesh_3/Mesher_3.h index 0d81d7a8455..e3f2c0c596d 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Mesher_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Mesher_3.h @@ -36,7 +36,7 @@ #include -#include +#include #include #include diff --git a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h index 25783f027d2..8c6f999d331 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Refine_facets_3.h @@ -38,7 +38,7 @@ #ifdef CGAL_MESH_3_PROFILING #include #endif -#include +#include #include #include diff --git a/Mesh_3/include/CGAL/refine_mesh_3.h b/Mesh_3/include/CGAL/refine_mesh_3.h index bba8c6c199e..30282afce45 100644 --- a/Mesh_3/include/CGAL/refine_mesh_3.h +++ b/Mesh_3/include/CGAL/refine_mesh_3.h @@ -24,11 +24,11 @@ #include #include #include -#include #include #include #include #include +#include #include diff --git a/Mesh_3/test/Mesh_3/test_c3t3_into_facegraph.cpp b/Mesh_3/test/Mesh_3/test_c3t3_into_facegraph.cpp index 6df89caf971..fd18c79ed52 100644 --- a/Mesh_3/test/Mesh_3/test_c3t3_into_facegraph.cpp +++ b/Mesh_3/test/Mesh_3/test_c3t3_into_facegraph.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include diff --git a/Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp b/Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp index 0e433bb0922..31e18de9840 100644 --- a/Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp +++ b/Mesh_3/test/Mesh_3/test_mesh_cell_base_3.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include #include diff --git a/Mesh_3/test/Mesh_3/test_meshing_polyhedron.cpp b/Mesh_3/test/Mesh_3/test_meshing_polyhedron.cpp index b758086448e..999faf85a56 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_polyhedron.cpp +++ b/Mesh_3/test/Mesh_3/test_meshing_polyhedron.cpp @@ -22,7 +22,7 @@ #include -#include +#include #include diff --git a/Mesh_3/test/Mesh_3/test_meshing_unit_tetrahedron.cpp b/Mesh_3/test/Mesh_3/test_meshing_unit_tetrahedron.cpp index 85989f0e485..8dd5fa81d70 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_unit_tetrahedron.cpp +++ b/Mesh_3/test/Mesh_3/test_meshing_unit_tetrahedron.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp index 4dfab1afc69..0972f9cc4f4 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp @@ -1,6 +1,6 @@ #include #include "Scene_c3t3_item.h" -#include +#include #include #include #include diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h index 4ce1fe25af0..99c06df497d 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include diff --git a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_tetrahedral_remeshing_from_mesh_file.cpp b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_tetrahedral_remeshing_from_mesh_file.cpp index cb748e0e92b..a00b07d21cf 100644 --- a/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_tetrahedral_remeshing_from_mesh_file.cpp +++ b/Tetrahedral_remeshing/test/Tetrahedral_remeshing/test_tetrahedral_remeshing_from_mesh_file.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel K; From f5a841892908ff813e6bbeb32beb69626889bd85 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 25 Mar 2021 14:49:26 +0100 Subject: [PATCH 02/79] add package_info --- MDS_3/package_info/MDS_3/copyright | 2 ++ MDS_3/package_info/MDS_3/dependencies | 42 ++++++++++++++++++++++++ MDS_3/package_info/MDS_3/description.txt | 2 ++ MDS_3/package_info/MDS_3/license.txt | 1 + MDS_3/package_info/MDS_3/maintainer | 2 ++ 5 files changed, 49 insertions(+) create mode 100644 MDS_3/package_info/MDS_3/copyright create mode 100644 MDS_3/package_info/MDS_3/dependencies create mode 100644 MDS_3/package_info/MDS_3/description.txt create mode 100644 MDS_3/package_info/MDS_3/license.txt create mode 100644 MDS_3/package_info/MDS_3/maintainer diff --git a/MDS_3/package_info/MDS_3/copyright b/MDS_3/package_info/MDS_3/copyright new file mode 100644 index 00000000000..8932b3233d2 --- /dev/null +++ b/MDS_3/package_info/MDS_3/copyright @@ -0,0 +1,2 @@ +INRIA Sophia-Antipolis (France) + diff --git a/MDS_3/package_info/MDS_3/dependencies b/MDS_3/package_info/MDS_3/dependencies new file mode 100644 index 00000000000..2bfb2043f8b --- /dev/null +++ b/MDS_3/package_info/MDS_3/dependencies @@ -0,0 +1,42 @@ +AABB_tree +Algebraic_foundations +Arithmetic_kernel +BGL +CGAL_ImageIO +Cartesian_kernel +Circulator +Convex_hull_2 +Distance_2 +Distance_3 +Filtered_kernel +Generator +HalfedgeDS +Hash_map +Homogeneous_kernel +Installation +Intersections_2 +Intersections_3 +Interval_support +Kernel_23 +Kernel_d +Mesh_3 +Mesher_level +Modifier +Modular_arithmetic +Number_types +Polygon +Polygon_mesh_processing +Polyhedron +Principal_component_analysis +Principal_component_analysis_LGPL +Profiling_tools +Property_map +Random_numbers +STL_Extension +Solver_interface +Spatial_searching +Spatial_sorting +Stream_support +TDS_3 +Triangulation_3 +Union_find diff --git a/MDS_3/package_info/MDS_3/description.txt b/MDS_3/package_info/MDS_3/description.txt new file mode 100644 index 00000000000..7a83f60476c --- /dev/null +++ b/MDS_3/package_info/MDS_3/description.txt @@ -0,0 +1,2 @@ +Package MDS_3 : +Mesh Data Structures for dimension <=3 \ No newline at end of file diff --git a/MDS_3/package_info/MDS_3/license.txt b/MDS_3/package_info/MDS_3/license.txt new file mode 100644 index 00000000000..8bb8efcb72b --- /dev/null +++ b/MDS_3/package_info/MDS_3/license.txt @@ -0,0 +1 @@ +GPL (v3 or later) diff --git a/MDS_3/package_info/MDS_3/maintainer b/MDS_3/package_info/MDS_3/maintainer new file mode 100644 index 00000000000..880cb264269 --- /dev/null +++ b/MDS_3/package_info/MDS_3/maintainer @@ -0,0 +1,2 @@ +Laurent Rineau +Jane Tournois From e4334b3d86cf4a8e53a7e5782508670100937ed8 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 25 Mar 2021 16:11:52 +0100 Subject: [PATCH 03/79] init examples directory --- MDS_3/examples/MDS_3/CMakeLists.txt | 21 +++++++++++++++++++ MDS_3/examples/MDS_3/c3t3_example.cpp | 29 +++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 MDS_3/examples/MDS_3/CMakeLists.txt create mode 100644 MDS_3/examples/MDS_3/c3t3_example.cpp diff --git a/MDS_3/examples/MDS_3/CMakeLists.txt b/MDS_3/examples/MDS_3/CMakeLists.txt new file mode 100644 index 00000000000..4b911246120 --- /dev/null +++ b/MDS_3/examples/MDS_3/CMakeLists.txt @@ -0,0 +1,21 @@ +# Created by the script cgal_create_CMakeLists +# This is the CMake script for compiling a set of CGAL applications. + +cmake_minimum_required(VERSION 3.1...3.14) + +project(MDS_3_Examples) + +# CGAL and its components +find_package(CGAL REQUIRED) + +# Boost and its components +find_package(Boost REQUIRED) +if(NOT Boost_FOUND) + message( + STATUS "This project requires the Boost library, and will not be compiled.") + return() +endif() + +# Creating entries for all C++ files with "main" routine +# ########################################################## +create_single_source_cgal_program( "c3t3_example.cpp" ) diff --git a/MDS_3/examples/MDS_3/c3t3_example.cpp b/MDS_3/examples/MDS_3/c3t3_example.cpp new file mode 100644 index 00000000000..f5a4e2c31a7 --- /dev/null +++ b/MDS_3/examples/MDS_3/c3t3_example.cpp @@ -0,0 +1,29 @@ +#include + +#include +#include +#include + +#include + +#include + +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; + +typedef CGAL::Tetrahedral_remeshing::Remeshing_triangulation_3 Remeshing_triangulation; + +int main(int argc, char* argv[]) +{ + const char* filename = (argc > 1) ? argv[1] : "data/sphere.mesh"; + + Remeshing_triangulation tr; + + std::ifstream is(filename, std::ios_base::in); + CGAL::read_MEDIT(is, tr); + + + std::ofstream os("after_remeshing.mesh"); + CGAL::write_MEDIT(os, tr); + + return EXIT_SUCCESS; +} From ecb3434364c73d46a25b80cb5f7dc6cffec6701c Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 25 Mar 2021 16:12:11 +0100 Subject: [PATCH 04/79] change Mesh_3 to MDS_3 --- .../include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h | 2 +- MDS_3/include/CGAL/IO/File_medit.h | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Installation/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h b/Installation/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h index d0202553abc..b9fa9e23de0 100644 --- a/Installation/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h +++ b/Installation/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h @@ -11,7 +11,7 @@ #define CGAL_MESH_3_MESH_COMPLEX_3_IN_TRIANGULATION_3_FWD_H /// \file Mesh_complex_3_in_triangulation_3_fwd.h -/// Forward declarations of the Mesh_3 package. +/// Forward declarations of the MDS_3 package. #ifndef DOXYGEN_RUNNING namespace CGAL { diff --git a/MDS_3/include/CGAL/IO/File_medit.h b/MDS_3/include/CGAL/IO/File_medit.h index a7d08616b3f..c7aae3ad51b 100644 --- a/MDS_3/include/CGAL/IO/File_medit.h +++ b/MDS_3/include/CGAL/IO/File_medit.h @@ -14,9 +14,8 @@ #ifndef CGAL_IO_FILE_MEDIT_H #define CGAL_IO_FILE_MEDIT_H -#include +#include -#include #include #include From 7282b10f64c06e07139db6744c2fdd0d881cc566 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 29 Mar 2021 14:32:02 +0200 Subject: [PATCH 05/79] WIP MDS_3 package --- .../MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h | 6 +++--- MDS_3/doc/MDS_3/Doxyfile.in | 14 ++++++++++++++ MDS_3/doc/MDS_3/dependencies | 11 +++++++++++ MDS_3/doc/MDS_3/examples.txt | 3 +++ MDS_3/examples/MDS_3/c3t3_example.cpp | 3 ++- 5 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 MDS_3/doc/MDS_3/Doxyfile.in create mode 100644 MDS_3/doc/MDS_3/dependencies create mode 100644 MDS_3/doc/MDS_3/examples.txt diff --git a/Installation/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h b/Installation/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h index b9fa9e23de0..9dc5d8a794f 100644 --- a/Installation/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h +++ b/Installation/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h @@ -7,8 +7,8 @@ // SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial // -#ifndef CGAL_MESH_3_MESH_COMPLEX_3_IN_TRIANGULATION_3_FWD_H -#define CGAL_MESH_3_MESH_COMPLEX_3_IN_TRIANGULATION_3_FWD_H +#ifndef CGAL_MDS_3_MESH_COMPLEX_3_IN_TRIANGULATION_3_FWD_H +#define CGAL_MDS_3_MESH_COMPLEX_3_IN_TRIANGULATION_3_FWD_H /// \file Mesh_complex_3_in_triangulation_3_fwd.h /// Forward declarations of the MDS_3 package. @@ -33,6 +33,6 @@ bool build_triangulation_from_file(std::istream& is, } // CGAL #endif -#endif /* CGAL_MESH_3_MESH_COMPLEX_3_IN_TRIANGULATION_3_FWD_H */ +#endif /* CGAL_MDS_3_MESH_COMPLEX_3_IN_TRIANGULATION_3_FWD_H */ diff --git a/MDS_3/doc/MDS_3/Doxyfile.in b/MDS_3/doc/MDS_3/Doxyfile.in new file mode 100644 index 00000000000..abb8090bb24 --- /dev/null +++ b/MDS_3/doc/MDS_3/Doxyfile.in @@ -0,0 +1,14 @@ +@INCLUDE = ${CGAL_DOC_PACKAGE_DEFAULTS} + +# macros to be used inside the code +#ALIASES += "cgalDescribePolylineType=A polyline is defined as a sequence of points, each pair of contiguous points defines a segment of the polyline. If the first and last points of the polyline are identical, the polyline is closed." + +#INPUT += \ + # ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/Polyhedral_complex_mesh_domain_3.h \ + # ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/Mesh_domain_with_polyline_features_3.h + +PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - 3D Mesh Data Structures" +HTML_EXTRA_FILES = ${CGAL_PACKAGE_DOC_DIR}/fig/c3t3.jpg \ +# ${CGAL_PACKAGE_DOC_DIR}/fig/no-protection-complex.png + +EXAMPLE_PATH += ${CGAL_PACKAGE_INCLUDE_DIR} diff --git a/MDS_3/doc/MDS_3/dependencies b/MDS_3/doc/MDS_3/dependencies new file mode 100644 index 00000000000..27855395ad3 --- /dev/null +++ b/MDS_3/doc/MDS_3/dependencies @@ -0,0 +1,11 @@ +Manual +Kernel_23 +STL_Extension +Algebraic_foundations +BGL +Stream_support +Triangulation_3 +Periodic_3_triangulation_3 +TDS_3 +Polyhedron +Miscellany diff --git a/MDS_3/doc/MDS_3/examples.txt b/MDS_3/doc/MDS_3/examples.txt new file mode 100644 index 00000000000..03c1706466f --- /dev/null +++ b/MDS_3/doc/MDS_3/examples.txt @@ -0,0 +1,3 @@ +/*! +\example MDS_3/c3t3_example.cpp +*/ diff --git a/MDS_3/examples/MDS_3/c3t3_example.cpp b/MDS_3/examples/MDS_3/c3t3_example.cpp index f5a4e2c31a7..22f8e650506 100644 --- a/MDS_3/examples/MDS_3/c3t3_example.cpp +++ b/MDS_3/examples/MDS_3/c3t3_example.cpp @@ -1,10 +1,11 @@ #include #include -#include + #include #include +#include #include From fa37faf42e79328e0c64985bc44e445ed8fff43f Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 20 Apr 2021 17:18:05 +0200 Subject: [PATCH 06/79] add doc --- MDS_3/doc/MDS_3/MDS_3.txt | 27 ++++++++++++ MDS_3/doc/MDS_3/PackageDescription.txt | 59 ++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 MDS_3/doc/MDS_3/MDS_3.txt create mode 100644 MDS_3/doc/MDS_3/PackageDescription.txt diff --git a/MDS_3/doc/MDS_3/MDS_3.txt b/MDS_3/doc/MDS_3/MDS_3.txt new file mode 100644 index 00000000000..d9978f0a0ab --- /dev/null +++ b/MDS_3/doc/MDS_3/MDS_3.txt @@ -0,0 +1,27 @@ +namespace CGAL { +/*! + +\mainpage User Manual +\anchor Chapter_3D_Mesh_Data_Structure +\anchor userchaptermds3 +\authors Pierre Alliez, Clément Jamin, Laurent Rineau, Stéphane Tayeb, Jane Tournois, Mariette Yvinec +\cgalAutoToc + +\cgalFigureBegin{figuremultilabel_mesher,multilabel_mesher.jpg} +Cut-view of a multi-domain 3D mesh generated from a segmented image. +\cgalFigureEnd + +\section MDS_3_section_intro Introduction + +This package is devoted to the representation of 3-Dimensional Mesh Data Structures. +The domain to be meshed is a subset of 3D space, required to be bounded. + + +\subsection MDS_3ImplementationHistory Implementation History + +The code of the package `MDS_3` was initially part of the package `Mesh_3`. +With the meshing processes becoming more versatile, it was moved to its own package in the +release 5.4 of \cgal. + +*/ +} /* namespace CGAL */ diff --git a/MDS_3/doc/MDS_3/PackageDescription.txt b/MDS_3/doc/MDS_3/PackageDescription.txt new file mode 100644 index 00000000000..596e353e11b --- /dev/null +++ b/MDS_3/doc/MDS_3/PackageDescription.txt @@ -0,0 +1,59 @@ +/// \defgroup PkgMDS3Ref 3D Mesh Data Structures Reference + +/// \defgroup PkgMDS3Concepts Concepts +/// \ingroup PkgMDS3Ref +/// The main concepts of this package. + +/// \defgroup PkgMDS3Classes Classes +/// \ingroup PkgMDS3Ref +/// The classes in this group are the main classes involved . + +/// \defgroup PkgMDS3Functions Functions +/// \ingroup PkgMDS3Ref +/// The functions to work with the 3D mesh data structures. + +/// \defgroup PkgMDS3IOFunctions Input/Output Functions +/// \ingroup PkgMDS3Ref +/// The free functions that can be used to read and write meshes. + +/*! +\addtogroup PkgMDS3Ref +\todo check generated documentation +\cgalPkgDescriptionBegin{3D Mesh Data Structures,PkgMDS3} +\todo add pkg picture +\cgalPkgPicture{MDS_3/fig/c3t3.jpg} +\cgalPkgSummaryBegin +\cgalPkgAuthors{Pierre Alliez, Clément Jamin, Laurent Rineau, Stéphane Tayeb, Jane Tournois, Mariette Yvinec} +\cgalPkgDesc{This package is devoted to the description of 3D Mesh Data Structures.} +\cgalPkgManuals{Chapter_3D_Mesh_Data_Structures,PkgMDS3Ref} +\cgalPkgSummaryEnd +\cgalPkgShortInfoBegin +\cgalPkgSince{5.3} +\cgalPkgDependsOn{\ref PkgTriangulation3} +\cgalPkgLicense{\ref licensesGPL "GPL"} +\cgalPkgDemo{Polyhedron demo,polyhedron_3.zip} +\cgalPkgShortInfoEnd +\cgalPkgDescriptionEnd + +\cgalClassifedRefPages + +\cgalCRPSection{Concepts} + +Here are the main concepts of this package: + +- `MeshComplex_3InTriangulation_3` +- `MeshComplexWithFeatures_3InTriangulation_3` + +\cgalCRPSection{Classes} + +- `CGAL::Mesh_complex_3_in_triangulation_3` + +\cgalCRPSection{Function Templates} + +- `CGAL::facets_in_complex_3_to_triangle_mesh()` + +\cgalCRPSection{Input/Output Functions} +- `CGAL::output_to_medit()` +- `CGAL::output_to_vtu()` +*/ + From 4575d8919c9d0770b113ddf9947233dbf407c28a Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 20 Apr 2021 17:28:04 +0200 Subject: [PATCH 07/79] move concept --- .../doc/MDS_3}/Concepts/MeshComplex_3InTriangulation_3.h | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {Mesh_3/doc/Mesh_3 => MDS_3/doc/MDS_3}/Concepts/MeshComplex_3InTriangulation_3.h (100%) diff --git a/Mesh_3/doc/Mesh_3/Concepts/MeshComplex_3InTriangulation_3.h b/MDS_3/doc/MDS_3/Concepts/MeshComplex_3InTriangulation_3.h similarity index 100% rename from Mesh_3/doc/Mesh_3/Concepts/MeshComplex_3InTriangulation_3.h rename to MDS_3/doc/MDS_3/Concepts/MeshComplex_3InTriangulation_3.h From e0335e3e5e99ecc1194f6b60c1efb64ff0ce5732 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 23 Apr 2021 13:54:37 +0200 Subject: [PATCH 08/79] move everything about C3t3 to new package MDS_3 --- .../doc/MDS_3}/CGAL/IO/File_avizo.h | 0 .../doc/MDS_3}/CGAL/IO/File_medit.h | 0 .../doc/MDS_3}/CGAL/IO/File_tetgen.h | 0 .../IO/facets_in_complex_3_to_triangle_mesh.h | 0 .../doc/MDS_3}/CGAL/IO/output_to_vtu.h | 0 .../CGAL/Mesh_complex_3_in_triangulation_3.h | 0 ...shComplexWithFeatures_3InTriangulation_3.h | 0 MDS_3/doc/MDS_3/MDS_3.txt | 16 ++++++ .../IO/Complex_3_in_triangulation_3_to_vtk.h | 0 .../include/CGAL/IO/File_avizo.h | 0 .../include/CGAL/IO/File_binary_mesh_3.h | 4 +- {Mesh_3 => MDS_3}/include/CGAL/IO/File_maya.h | 0 .../include/CGAL/IO/File_tetgen.h | 0 .../IO/facets_in_complex_3_to_triangle_mesh.h | 0 .../include/CGAL/IO/output_to_vtu.h | 0 MDS_3/include/CGAL/MDS_3/Dump_c3t3.h | 2 +- .../Mesh_complex_3_in_triangulation_3_base.h | 12 ++--- .../include/CGAL/MDS_3}/io_signature.h | 0 .../include/CGAL/MDS_3}/utilities.h | 12 ++--- .../CGAL/Mesh_complex_3_in_triangulation_3.h | 16 +++--- ...n_of_complex_3_in_triangulation_3_to_off.h | 0 .../MDS_3}/Handle_IO_for_pair_of_int.h | 2 +- MDS_3/test/MDS_3/CMakeLists.txt | 36 +++++++++++++ .../Mesh_3 => MDS_3/test/MDS_3}/test_c3t3.cpp | 4 +- ...est_c3t3_extract_subdomains_boundaries.cpp | 0 .../test/MDS_3}/test_c3t3_into_facegraph.cpp | 0 .../test/MDS_3}/test_c3t3_io.cpp | 2 +- .../test/MDS_3}/test_c3t3_with_features.cpp | 0 MDS_3/test/MDS_3/test_utilities.h | 51 +++++++++++++++++++ Mesh_3/doc/Mesh_3/PackageDescription.txt | 7 --- Mesh_3/doc/Mesh_3/dependencies | 2 + .../include/CGAL/Compact_mesh_cell_base_3.h | 2 +- Mesh_3/include/CGAL/Labeled_mesh_domain_3.h | 2 +- .../CGAL/Mesh_3/Mesh_surface_cell_base_3.h | 2 +- .../CGAL/Mesh_3/Protect_edges_sizing_field.h | 6 +-- Mesh_3/include/CGAL/Mesh_cell_base_3.h | 2 +- Mesh_3/include/CGAL/Mesh_triangulation_3.h | 2 +- Mesh_3/include/CGAL/Mesh_vertex_base_3.h | 2 +- .../include/CGAL/Polyhedral_mesh_domain_3.h | 2 +- Mesh_3/test/Mesh_3/CMakeLists.txt | 10 ---- .../test/Mesh_3/test_meshing_polyhedron.cpp | 2 +- 41 files changed, 143 insertions(+), 55 deletions(-) rename {Mesh_3/doc/Mesh_3 => MDS_3/doc/MDS_3}/CGAL/IO/File_avizo.h (100%) rename {Mesh_3/doc/Mesh_3 => MDS_3/doc/MDS_3}/CGAL/IO/File_medit.h (100%) rename {Mesh_3/doc/Mesh_3 => MDS_3/doc/MDS_3}/CGAL/IO/File_tetgen.h (100%) rename {Mesh_3/doc/Mesh_3 => MDS_3/doc/MDS_3}/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h (100%) rename {Mesh_3/doc/Mesh_3 => MDS_3/doc/MDS_3}/CGAL/IO/output_to_vtu.h (100%) rename {Mesh_3/doc/Mesh_3 => MDS_3/doc/MDS_3}/CGAL/Mesh_complex_3_in_triangulation_3.h (100%) rename {Mesh_3/doc/Mesh_3 => MDS_3/doc/MDS_3}/Concepts/MeshComplexWithFeatures_3InTriangulation_3.h (100%) rename {Mesh_3 => MDS_3}/include/CGAL/IO/Complex_3_in_triangulation_3_to_vtk.h (100%) rename {Mesh_3 => MDS_3}/include/CGAL/IO/File_avizo.h (100%) rename {Mesh_3 => MDS_3}/include/CGAL/IO/File_binary_mesh_3.h (95%) rename {Mesh_3 => MDS_3}/include/CGAL/IO/File_maya.h (100%) rename {Mesh_3 => MDS_3}/include/CGAL/IO/File_tetgen.h (100%) rename {Mesh_3 => MDS_3}/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h (100%) rename {Mesh_3 => MDS_3}/include/CGAL/IO/output_to_vtu.h (100%) rename {Mesh_3/include/CGAL/Mesh_3 => MDS_3/include/CGAL/MDS_3}/io_signature.h (100%) rename {Mesh_3/include/CGAL/Mesh_3 => MDS_3/include/CGAL/MDS_3}/utilities.h (93%) rename {Mesh_3/include/CGAL/internal/Mesh_3 => MDS_3/include/CGAL/internal/MDS_3}/Boundary_of_subdomain_of_complex_3_in_triangulation_3_to_off.h (100%) rename {Mesh_3/include/CGAL/internal/Mesh_3 => MDS_3/include/CGAL/internal/MDS_3}/Handle_IO_for_pair_of_int.h (98%) create mode 100644 MDS_3/test/MDS_3/CMakeLists.txt rename {Mesh_3/test/Mesh_3 => MDS_3/test/MDS_3}/test_c3t3.cpp (99%) rename {Mesh_3/test/Mesh_3 => MDS_3/test/MDS_3}/test_c3t3_extract_subdomains_boundaries.cpp (100%) rename {Mesh_3/test/Mesh_3 => MDS_3/test/MDS_3}/test_c3t3_into_facegraph.cpp (100%) rename {Mesh_3/test/Mesh_3 => MDS_3/test/MDS_3}/test_c3t3_io.cpp (99%) rename {Mesh_3/test/Mesh_3 => MDS_3/test/MDS_3}/test_c3t3_with_features.cpp (100%) create mode 100644 MDS_3/test/MDS_3/test_utilities.h diff --git a/Mesh_3/doc/Mesh_3/CGAL/IO/File_avizo.h b/MDS_3/doc/MDS_3/CGAL/IO/File_avizo.h similarity index 100% rename from Mesh_3/doc/Mesh_3/CGAL/IO/File_avizo.h rename to MDS_3/doc/MDS_3/CGAL/IO/File_avizo.h diff --git a/Mesh_3/doc/Mesh_3/CGAL/IO/File_medit.h b/MDS_3/doc/MDS_3/CGAL/IO/File_medit.h similarity index 100% rename from Mesh_3/doc/Mesh_3/CGAL/IO/File_medit.h rename to MDS_3/doc/MDS_3/CGAL/IO/File_medit.h diff --git a/Mesh_3/doc/Mesh_3/CGAL/IO/File_tetgen.h b/MDS_3/doc/MDS_3/CGAL/IO/File_tetgen.h similarity index 100% rename from Mesh_3/doc/Mesh_3/CGAL/IO/File_tetgen.h rename to MDS_3/doc/MDS_3/CGAL/IO/File_tetgen.h diff --git a/Mesh_3/doc/Mesh_3/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h b/MDS_3/doc/MDS_3/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h similarity index 100% rename from Mesh_3/doc/Mesh_3/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h rename to MDS_3/doc/MDS_3/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h diff --git a/Mesh_3/doc/Mesh_3/CGAL/IO/output_to_vtu.h b/MDS_3/doc/MDS_3/CGAL/IO/output_to_vtu.h similarity index 100% rename from Mesh_3/doc/Mesh_3/CGAL/IO/output_to_vtu.h rename to MDS_3/doc/MDS_3/CGAL/IO/output_to_vtu.h diff --git a/Mesh_3/doc/Mesh_3/CGAL/Mesh_complex_3_in_triangulation_3.h b/MDS_3/doc/MDS_3/CGAL/Mesh_complex_3_in_triangulation_3.h similarity index 100% rename from Mesh_3/doc/Mesh_3/CGAL/Mesh_complex_3_in_triangulation_3.h rename to MDS_3/doc/MDS_3/CGAL/Mesh_complex_3_in_triangulation_3.h diff --git a/Mesh_3/doc/Mesh_3/Concepts/MeshComplexWithFeatures_3InTriangulation_3.h b/MDS_3/doc/MDS_3/Concepts/MeshComplexWithFeatures_3InTriangulation_3.h similarity index 100% rename from Mesh_3/doc/Mesh_3/Concepts/MeshComplexWithFeatures_3InTriangulation_3.h rename to MDS_3/doc/MDS_3/Concepts/MeshComplexWithFeatures_3InTriangulation_3.h diff --git a/MDS_3/doc/MDS_3/MDS_3.txt b/MDS_3/doc/MDS_3/MDS_3.txt index d9978f0a0ab..0fb6558590d 100644 --- a/MDS_3/doc/MDS_3/MDS_3.txt +++ b/MDS_3/doc/MDS_3/MDS_3.txt @@ -17,6 +17,22 @@ This package is devoted to the representation of 3-Dimensional Mesh Data Structu The domain to be meshed is a subset of 3D space, required to be bounded. +//The template parameter `C3T3` is required to be a model of +//the concept +//`MeshComplex_3InTriangulation_3`, a data structure devised to +//represent a three dimensional complex embedded in a 3D +//triangulation. In both functions, an instance of type `C3T3` is used to maintain the current +//approximating simplicial mesh +//and to represent the final 3D mesh at the end +//of the procedure. +// +//The embedding 3D triangulation is required to be the nested type +//`CGAL::Mesh_triangulation_3::type`, provided by the class template +//`CGAL::Mesh_triangulation_3`. The type for this triangulation is a +//wrapper around the class `CGAL::Regular_triangulation_3` whose vertex and cell base classes +//are respectively models of the concepts `MeshVertexBase_3` and +//`MeshCellBase_3`. + \subsection MDS_3ImplementationHistory Implementation History The code of the package `MDS_3` was initially part of the package `Mesh_3`. diff --git a/Mesh_3/include/CGAL/IO/Complex_3_in_triangulation_3_to_vtk.h b/MDS_3/include/CGAL/IO/Complex_3_in_triangulation_3_to_vtk.h similarity index 100% rename from Mesh_3/include/CGAL/IO/Complex_3_in_triangulation_3_to_vtk.h rename to MDS_3/include/CGAL/IO/Complex_3_in_triangulation_3_to_vtk.h diff --git a/Mesh_3/include/CGAL/IO/File_avizo.h b/MDS_3/include/CGAL/IO/File_avizo.h similarity index 100% rename from Mesh_3/include/CGAL/IO/File_avizo.h rename to MDS_3/include/CGAL/IO/File_avizo.h diff --git a/Mesh_3/include/CGAL/IO/File_binary_mesh_3.h b/MDS_3/include/CGAL/IO/File_binary_mesh_3.h similarity index 95% rename from Mesh_3/include/CGAL/IO/File_binary_mesh_3.h rename to MDS_3/include/CGAL/IO/File_binary_mesh_3.h index 52ac49d057b..a0198d49402 100644 --- a/Mesh_3/include/CGAL/IO/File_binary_mesh_3.h +++ b/MDS_3/include/CGAL/IO/File_binary_mesh_3.h @@ -13,13 +13,13 @@ #ifndef CGAL_IO_FILE_BINARY_MESH_3_H #define CGAL_IO_FILE_BINARY_MESH_3_H -#include +#include #include #include #include -#include +#include namespace CGAL { diff --git a/Mesh_3/include/CGAL/IO/File_maya.h b/MDS_3/include/CGAL/IO/File_maya.h similarity index 100% rename from Mesh_3/include/CGAL/IO/File_maya.h rename to MDS_3/include/CGAL/IO/File_maya.h diff --git a/Mesh_3/include/CGAL/IO/File_tetgen.h b/MDS_3/include/CGAL/IO/File_tetgen.h similarity index 100% rename from Mesh_3/include/CGAL/IO/File_tetgen.h rename to MDS_3/include/CGAL/IO/File_tetgen.h diff --git a/Mesh_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h b/MDS_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h similarity index 100% rename from Mesh_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h rename to MDS_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h diff --git a/Mesh_3/include/CGAL/IO/output_to_vtu.h b/MDS_3/include/CGAL/IO/output_to_vtu.h similarity index 100% rename from Mesh_3/include/CGAL/IO/output_to_vtu.h rename to MDS_3/include/CGAL/IO/output_to_vtu.h diff --git a/MDS_3/include/CGAL/MDS_3/Dump_c3t3.h b/MDS_3/include/CGAL/MDS_3/Dump_c3t3.h index bb9e11080aa..de57437424f 100644 --- a/MDS_3/include/CGAL/MDS_3/Dump_c3t3.h +++ b/MDS_3/include/CGAL/MDS_3/Dump_c3t3.h @@ -17,7 +17,7 @@ #include -#include +#include #include #include diff --git a/MDS_3/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_base.h b/MDS_3/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_base.h index 618d8c51b8b..093a639a589 100644 --- a/MDS_3/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_base.h +++ b/MDS_3/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_base.h @@ -24,12 +24,12 @@ #include -#include +#include #include #include #include #include -#include +#include #include #include @@ -70,7 +70,7 @@ namespace CGAL { #endif namespace CGAL { -namespace Mesh_3 { +namespace MDS_3 { namespace details { @@ -110,7 +110,7 @@ namespace Mesh_3 { }; // end class template C3t3_helper_class - } // end namespace Mesh_3::details + } // end namespace MDS_3::details /** * @class Mesh_complex_3_in_triangulation_3_base @@ -675,7 +675,7 @@ private: // Traversal //------------------------------------------------------- private: - typedef Mesh_3::internal::Iterator_not_in_complex Iterator_not_in_complex; + typedef MDS_3::internal::Iterator_not_in_complex Iterator_not_in_complex; class Facet_iterator_not_in_complex { @@ -1136,7 +1136,7 @@ rescan_after_load_of_triangulation() { } } -} // end namespace Mesh_3 +} // end namespace MDS_3 } // end namespace CGAL #include diff --git a/Mesh_3/include/CGAL/Mesh_3/io_signature.h b/MDS_3/include/CGAL/MDS_3/io_signature.h similarity index 100% rename from Mesh_3/include/CGAL/Mesh_3/io_signature.h rename to MDS_3/include/CGAL/MDS_3/io_signature.h diff --git a/Mesh_3/include/CGAL/Mesh_3/utilities.h b/MDS_3/include/CGAL/MDS_3/utilities.h similarity index 93% rename from Mesh_3/include/CGAL/Mesh_3/utilities.h rename to MDS_3/include/CGAL/MDS_3/utilities.h index 5e49f7a617e..02bbd8454f1 100644 --- a/Mesh_3/include/CGAL/Mesh_3/utilities.h +++ b/MDS_3/include/CGAL/MDS_3/utilities.h @@ -14,10 +14,10 @@ // File Description : //****************************************************************************** -#ifndef CGAL_MESH_3_UTILITIES_H -#define CGAL_MESH_3_UTILITIES_H +#ifndef CGAL_MDS_3_UTILITIES_H +#define CGAL_MDS_3_UTILITIES_H -#include +#include #include #include @@ -25,7 +25,7 @@ #include namespace CGAL { -namespace Mesh_3 { +namespace MDS_3 { namespace internal { struct Debug_messages_tools { @@ -115,7 +115,7 @@ public: } // end namespace internal -} // end namespace Mesh_3 +} // end namespace MDS_3 } //namespace CGAL -#endif // CGAL_MESH_3_UTILITIES_H +#endif // CGAL_MDS_3_UTILITIES_H diff --git a/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index e934cec6ce9..36c98d89222 100644 --- a/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -23,9 +23,9 @@ #include #include #include -#include +#include #include -#include +#include #include #include @@ -42,9 +42,9 @@ template class Mesh_complex_3_in_triangulation_3 : - public Mesh_3::Mesh_complex_3_in_triangulation_3_base< + public MDS_3::Mesh_complex_3_in_triangulation_3_base< Tr, typename Tr::Concurrency_tag> - , public CGAL::Mesh_3::internal::Debug_messages_tools + , public CGAL::MDS_3::internal::Debug_messages_tools { public: typedef typename Tr::Concurrency_tag Concurrency_tag; @@ -52,7 +52,7 @@ public: private: typedef Mesh_complex_3_in_triangulation_3< Tr,CornerIndex,CurveIndex> Self; - typedef Mesh_3::Mesh_complex_3_in_triangulation_3_base< + typedef MDS_3::Mesh_complex_3_in_triangulation_3_base< Tr,Concurrency_tag> Base; public: @@ -454,7 +454,7 @@ private: // Iterator type to get the first element of pair typedef boost::transform_iterator < - Mesh_3::internal::First_of, + MDS_3::internal::First_of, Vertex_map_filter_iterator > Vertex_map_iterator_first; // Iterator type to remove a level of referencing @@ -775,7 +775,7 @@ operator<< (std::ostream& os, // TODO: implement edge saving typedef typename Mesh_complex_3_in_triangulation_3::Concurrency_tag Concurrency_tag; return os << static_cast< - const Mesh_3::Mesh_complex_3_in_triangulation_3_base&>(c3t3); + const MDS_3::Mesh_complex_3_in_triangulation_3_base&>(c3t3); } @@ -787,7 +787,7 @@ operator>> (std::istream& is, // TODO: implement edge loading typedef typename Mesh_complex_3_in_triangulation_3::Concurrency_tag Concurrency_tag; is >> static_cast< - Mesh_3::Mesh_complex_3_in_triangulation_3_base&>(c3t3); + MDS_3::Mesh_complex_3_in_triangulation_3_base&>(c3t3); c3t3.rescan_after_load_of_triangulation(); return is; } diff --git a/Mesh_3/include/CGAL/internal/Mesh_3/Boundary_of_subdomain_of_complex_3_in_triangulation_3_to_off.h b/MDS_3/include/CGAL/internal/MDS_3/Boundary_of_subdomain_of_complex_3_in_triangulation_3_to_off.h similarity index 100% rename from Mesh_3/include/CGAL/internal/Mesh_3/Boundary_of_subdomain_of_complex_3_in_triangulation_3_to_off.h rename to MDS_3/include/CGAL/internal/MDS_3/Boundary_of_subdomain_of_complex_3_in_triangulation_3_to_off.h diff --git a/Mesh_3/include/CGAL/internal/Mesh_3/Handle_IO_for_pair_of_int.h b/MDS_3/include/CGAL/internal/MDS_3/Handle_IO_for_pair_of_int.h similarity index 98% rename from Mesh_3/include/CGAL/internal/Mesh_3/Handle_IO_for_pair_of_int.h rename to MDS_3/include/CGAL/internal/MDS_3/Handle_IO_for_pair_of_int.h index 7def0a39e9b..0520ca92ea1 100644 --- a/Mesh_3/include/CGAL/internal/Mesh_3/Handle_IO_for_pair_of_int.h +++ b/MDS_3/include/CGAL/internal/MDS_3/Handle_IO_for_pair_of_int.h @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include #include diff --git a/MDS_3/test/MDS_3/CMakeLists.txt b/MDS_3/test/MDS_3/CMakeLists.txt new file mode 100644 index 00000000000..697236746d3 --- /dev/null +++ b/MDS_3/test/MDS_3/CMakeLists.txt @@ -0,0 +1,36 @@ +# Created by the script cgal_create_cmake_script +# This is the CMake script for compiling a CGAL application. + +cmake_minimum_required(VERSION 3.1...3.15) +project( MDS_3_Tests ) + +if(POLICY CMP0074) + cmake_policy(SET CMP0074 NEW) +endif() + +find_package(CGAL REQUIRED) + +# Use Eigen +find_package(Eigen3 3.1.0 REQUIRED) #(3.1.0 or greater) +include(CGAL_Eigen3_support) +if (NOT TARGET CGAL::Eigen3_support) + message(STATUS "This project requires the Eigen library, and will not be compiled.") + return() +endif() + +create_single_source_cgal_program( "test_c3t3.cpp" ) +create_single_source_cgal_program( "test_c3t3_io.cpp" ) +create_single_source_cgal_program( "test_c3t3_with_features.cpp" ) +create_single_source_cgal_program( "test_c3t3_into_facegraph.cpp" ) +create_single_source_cgal_program( "test_c3t3_extract_subdomains_boundaries.cpp" ) + +foreach(target + test_c3t3 + test_c3t3_io + test_c3t3_with_features + test_c3t3_into_facegraph + test_c3t3_extract_subdomains_boundaries) + if(TARGET ${target}) + target_link_libraries(${target} PUBLIC CGAL::Eigen3_support) + endif() +endforeach() diff --git a/Mesh_3/test/Mesh_3/test_c3t3.cpp b/MDS_3/test/MDS_3/test_c3t3.cpp similarity index 99% rename from Mesh_3/test/Mesh_3/test_c3t3.cpp rename to MDS_3/test/MDS_3/test_c3t3.cpp index 7e4828a460d..a20a8ba74c2 100644 --- a/Mesh_3/test/Mesh_3/test_c3t3.cpp +++ b/MDS_3/test/MDS_3/test_c3t3.cpp @@ -37,9 +37,9 @@ struct Tester typedef typename CGAL::Mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; - typedef CGAL::Mesh_3::Mesh_complex_3_in_triangulation_3_base C3t3_base_sequential; - typedef CGAL::Mesh_3::Mesh_complex_3_in_triangulation_3_base C3t3_base_parallel; typedef typename Tr::Bare_point Bare_point; diff --git a/Mesh_3/test/Mesh_3/test_c3t3_extract_subdomains_boundaries.cpp b/MDS_3/test/MDS_3/test_c3t3_extract_subdomains_boundaries.cpp similarity index 100% rename from Mesh_3/test/Mesh_3/test_c3t3_extract_subdomains_boundaries.cpp rename to MDS_3/test/MDS_3/test_c3t3_extract_subdomains_boundaries.cpp diff --git a/Mesh_3/test/Mesh_3/test_c3t3_into_facegraph.cpp b/MDS_3/test/MDS_3/test_c3t3_into_facegraph.cpp similarity index 100% rename from Mesh_3/test/Mesh_3/test_c3t3_into_facegraph.cpp rename to MDS_3/test/MDS_3/test_c3t3_into_facegraph.cpp diff --git a/Mesh_3/test/Mesh_3/test_c3t3_io.cpp b/MDS_3/test/MDS_3/test_c3t3_io.cpp similarity index 99% rename from Mesh_3/test/Mesh_3/test_c3t3_io.cpp rename to MDS_3/test/MDS_3/test_c3t3_io.cpp index 03f8e8e0a2d..b590fa9c08f 100644 --- a/Mesh_3/test/Mesh_3/test_c3t3_io.cpp +++ b/MDS_3/test/MDS_3/test_c3t3_io.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/Mesh_3/test/Mesh_3/test_c3t3_with_features.cpp b/MDS_3/test/MDS_3/test_c3t3_with_features.cpp similarity index 100% rename from Mesh_3/test/Mesh_3/test_c3t3_with_features.cpp rename to MDS_3/test/MDS_3/test_c3t3_with_features.cpp diff --git a/MDS_3/test/MDS_3/test_utilities.h b/MDS_3/test/MDS_3/test_utilities.h new file mode 100644 index 00000000000..16797ae26bc --- /dev/null +++ b/MDS_3/test/MDS_3/test_utilities.h @@ -0,0 +1,51 @@ +// Copyright (c) 2009 INRIA Sophia-Antipolis (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) : Stephane Tayeb +// +//****************************************************************************** +// File Description : +// +//****************************************************************************** + +#ifndef CGAL_MESH_3_TEST_TEST_UTILITIES_H +#define CGAL_MESH_3_TEST_TEST_UTILITIES_H + +#include +#include + +#include +#include + +#include + +typedef CGAL::Exact_predicates_inexact_constructions_kernel K_e_i; +typedef CGAL::Exact_predicates_exact_constructions_kernel K_e_e; + +namespace CGAL { +namespace details { + +template<> +struct Mesh_geom_traits_generator +{ +private: + typedef K_e_e Geom_traits; + +public: + typedef Geom_traits type; + typedef type Type; +}; // end struct Mesh_geom_traits_generator<...> + +} // end namespace details +} // end namespace CGAL + +#include + +#endif // CGAL_MESH_3_TEST_TEST_UTILITIES_H diff --git a/Mesh_3/doc/Mesh_3/PackageDescription.txt b/Mesh_3/doc/Mesh_3/PackageDescription.txt index 9d9edbfd5ac..4947d2a4fce 100644 --- a/Mesh_3/doc/Mesh_3/PackageDescription.txt +++ b/Mesh_3/doc/Mesh_3/PackageDescription.txt @@ -57,8 +57,6 @@ Here are the main concepts of this package: - `MeshTriangulationTraits_3` -- `MeshComplex_3InTriangulation_3` -- `MeshComplexWithFeatures_3InTriangulation_3` - `MeshDomain_3` - `MeshDomainWithFeatures_3` - `MeshCriteria_3` @@ -80,7 +78,6 @@ related to the template parameters of some models of the main concepts: \cgalCRPSection{Classes} -- `CGAL::Mesh_complex_3_in_triangulation_3` - `CGAL::Mesh_triangulation_3` - `CGAL::Mesh_vertex_base_3` - `CGAL::Compact_mesh_cell_base_3` @@ -114,7 +111,6 @@ and their associated classes: - `CGAL::perturb_mesh_3()` - `CGAL::lloyd_optimize_mesh_3()` - `CGAL::odt_optimize_mesh_3()` -- `CGAL::facets_in_complex_3_to_triangle_mesh()` \cgalCRPSection{CGAL::parameters Functions} @@ -137,8 +133,5 @@ and their associated classes: - `CGAL::Mesh_optimization_return_code` - `CGAL::Mesh_facet_topology` -\cgalCRPSection{Input/Output Functions} -- `CGAL::output_to_medit()` -- `CGAL::output_to_vtu()` */ diff --git a/Mesh_3/doc/Mesh_3/dependencies b/Mesh_3/doc/Mesh_3/dependencies index 8dc427e241e..8d1e9d646e9 100644 --- a/Mesh_3/doc/Mesh_3/dependencies +++ b/Mesh_3/doc/Mesh_3/dependencies @@ -13,3 +13,5 @@ Polyhedron Miscellany Mesh_2 Polygon_mesh_processing +MDS_3 + diff --git a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h index 13fd9f70083..36a9b2215a1 100644 --- a/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h +++ b/Mesh_3/include/CGAL/Compact_mesh_cell_base_3.h @@ -28,7 +28,7 @@ #include #include -#include +#include #include diff --git a/Mesh_3/include/CGAL/Labeled_mesh_domain_3.h b/Mesh_3/include/CGAL/Labeled_mesh_domain_3.h index 0dceef7f282..81d262fe4e7 100644 --- a/Mesh_3/include/CGAL/Labeled_mesh_domain_3.h +++ b/Mesh_3/include/CGAL/Labeled_mesh_domain_3.h @@ -33,7 +33,7 @@ #include -#include +#include #include // support for `CGAL::Image_3` diff --git a/Mesh_3/include/CGAL/Mesh_3/Mesh_surface_cell_base_3.h b/Mesh_3/include/CGAL/Mesh_3/Mesh_surface_cell_base_3.h index 90a0e1ec909..d9667ca1a67 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Mesh_surface_cell_base_3.h +++ b/Mesh_3/include/CGAL/Mesh_3/Mesh_surface_cell_base_3.h @@ -24,7 +24,7 @@ #include #include -#include +#include #ifdef CGAL_LINKED_WITH_TBB # include diff --git a/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h b/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h index ab9a4844e5f..8291c2ee81b 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h +++ b/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h @@ -28,11 +28,11 @@ #include #include -#include +#include #ifdef CGAL_MESH_3_DUMP_FEATURES_PROTECTION_ITERATIONS # include #endif -#include +#include #include #include #include @@ -108,7 +108,7 @@ void debug_dump_c3t3(const std::string filename, const C3t3& c3t3) template class Protect_edges_sizing_field - : public CGAL::Mesh_3::internal::Debug_messages_tools + : public CGAL::MDS_3::internal::Debug_messages_tools { typedef Protect_edges_sizing_field Self; diff --git a/Mesh_3/include/CGAL/Mesh_cell_base_3.h b/Mesh_3/include/CGAL/Mesh_cell_base_3.h index 2babd0cc5db..3bb5e2c30d9 100644 --- a/Mesh_3/include/CGAL/Mesh_cell_base_3.h +++ b/Mesh_3/include/CGAL/Mesh_cell_base_3.h @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include diff --git a/Mesh_3/include/CGAL/Mesh_triangulation_3.h b/Mesh_3/include/CGAL/Mesh_triangulation_3.h index 8d97e0696fe..5d4225225d3 100644 --- a/Mesh_3/include/CGAL/Mesh_triangulation_3.h +++ b/Mesh_3/include/CGAL/Mesh_triangulation_3.h @@ -28,7 +28,7 @@ #include #include -#include +#include namespace CGAL { diff --git a/Mesh_3/include/CGAL/Mesh_vertex_base_3.h b/Mesh_3/include/CGAL/Mesh_vertex_base_3.h index ecb1f9464c5..de112e16f4b 100644 --- a/Mesh_3/include/CGAL/Mesh_vertex_base_3.h +++ b/Mesh_3/include/CGAL/Mesh_vertex_base_3.h @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include diff --git a/Mesh_3/include/CGAL/Polyhedral_mesh_domain_3.h b/Mesh_3/include/CGAL/Polyhedral_mesh_domain_3.h index ce7d0088fe3..256e92aadf8 100644 --- a/Mesh_3/include/CGAL/Polyhedral_mesh_domain_3.h +++ b/Mesh_3/include/CGAL/Polyhedral_mesh_domain_3.h @@ -59,7 +59,7 @@ // To handle I/O for Surface_patch_index if that is a pair of `int` (the // default) -#include +#include #include diff --git a/Mesh_3/test/Mesh_3/CMakeLists.txt b/Mesh_3/test/Mesh_3/CMakeLists.txt index f30b1c82b46..376aea84c2f 100644 --- a/Mesh_3/test/Mesh_3/CMakeLists.txt +++ b/Mesh_3/test/Mesh_3/CMakeLists.txt @@ -29,16 +29,12 @@ if ( CGAL_FOUND ) endif() create_single_source_cgal_program( "test_boost_has_xxx.cpp" ) - create_single_source_cgal_program( "test_c3t3.cpp" ) create_single_source_cgal_program( "test_mesh_capsule_var_distance_bound.cpp" ) create_single_source_cgal_program( "test_implicit_multi_domain_to_labeling_function_wrapper.cpp" ) - create_single_source_cgal_program( "test_c3t3_io.cpp" ) - create_single_source_cgal_program( "test_c3t3_with_features.cpp" ) create_single_source_cgal_program( "test_criteria.cpp" ) create_single_source_cgal_program( "test_domain_with_polyline_features.cpp" ) create_single_source_cgal_program( "test_labeled_mesh_domain_3.cpp" ) create_single_source_cgal_program( "test_mesh_criteria_creation.cpp" ) - create_single_source_cgal_program( "test_c3t3_into_facegraph.cpp" ) create_single_source_cgal_program( "test_without_detect_features.cpp" ) if(CGAL_ImageIO_USE_ZLIB) create_single_source_cgal_program( "test_meshing_3D_image.cpp" ) @@ -58,7 +54,6 @@ if ( CGAL_FOUND ) create_single_source_cgal_program( "test_meshing_unit_tetrahedron.cpp" ) create_single_source_cgal_program( "test_meshing_with_default_edge_size.cpp" ) create_single_source_cgal_program( "test_meshing_determinism.cpp" ) - create_single_source_cgal_program( "test_c3t3_extract_subdomains_boundaries.cpp" ) create_single_source_cgal_program( "test_mesh_3_issue_1554.cpp" ) create_single_source_cgal_program( "test_mesh_polyhedral_domain_with_features_deprecated.cpp" ) create_single_source_cgal_program( "test_meshing_with_one_step.cpp" ) @@ -66,16 +61,12 @@ if ( CGAL_FOUND ) foreach(target test_boost_has_xxx - test_c3t3 test_mesh_capsule_var_distance_bound test_implicit_multi_domain_to_labeling_function_wrapper - test_c3t3_io - test_c3t3_with_features test_criteria test_domain_with_polyline_features test_labeled_mesh_domain_3 test_mesh_criteria_creation - test_c3t3_into_facegraph test_without_detect_features test_meshing_3D_image test_meshing_3D_image_deprecated @@ -91,7 +82,6 @@ if ( CGAL_FOUND ) test_meshing_unit_tetrahedron test_meshing_with_default_edge_size test_meshing_determinism - test_c3t3_extract_subdomains_boundaries test_mesh_3_issue_1554 test_mesh_polyhedral_domain_with_features_deprecated test_mesh_cell_base_3 diff --git a/Mesh_3/test/Mesh_3/test_meshing_polyhedron.cpp b/Mesh_3/test/Mesh_3/test_meshing_polyhedron.cpp index 999faf85a56..6acba7b342b 100644 --- a/Mesh_3/test/Mesh_3/test_meshing_polyhedron.cpp +++ b/Mesh_3/test/Mesh_3/test_meshing_polyhedron.cpp @@ -15,7 +15,7 @@ // File Description : //****************************************************************************** -#include +#include #include "test_meshing_utilities.h" #include #include From baba44459b0678458fa3d41a9ea946035c9beca6 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 23 Apr 2021 15:02:16 +0200 Subject: [PATCH 09/79] fix compilation of the demo --- Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp | 4 ++-- Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp index 7dbc3eaa910..1e90b794e17 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp @@ -10,7 +10,7 @@ // Jane Tournois // -#include +#include #include #include "Scene_surface_mesh_item.h" @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp index 0972f9cc4f4..41aee815337 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp @@ -1,4 +1,4 @@ -#include +#include #include "Scene_c3t3_item.h" #include #include From 4cd5726088d5db0f8516985a35c3e520d1b0eed2 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 26 Apr 2021 11:31:40 +0200 Subject: [PATCH 10/79] update group names --- MDS_3/doc/MDS_3/CGAL/IO/File_avizo.h | 2 +- MDS_3/doc/MDS_3/CGAL/IO/File_medit.h | 2 +- MDS_3/doc/MDS_3/CGAL/IO/File_tetgen.h | 2 +- MDS_3/doc/MDS_3/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h | 2 +- MDS_3/doc/MDS_3/CGAL/IO/output_to_vtu.h | 2 +- MDS_3/doc/MDS_3/CGAL/Mesh_complex_3_in_triangulation_3.h | 2 +- .../MDS_3/Concepts/MeshComplexWithFeatures_3InTriangulation_3.h | 2 +- MDS_3/doc/MDS_3/Concepts/MeshComplex_3InTriangulation_3.h | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/MDS_3/doc/MDS_3/CGAL/IO/File_avizo.h b/MDS_3/doc/MDS_3/CGAL/IO/File_avizo.h index 94c1c3684a6..0984dc4e843 100644 --- a/MDS_3/doc/MDS_3/CGAL/IO/File_avizo.h +++ b/MDS_3/doc/MDS_3/CGAL/IO/File_avizo.h @@ -1,6 +1,6 @@ namespace CGAL{ /** - * \ingroup PkgMesh3IOFunctions + * \ingroup PkgMDS3IOFunctions * @brief outputs mesh to avizo format * @param os the stream * @param c3t3 the mesh complex diff --git a/MDS_3/doc/MDS_3/CGAL/IO/File_medit.h b/MDS_3/doc/MDS_3/CGAL/IO/File_medit.h index 62bb1476d86..9b4af2dd68c 100644 --- a/MDS_3/doc/MDS_3/CGAL/IO/File_medit.h +++ b/MDS_3/doc/MDS_3/CGAL/IO/File_medit.h @@ -1,6 +1,6 @@ namespace CGAL { -/// \ingroup PkgMesh3IOFunctions +/// \ingroup PkgMDS3IOFunctions /// /// \brief outputs a mesh complex to the medit (`.mesh`) file format. /// See \cgalCite{frey:inria-00069921} for a comprehensive description of this file format. diff --git a/MDS_3/doc/MDS_3/CGAL/IO/File_tetgen.h b/MDS_3/doc/MDS_3/CGAL/IO/File_tetgen.h index b142b41f0c7..4ae346424c1 100644 --- a/MDS_3/doc/MDS_3/CGAL/IO/File_tetgen.h +++ b/MDS_3/doc/MDS_3/CGAL/IO/File_tetgen.h @@ -1,6 +1,6 @@ namespace CGAL{ /** - * \ingroup PkgMesh3IOFunctions + * \ingroup PkgMDS3IOFunctions * @brief outputs a mesh complex to tetgen format * @param filename the path to the output file * @param c3t3 the mesh diff --git a/MDS_3/doc/MDS_3/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h b/MDS_3/doc/MDS_3/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h index b672d4d3273..e17c8213fc1 100644 --- a/MDS_3/doc/MDS_3/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h +++ b/MDS_3/doc/MDS_3/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h @@ -1,5 +1,5 @@ namespace CGAL { -//! \ingroup PkgMesh3Functions +//! \ingroup PkgMDS3Functions //! //! \brief builds a `TriangleMesh` from the surface facets, with a consistent orientation at the interface of two subdomains. //! diff --git a/MDS_3/doc/MDS_3/CGAL/IO/output_to_vtu.h b/MDS_3/doc/MDS_3/CGAL/IO/output_to_vtu.h index 70a64f586c7..a9c4205f590 100644 --- a/MDS_3/doc/MDS_3/CGAL/IO/output_to_vtu.h +++ b/MDS_3/doc/MDS_3/CGAL/IO/output_to_vtu.h @@ -1,5 +1,5 @@ namespace CGAL{ -//! \ingroup PkgMesh3IOFunctions +//! \ingroup PkgMDS3IOFunctions //! //! \brief writes a tetrahedron mesh using the `UnstructuredGrid` XML format. //! diff --git a/MDS_3/doc/MDS_3/CGAL/Mesh_complex_3_in_triangulation_3.h b/MDS_3/doc/MDS_3/CGAL/Mesh_complex_3_in_triangulation_3.h index d46c9ea2b83..4725a135197 100644 --- a/MDS_3/doc/MDS_3/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/MDS_3/doc/MDS_3/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -1,7 +1,7 @@ namespace CGAL { /*! -\ingroup PkgMesh3MeshClasses +\ingroup PkgMDS3Classes The class `Mesh_complex_3_in_triangulation_3` implements a data structure to store the 3D restricted Delaunay triangulation used by a mesh diff --git a/MDS_3/doc/MDS_3/Concepts/MeshComplexWithFeatures_3InTriangulation_3.h b/MDS_3/doc/MDS_3/Concepts/MeshComplexWithFeatures_3InTriangulation_3.h index 50b2751ac74..9bfd0e07b60 100644 --- a/MDS_3/doc/MDS_3/Concepts/MeshComplexWithFeatures_3InTriangulation_3.h +++ b/MDS_3/doc/MDS_3/Concepts/MeshComplexWithFeatures_3InTriangulation_3.h @@ -1,5 +1,5 @@ /*! -\ingroup PkgMesh3Concepts +\ingroup PkgMDS3Concepts \cgalConcept The concept `MeshComplexWithFeatures_3InTriangulation_3` describes a data structure diff --git a/MDS_3/doc/MDS_3/Concepts/MeshComplex_3InTriangulation_3.h b/MDS_3/doc/MDS_3/Concepts/MeshComplex_3InTriangulation_3.h index 3d3e28c7e2f..993d9bd1a34 100644 --- a/MDS_3/doc/MDS_3/Concepts/MeshComplex_3InTriangulation_3.h +++ b/MDS_3/doc/MDS_3/Concepts/MeshComplex_3InTriangulation_3.h @@ -1,5 +1,5 @@ /*! -\ingroup PkgMesh3Concepts +\ingroup PkgMDS3Concepts \cgalConcept The concept `MeshComplex_3InTriangulation_3` describes a data structure From d4b5d61f839b95c81ccd8fe955953ea9359bfd60 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 26 Apr 2021 11:32:58 +0200 Subject: [PATCH 11/79] add missing IO functions --- MDS_3/doc/MDS_3/PackageDescription.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MDS_3/doc/MDS_3/PackageDescription.txt b/MDS_3/doc/MDS_3/PackageDescription.txt index 596e353e11b..087ce57e1d0 100644 --- a/MDS_3/doc/MDS_3/PackageDescription.txt +++ b/MDS_3/doc/MDS_3/PackageDescription.txt @@ -55,5 +55,7 @@ Here are the main concepts of this package: \cgalCRPSection{Input/Output Functions} - `CGAL::output_to_medit()` - `CGAL::output_to_vtu()` +- `CGAL::output_to_tetgen()` +- `CGAL::output_to_avizo()` */ From 0352c7d8bbdb923acc841da633f146169827b9c2 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 26 Apr 2021 16:57:45 +0200 Subject: [PATCH 12/79] transfer documentation to header files and fix some namespaces --- MDS_3/doc/MDS_3/CGAL/IO/File_avizo.h | 13 --- MDS_3/doc/MDS_3/CGAL/IO/File_medit.h | 21 ---- MDS_3/doc/MDS_3/CGAL/IO/File_tetgen.h | 19 ---- .../IO/facets_in_complex_3_to_triangle_mesh.h | 16 --- MDS_3/doc/MDS_3/CGAL/IO/output_to_vtu.h | 17 --- .../CGAL/Mesh_complex_3_in_triangulation_3.h | 101 ------------------ MDS_3/doc/MDS_3/Doxyfile.in | 12 ++- MDS_3/doc/MDS_3/dependencies | 1 + MDS_3/include/CGAL/IO/File_avizo.h | 9 +- MDS_3/include/CGAL/IO/File_medit.h | 26 ++--- MDS_3/include/CGAL/IO/File_tetgen.h | 22 ++-- .../IO/facets_in_complex_3_to_triangle_mesh.h | 31 +++--- MDS_3/include/CGAL/IO/output_to_vtu.h | 12 ++- .../CGAL/Mesh_complex_3_in_triangulation_3.h | 83 +++++++++++++- ...n_of_complex_3_in_triangulation_3_to_off.h | 4 +- 15 files changed, 153 insertions(+), 234 deletions(-) delete mode 100644 MDS_3/doc/MDS_3/CGAL/IO/File_avizo.h delete mode 100644 MDS_3/doc/MDS_3/CGAL/IO/File_medit.h delete mode 100644 MDS_3/doc/MDS_3/CGAL/IO/File_tetgen.h delete mode 100644 MDS_3/doc/MDS_3/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h delete mode 100644 MDS_3/doc/MDS_3/CGAL/IO/output_to_vtu.h delete mode 100644 MDS_3/doc/MDS_3/CGAL/Mesh_complex_3_in_triangulation_3.h diff --git a/MDS_3/doc/MDS_3/CGAL/IO/File_avizo.h b/MDS_3/doc/MDS_3/CGAL/IO/File_avizo.h deleted file mode 100644 index 0984dc4e843..00000000000 --- a/MDS_3/doc/MDS_3/CGAL/IO/File_avizo.h +++ /dev/null @@ -1,13 +0,0 @@ -namespace CGAL{ -/** - * \ingroup PkgMDS3IOFunctions - * @brief outputs mesh to avizo format - * @param os the stream - * @param c3t3 the mesh complex - * \see \ref IOStreamAvizo - */ -template -void -output_to_avizo(std::ostream& os, - const C3T3& c3t3); -} diff --git a/MDS_3/doc/MDS_3/CGAL/IO/File_medit.h b/MDS_3/doc/MDS_3/CGAL/IO/File_medit.h deleted file mode 100644 index 9b4af2dd68c..00000000000 --- a/MDS_3/doc/MDS_3/CGAL/IO/File_medit.h +++ /dev/null @@ -1,21 +0,0 @@ -namespace CGAL { - -/// \ingroup PkgMDS3IOFunctions -/// -/// \brief outputs a mesh complex to the medit (`.mesh`) file format. -/// See \cgalCite{frey:inria-00069921} for a comprehensive description of this file format. -/// -/// \param os the output stream -/// \param c3t3 the mesh complex -/// \param rebind if set to `true`, labels of cells are rebinded into `[1..nb_of_labels]` -/// \param show_patches if set to `true`, patches are labeled with different labels than -/// cells. If set to `false`, each surface facet is written twice, -/// using the label of each adjacent cell. -/// -template -void output_to_medit(std::ostream& os, - const C3T3& c3t3, - bool rebind = false, - bool show_patches = false); - -} // end namespace CGAL diff --git a/MDS_3/doc/MDS_3/CGAL/IO/File_tetgen.h b/MDS_3/doc/MDS_3/CGAL/IO/File_tetgen.h deleted file mode 100644 index 4ae346424c1..00000000000 --- a/MDS_3/doc/MDS_3/CGAL/IO/File_tetgen.h +++ /dev/null @@ -1,19 +0,0 @@ -namespace CGAL{ -/** - * \ingroup PkgMDS3IOFunctions - * @brief outputs a mesh complex to tetgen format - * @param filename the path to the output file - * @param c3t3 the mesh - * @param rebind if true, labels of cells are rebinded into [1..nb_of_labels] - * @param show_patches if true, patches are labeled with different labels than - * cells. If false, each surface facet is written twice, using label of - * each adjacent cell. - * \see \ref IOStreamTetgen - */ -template -void -output_to_tetgen(std::string filename, - const C3T3& c3t3, - bool rebind = false, - bool show_patches = false); -} diff --git a/MDS_3/doc/MDS_3/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h b/MDS_3/doc/MDS_3/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h deleted file mode 100644 index e17c8213fc1..00000000000 --- a/MDS_3/doc/MDS_3/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h +++ /dev/null @@ -1,16 +0,0 @@ -namespace CGAL { -//! \ingroup PkgMDS3Functions -//! -//! \brief builds a `TriangleMesh` from the surface facets, with a consistent orientation at the interface of two subdomains. -//! -//! This function exports the surface as a `TriangleMesh` and appends it to `graph`, using -//! `orient_polygon_soup()`. -//! -//! @tparam C3T3 a model of `MeshComplexWithFeatures_3InTriangulation_3`. -//! @tparam TriangleMesh a model of `MutableFaceGraph` with an internal point property map. The point type should be compatible with the one used in `C3T3`. -//! -//! @param c3t3 an instance of `C3T3`. -//! @param graph an instance of `TriangleMesh`. -template -void facets_in_complex_3_to_triangle_mesh(const C3T3& c3t3, TriangleMesh& graph); -} diff --git a/MDS_3/doc/MDS_3/CGAL/IO/output_to_vtu.h b/MDS_3/doc/MDS_3/CGAL/IO/output_to_vtu.h deleted file mode 100644 index a9c4205f590..00000000000 --- a/MDS_3/doc/MDS_3/CGAL/IO/output_to_vtu.h +++ /dev/null @@ -1,17 +0,0 @@ -namespace CGAL{ -//! \ingroup PkgMDS3IOFunctions -//! -//! \brief writes a tetrahedron mesh using the `UnstructuredGrid` XML format. -//! -//! \tparam C3T3 a model of `MeshComplexWithFeatures_3InTriangulation_3`. -//! -//! \param os the stream used for writing. -//! \param c3t3 the instance of `C3T3` to be written. -//! \param mode decides if the data should be written in binary (`IO::BINARY`) -//! or in ASCII (`IO::ASCII`). -//! -template -void output_to_vtu(std::ostream& os, - const C3T3& c3t3, - IO::Mode mode = IO::BINARY); -} diff --git a/MDS_3/doc/MDS_3/CGAL/Mesh_complex_3_in_triangulation_3.h b/MDS_3/doc/MDS_3/CGAL/Mesh_complex_3_in_triangulation_3.h deleted file mode 100644 index 4725a135197..00000000000 --- a/MDS_3/doc/MDS_3/CGAL/Mesh_complex_3_in_triangulation_3.h +++ /dev/null @@ -1,101 +0,0 @@ -namespace CGAL { - -/*! -\ingroup PkgMDS3Classes - -The class `Mesh_complex_3_in_triangulation_3` implements a data structure -to store the 3D restricted Delaunay triangulation used by a mesh -generation process. - -This class is a model of the concept -`MeshComplexWithFeatures_3InTriangulation_3`. - - -\tparam Tr can be instantiated with any 3D -regular triangulation of \cgal provided that its -vertex and cell base class are models of the concepts -`MeshVertexBase_3` and `MeshCellBase_3`, respectively. - -\tparam CornerIndex is the type of the indices for corners. It must match the `Corner_index` of the model -of the `MeshDomainWithFeatures_3` concept used for mesh generation. - -\tparam CurveIndex is the type of the indices for curves. -It must match the `Curve_index` types of the model -of the `MeshDomainWithFeatures_3` concept used for mesh generation. - -Those two last template parameters defaults to `int`, so that they can be ignored -if the domain used for mesh generation does not include 0 and 1-dimensionnal features (i.e -is a model of the concept `MeshDomain_3`). - -\cgalModels `MeshComplexWithFeatures_3InTriangulation_3` - -\sa `CGAL::make_mesh_3()` -\sa `CGAL::refine_mesh_3()` -\sa `MeshComplex_3InTriangulation_3` -\sa `MeshComplexWithFeatures_3InTriangulation_3` -\sa `MeshCellBase_3`, -\sa `MeshVertexBase_3` - -*/ -template< typename Tr, typename CornerIndex, typename CurveIndex > -class Mesh_complex_3_in_triangulation_3 { -public: - -/// \name Types -/// @{ - -/*! -%Index type. -*/ -typedef Tr::Vertex::Index Index; - -/*! -Surface index type. -*/ -typedef Tr::Cell::Surface_patch_index Surface_patch_index; - -/*! -Subdomain index type. -*/ -typedef Tr::Cell::Subdomain_index Subdomain_index; - -/*! - Corner index type. -*/ -typedef CornerIndex Corner_index; - -/*! -Curve index type. -*/ -typedef CurveIndex Curve_index; - -/// @} - -/// \name Operations -/// @{ - -/*! -Outputs the mesh to `os` -in medit format. -*/ -void output_to_medit(std::ofstream& os); - -/** - * Outputs the outer boundary of the entire domain with facets oriented outward. - */ -std::ostream& output_boundary_to_off(std::ostream& out) const; - -/** - * Outputs the outer boundary of the selected subdomain with facets oriented outward. - */ -std::ostream& output_boundary_to_off(std::ostream& out, Subdomain_index subdomain) const; - -/** - * Outputs the surface facets with a consistent orientation at the interface of two subdomains. - */ -std::ostream& output_facets_in_complex_to_off(std::ostream& out) const; - -/// @} - -}; /* end Mesh_complex_3_in_triangulation_3 */ -} /* end namespace CGAL */ diff --git a/MDS_3/doc/MDS_3/Doxyfile.in b/MDS_3/doc/MDS_3/Doxyfile.in index abb8090bb24..f0a2385ded1 100644 --- a/MDS_3/doc/MDS_3/Doxyfile.in +++ b/MDS_3/doc/MDS_3/Doxyfile.in @@ -3,11 +3,17 @@ # macros to be used inside the code #ALIASES += "cgalDescribePolylineType=A polyline is defined as a sequence of points, each pair of contiguous points defines a segment of the polyline. If the first and last points of the polyline are identical, the polyline is closed." -#INPUT += \ - # ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/Polyhedral_complex_mesh_domain_3.h \ - # ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/Mesh_domain_with_polyline_features_3.h +INPUT += \ + ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/IO PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - 3D Mesh Data Structures" + +EXTRACT_ALL = false +HIDE_UNDOC_CLASSES = true +WARN_IF_UNDOCUMENTED = false + +EXCLUDE = ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/internal/MDS_3 + HTML_EXTRA_FILES = ${CGAL_PACKAGE_DOC_DIR}/fig/c3t3.jpg \ # ${CGAL_PACKAGE_DOC_DIR}/fig/no-protection-complex.png diff --git a/MDS_3/doc/MDS_3/dependencies b/MDS_3/doc/MDS_3/dependencies index 27855395ad3..4db3ea7295e 100644 --- a/MDS_3/doc/MDS_3/dependencies +++ b/MDS_3/doc/MDS_3/dependencies @@ -9,3 +9,4 @@ Periodic_3_triangulation_3 TDS_3 Polyhedron Miscellany +Mesh_3 diff --git a/MDS_3/include/CGAL/IO/File_avizo.h b/MDS_3/include/CGAL/IO/File_avizo.h index 704200b069b..d8ab470a9c5 100644 --- a/MDS_3/include/CGAL/IO/File_avizo.h +++ b/MDS_3/include/CGAL/IO/File_avizo.h @@ -24,7 +24,7 @@ namespace CGAL { -namespace Mesh_3 { +namespace MDS_3 { template @@ -137,15 +137,16 @@ output_to_avizo(std::ostream& os, } // end output_to_avizo(...) -} // end namespace Mesh_3 +} // end namespace MDS_3 /** + * \ingroup PkgMDS3IOFunctions * @brief outputs mesh to avizo format * @param os the stream - * @param c3t3 the mesh + * @param c3t3 the mesh complex * \see \ref IOStreamAvizo */ template @@ -153,7 +154,7 @@ void output_to_avizo(std::ostream& os, const C3T3& c3t3) { - Mesh_3::output_to_avizo(os,c3t3); + MDS_3::output_to_avizo(os,c3t3); } } // end namespace CGAL diff --git a/MDS_3/include/CGAL/IO/File_medit.h b/MDS_3/include/CGAL/IO/File_medit.h index c7aae3ad51b..1041c4ba2a3 100644 --- a/MDS_3/include/CGAL/IO/File_medit.h +++ b/MDS_3/include/CGAL/IO/File_medit.h @@ -34,7 +34,7 @@ namespace CGAL { -namespace Mesh_3 { +namespace MDS_3 { //------------------------------------------------------- // Needed in verbose mode @@ -862,13 +862,15 @@ output_to_medit(std::ostream& os, } // end namespace Mesh_3 /** - * @brief outputs mesh to medit format - * @param os the stream - * @param c3t3 the mesh - * @param rebind if true, labels of cells are rebinded into [1..nb_of_labels] - * @param show_patches if true, patches are labeled with different labels than - * cells. If false, each surface facet is written twice, using label of - * each adjacent cell. + * @ingroup PkgMDS3IOFunctions + * @brief outputs a mesh complex to the medit (`.mesh`) file format. + See \cgalCite{frey:inria-00069921} for a comprehensive description of this file format. + * @param os the output stream + * @param c3t3 the mesh complex + * @param rebind if `true`, labels of cells are rebinded into `[1..nb_of_labels]` + * @param show_patches if `true`, patches are labeled with different labels than + * cells. If `false`, each surface facet is written twice, + * using the label of each adjacent cell. * \see \ref IOStreamMedit */ template @@ -881,16 +883,16 @@ output_to_medit(std::ostream& os, if ( rebind ) { if ( show_patches ) - Mesh_3::output_to_medit(os,c3t3); + MDS_3::output_to_medit(os,c3t3); else - Mesh_3::output_to_medit(os,c3t3); + MDS_3::output_to_medit(os,c3t3); } else { if ( show_patches ) - Mesh_3::output_to_medit(os,c3t3); + MDS_3::output_to_medit(os,c3t3); else - Mesh_3::output_to_medit(os,c3t3); + MDS_3::output_to_medit(os,c3t3); } } diff --git a/MDS_3/include/CGAL/IO/File_tetgen.h b/MDS_3/include/CGAL/IO/File_tetgen.h index 0eca7bdb760..c7a45151d62 100644 --- a/MDS_3/include/CGAL/IO/File_tetgen.h +++ b/MDS_3/include/CGAL/IO/File_tetgen.h @@ -25,7 +25,7 @@ namespace CGAL { -namespace Mesh_3 { +namespace MDS_3 { template void @@ -189,7 +189,17 @@ output_to_tetgen(std::string filename, - +/** + * \ingroup PkgMDS3IOFunctions + * @brief outputs a mesh complex to tetgen format + * @param filename the path to the output file + * @param c3t3 the mesh + * @param rebind if true, labels of cells are rebinded into [1..nb_of_labels] + * @param show_patches if true, patches are labeled with different labels than + * cells. If false, each surface facet is written twice, using label of + * each adjacent cell. + * \see \ref IOStreamTetgen + */ template void output_to_tetgen(std::string filename, @@ -200,16 +210,16 @@ output_to_tetgen(std::string filename, if ( rebind ) { if ( show_patches ) - Mesh_3::output_to_tetgen(filename,c3t3); + MDS_3::output_to_tetgen(filename,c3t3); else - Mesh_3::output_to_tetgen(filename,c3t3); + MDS_3::output_to_tetgen(filename,c3t3); } else { if ( show_patches ) - Mesh_3::output_to_tetgen(filename,c3t3); + MDS_3::output_to_tetgen(filename,c3t3); else - Mesh_3::output_to_tetgen(filename,c3t3); + MDS_3::output_to_tetgen(filename,c3t3); } } diff --git a/MDS_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h b/MDS_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h index d69f445716f..74fc03c0e5c 100644 --- a/MDS_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h +++ b/MDS_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h @@ -32,7 +32,7 @@ namespace CGAL { -namespace Mesh_3 { +namespace MDS_3 { namespace internal { @@ -144,20 +144,19 @@ void facets_in_complex_3_to_triangle_soup(const C3T3& c3t3, } // end namespace Mesh_3 -//! \ingroup PkgMesh3Functions -//! -//! \brief builds a `TriangleMesh` from the surface facets, with a consistent orientation -//! at the interface of two subdomains. -//! -//! This function exports the surface as a `TriangleMesh` and appends it to `graph`, using -//! `orient_polygon_soup()`. -//! -//! @tparam C3T3 a model of `MeshComplexWithFeatures_3InTriangulation_3`. -//! @tparam TriangleMesh a model of `MutableFaceGraph` with an internal point property map. -//! The point type should be compatible with the one used in `C3T3`. -//! -//! @param c3t3 an instance of `C3T3`. -//! @param graph an instance of `TriangleMesh`. +/** + * @ingroup PkgMDS3Functions + * + * @brief builds a `TriangleMesh` from the surface facets, with a consistent orientation at the interface of two subdomains. + * + * This function exports the surface as a `TriangleMesh` and appends it to `graph`, using `orient_polygon_soup()`. + * + * @tparam C3T3 a model of `MeshComplexWithFeatures_3InTriangulation_3`. + * @tparam TriangleMesh a model of `MutableFaceGraph` with an internal point property map. The point type should be compatible with the one used in `C3T3`. + * + * @param c3t3 an instance of `C3T3`. + * @param graph an instance of `TriangleMesh`. +*/ template void facets_in_complex_3_to_triangle_mesh(const C3T3& c3t3, TriangleMesh& graph) { @@ -171,7 +170,7 @@ void facets_in_complex_3_to_triangle_mesh(const C3T3& c3t3, TriangleMesh& graph) std::vector faces; std::vector points; - Mesh_3::internal::facets_in_complex_3_to_triangle_soup(c3t3, points, faces); + MDS_3::internal::facets_in_complex_3_to_triangle_soup(c3t3, points, faces); if(!PMP::is_polygon_soup_a_polygon_mesh(faces)) PMP::orient_polygon_soup(points, faces); diff --git a/MDS_3/include/CGAL/IO/output_to_vtu.h b/MDS_3/include/CGAL/IO/output_to_vtu.h index 65a96d013d7..fc2d478066b 100644 --- a/MDS_3/include/CGAL/IO/output_to_vtu.h +++ b/MDS_3/include/CGAL/IO/output_to_vtu.h @@ -352,7 +352,17 @@ void output_to_vtu_with_attributes(std::ostream& os, } // namespace internal } // namespace IO -//public API +//! \ingroup PkgMDS3IOFunctions +//! +//! \brief writes a tetrahedron mesh using the `UnstructuredGrid` XML format. +//! +//! \tparam C3T3 a model of `MeshComplexWithFeatures_3InTriangulation_3`. +//! +//! \param os the stream used for writing. +//! \param c3t3 the instance of `C3T3` to be written. +//! \param mode decides if the data should be written in binary (`IO::BINARY`) +//! or in ASCII (`IO::ASCII`). +//! template void output_to_vtu(std::ostream& os, const C3T3& c3t3, diff --git a/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 36c98d89222..967e84f9d6d 100644 --- a/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -34,10 +34,48 @@ #include #include #include +#include +#include namespace CGAL { +/*! + \ingroup PkgMDS3Classes + The class `Mesh_complex_3_in_triangulation_3` implements a data structure + to store the 3D restricted Delaunay triangulation used by a mesh + generation process. + + This class is a model of the concept + `MeshComplexWithFeatures_3InTriangulation_3`. + + + \tparam Tr can be instantiated with any 3D + regular triangulation of \cgal provided that its + vertex and cell base class are models of the concepts + `MeshVertexBase_3` and `MeshCellBase_3`, respectively. + + \tparam CornerIndex is the type of the indices for corners. It must match the `Corner_index` of the model + of the `MeshDomainWithFeatures_3` concept used for mesh generation. + + \tparam CurveIndex is the type of the indices for curves. + It must match the `Curve_index` types of the model + of the `MeshDomainWithFeatures_3` concept used for mesh generation. + + Those two last template parameters defaults to `int`, so that they can be ignored + if the domain used for mesh generation does not include 0 and 1-dimensionnal features (i.e + is a model of the concept `MeshDomain_3`). + + \cgalModels `MeshComplexWithFeatures_3InTriangulation_3` + + \sa `CGAL::make_mesh_3()` + \sa `CGAL::refine_mesh_3()` + \sa `MeshComplex_3InTriangulation_3` + \sa `MeshComplexWithFeatures_3InTriangulation_3` + \sa `MeshCellBase_3`, + \sa `MeshVertexBase_3` + +*/ template @@ -63,8 +101,6 @@ public: typedef typename Base::Facet Facet; typedef typename Base::Vertex_handle Vertex_handle; typedef typename Base::Cell_handle Cell_handle; - typedef CornerIndex Corner_index; - typedef CurveIndex Curve_index; typedef CGAL::Hash_handles_with_or_without_timestamps Hash_fct; @@ -73,10 +109,38 @@ public: #endif typedef typename Base::Triangulation Triangulation; - typedef typename Base::Subdomain_index Subdomain_index; using Base::surface_patch_index; +/// \name Types +/// @{ + /*! + Index type. + */ + typedef typename Tr::Vertex::Index Index; + /*! + Surface index type. + */ + typedef typename Tr::Cell::Surface_patch_index Surface_patch_index; + /*! + Subdomain index type. + */ + typedef typename Tr::Cell::Subdomain_index Subdomain_index; + /*! + Corner index type. + */ + typedef CornerIndex Corner_index; + /*! + Curve index type. + */ + typedef CurveIndex Curve_index; +/// @} + + BOOST_STATIC_ASSERT( + boost::is_same::value); + BOOST_STATIC_ASSERT( + boost::is_same::value); + private: // Type to store the edges: // - a set of std::pair (ordered at insertion) @@ -362,6 +426,8 @@ public: return Corner_index(); } + /// \name Operations + /// @{ /** * Outputs the outer boundary of the entire domain with facets oriented outward. */ @@ -389,6 +455,17 @@ public: return out; } + /*! + Outputs the mesh to `os` + in Medit format. + */ + void output_to_medit(std::ostream& os) const + { + Base::output_to_medit(os); + } + + /// @} + /** * Fills \c out with incident edges (1-dimensional features of \c v. * OutputIterator value type is std::pair diff --git a/MDS_3/include/CGAL/internal/MDS_3/Boundary_of_subdomain_of_complex_3_in_triangulation_3_to_off.h b/MDS_3/include/CGAL/internal/MDS_3/Boundary_of_subdomain_of_complex_3_in_triangulation_3_to_off.h index b08974e545e..3c930811023 100644 --- a/MDS_3/include/CGAL/internal/MDS_3/Boundary_of_subdomain_of_complex_3_in_triangulation_3_to_off.h +++ b/MDS_3/include/CGAL/internal/MDS_3/Boundary_of_subdomain_of_complex_3_in_triangulation_3_to_off.h @@ -62,7 +62,7 @@ output_boundary_of_c3t3_to_off(const C3T3& c3t3, std::vector points; std::vector faces; - CGAL::Mesh_3::internal::facets_in_complex_3_to_triangle_soup(c3t3, sd_index, points, faces, normals_point_outside_of_the_subdomain); + CGAL::MDS_3::internal::facets_in_complex_3_to_triangle_soup(c3t3, sd_index, points, faces, normals_point_outside_of_the_subdomain); return output_polygon_soup_to_off(points, faces, out); } @@ -78,7 +78,7 @@ output_facets_in_complex_to_off(const C3T3& c3t3, std::vector points; std::vector faces; - CGAL::Mesh_3::internal::facets_in_complex_3_to_triangle_soup(c3t3, points, faces); + CGAL::MDS_3::internal::facets_in_complex_3_to_triangle_soup(c3t3, points, faces); return output_polygon_soup_to_off(points, faces, out); } From 0a42951c5e998362bf3dec370992def445c217e0 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 26 Apr 2021 17:19:20 +0200 Subject: [PATCH 13/79] wip cleaning documentation of C3T3 class in header --- .../CGAL/Mesh_complex_3_in_triangulation_3.h | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 967e84f9d6d..9016ff5a129 100644 --- a/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -92,26 +92,21 @@ private: Tr,CornerIndex,CurveIndex> Self; typedef MDS_3::Mesh_complex_3_in_triangulation_3_base< Tr,Concurrency_tag> Base; + typedef CGAL::Hash_handles_with_or_without_timestamps Hash_fct; public: - typedef typename Base::size_type size_type; - - typedef typename Tr::Point Point; - typedef typename Base::Edge Edge; - typedef typename Base::Facet Facet; - typedef typename Base::Vertex_handle Vertex_handle; - typedef typename Base::Cell_handle Cell_handle; - - typedef CGAL::Hash_handles_with_or_without_timestamps Hash_fct; + typedef Tr Triangulation; + typedef typename Tr::size_type size_type; + typedef typename Tr::Point Point; + typedef typename Tr::Edge Edge; + typedef typename Tr::Facet Facet; + typedef typename Tr::Vertex_handle Vertex_handle; + typedef typename Tr::Cell_handle Cell_handle; #ifndef CGAL_NO_DEPRECATED_CODE typedef CurveIndex Curve_segment_index; #endif - typedef typename Base::Triangulation Triangulation; - - using Base::surface_patch_index; - /// \name Types /// @{ /*! @@ -136,10 +131,20 @@ public: typedef CurveIndex Curve_index; /// @} +#ifndef DOXYGEN_RUNNING BOOST_STATIC_ASSERT( boost::is_same::value); BOOST_STATIC_ASSERT( boost::is_same::value); + BOOST_STATIC_ASSERT( + boost::is_same::value); + BOOST_STATIC_ASSERT( + boost::is_same::value); + BOOST_STATIC_ASSERT( + boost::is_same::value); + BOOST_STATIC_ASSERT( + boost::is_same::value); +#endif private: // Type to store the edges: @@ -163,8 +168,10 @@ private: typedef std::vector Far_vertices_vec; public: +/// \name Constructors +/// @{ /** - * Constructor + * Default constructor */ Mesh_complex_3_in_triangulation_3() = default; @@ -182,7 +189,10 @@ public: , corners_(std::move(rhs.corners_)) , far_vertices_(std::move(rhs.far_vertices_)) {} +/// @} +/// \name Operators +/// @{ /** * Assignement operator, also serves as move-assignement */ @@ -213,6 +223,7 @@ public: corners_.clear(); far_vertices_.clear(); } +/// @} /// Import Base functions using Base::is_in_complex; @@ -220,8 +231,7 @@ public: using Base::remove_from_complex; using Base::triangulation; using Base::set_surface_patch_index; - - + using Base::surface_patch_index; /** * Add edge e to complex, with Curve_index index From 1a6276e48c5f2792c6318fd05d3c5f8a5a16c946 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 27 Apr 2021 16:22:54 +0200 Subject: [PATCH 14/79] remove Mesh_complex_3_in_triangulation_3_base.h and merge everything into Mesh_complex_3_in_triangulation_3 wip on the class documentation --- MDS_3/doc/MDS_3/Doxyfile.in | 17 +- MDS_3/include/CGAL/MDS_3/Dump_c3t3.h | 1 - .../Mesh_complex_3_in_triangulation_3_base.h | 1144 ---------------- .../CGAL/Mesh_complex_3_in_triangulation_3.h | 1178 ++++++++++++++++- MDS_3/test/MDS_3/test_c3t3.cpp | 4 - 5 files changed, 1119 insertions(+), 1225 deletions(-) delete mode 100644 MDS_3/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_base.h diff --git a/MDS_3/doc/MDS_3/Doxyfile.in b/MDS_3/doc/MDS_3/Doxyfile.in index f0a2385ded1..c7b9e9a3e10 100644 --- a/MDS_3/doc/MDS_3/Doxyfile.in +++ b/MDS_3/doc/MDS_3/Doxyfile.in @@ -1,16 +1,17 @@ @INCLUDE = ${CGAL_DOC_PACKAGE_DEFAULTS} +PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - 3D Mesh Data Structures" + +#custom options +EXTRACT_ALL = false +HIDE_UNDOC_CLASSES = true +HIDE_UNDOC_MEMBERS = true +WARN_IF_UNDOCUMENTED = false + # macros to be used inside the code #ALIASES += "cgalDescribePolylineType=A polyline is defined as a sequence of points, each pair of contiguous points defines a segment of the polyline. If the first and last points of the polyline are identical, the polyline is closed." -INPUT += \ - ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/IO - -PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - 3D Mesh Data Structures" - -EXTRACT_ALL = false -HIDE_UNDOC_CLASSES = true -WARN_IF_UNDOCUMENTED = false +INPUT += ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/IO EXCLUDE = ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/internal/MDS_3 diff --git a/MDS_3/include/CGAL/MDS_3/Dump_c3t3.h b/MDS_3/include/CGAL/MDS_3/Dump_c3t3.h index de57437424f..6380c5f5d7d 100644 --- a/MDS_3/include/CGAL/MDS_3/Dump_c3t3.h +++ b/MDS_3/include/CGAL/MDS_3/Dump_c3t3.h @@ -18,7 +18,6 @@ #include #include -#include #include #include diff --git a/MDS_3/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_base.h b/MDS_3/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_base.h deleted file mode 100644 index 093a639a589..00000000000 --- a/MDS_3/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_base.h +++ /dev/null @@ -1,1144 +0,0 @@ -// Copyright (c) 2003-2009 INRIA Sophia-Antipolis (France). -// Copyright (c) 2013 GeometryFactory Sarl (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) : Laurent Rineau, Stéphane Tayeb -// -//****************************************************************************** -// File Description : Implements class Mesh_complex_3_in_triangulation_3. -//****************************************************************************** - -#ifndef CGAL_MESH_3_MESH_COMPLEX_3_IN_TRIANGULATION_3_BASE_H -#define CGAL_MESH_3_MESH_COMPLEX_3_IN_TRIANGULATION_3_BASE_H - -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - - -#ifdef CGAL_LINKED_WITH_TBB - #include - #include - -namespace CGAL { - template < class DSC, bool Const > - std::size_t tbb_hasher(const CGAL::internal::CC_iterator& it) - { - return CGAL::internal::hash_value(it); - } - - - // As Marc Glisse pointed out the TBB hash of a std::pair is - // simplistic and leads to the - // TBB Warning: Performance is not optimal because the hash function - // produces bad randomness in lower bits in class - // tbb::interface5::concurrent_hash_map - template < class DSC, bool Const > - std::size_t tbb_hasher(const std::pair, - CGAL::internal::CC_iterator >& p) - { - return boost::hash, - CGAL::internal::CC_iterator > >()(p); - } - - -} -#endif - -namespace CGAL { -namespace MDS_3 { - - namespace details { - - template - class C3t3_helper_class - { - protected: - typedef typename Tr::Vertex_handle Vertex_handle; - typedef typename Tr::Cell_handle Cell_handle; - typedef typename Tr::Facet Facet; - typedef typename Tr::Edge Edge; - - typedef std::pair Pair_of_vertices; - - // computes and return an ordered pair of Vertex - Pair_of_vertices - make_ordered_pair(const Vertex_handle vh1, const Vertex_handle vh2) const { - if (vh1 < vh2) { - return std::make_pair(vh1, vh2); - } - else { - return std::make_pair(vh2, vh1); - } - } - - // same from an Edge - Pair_of_vertices - make_ordered_pair(const Edge e) const { - return make_ordered_pair(e.first->vertex(e.second), - e.first->vertex(e.third)); - } - - Facet canonical_facet(Cell_handle c, int i) const { - Cell_handle c2 = c->neighbor(i); - return (c2 < c) ? std::make_pair(c2,c2->index(c)) : std::make_pair(c,i); - } - - }; // end class template C3t3_helper_class - - } // end namespace MDS_3::details - -/** - * @class Mesh_complex_3_in_triangulation_3_base - * @brief A data-structure to represent and maintain a 3D complex embedded - * in a 3D triangulation. - */ -template -class Mesh_complex_3_in_triangulation_3_base - : public details::C3t3_helper_class -{ - typedef Mesh_complex_3_in_triangulation_3_base Self; - typedef details::C3t3_helper_class Base; - -public: - // Triangulation types - typedef Tr Triangulation; - typedef typename Tr::Vertex_handle Vertex_handle; - typedef typename Tr::Cell_handle Cell_handle; - typedef typename Tr::Facet Facet; - typedef typename Tr::Edge Edge; - typedef typename Tr::size_type size_type; - - typedef CGAL::Hash_handles_with_or_without_timestamps Hash_fct; - - // Indices types - typedef typename Tr::Cell::Subdomain_index Subdomain_index; - typedef typename Tr::Cell::Surface_patch_index Surface_patch_index; - typedef typename Tr::Vertex::Index Index; - - enum Face_status{ NOT_IN_COMPLEX = 0, - ISOLATED = 1, // - An ISOLATED edge is a marked edge, - // without any incident facets. - BOUNDARY, // - An edge is on BOUNDARY if it has only - // one incident facet. - // - A vertex is on BOUNDARY if all its - // incident edges are REGULAR or on - // BOUNDARY, at least one is on - // BOUNDARY, and the incident facets - // form only one connected component. - REGULAR, // - A facet that is in the complex is - // REGULAR. - // - An edge is REGULAR if it has - // exactly two incident facets. - // - A vertex is REGULAR if all it - // incident edges are REGULAR, and the - // incident facets form only one - // connected component. - SINGULAR}; // - SINGULAR is for all other cases. - - //------------------------------------------------------- - // Constructors / Destructors - //------------------------------------------------------- - /** - * @brief Constructor - * Builds an empty 3D complex. - */ - Mesh_complex_3_in_triangulation_3_base() - : Base() - , tr_() - , edge_facet_counter_() //TODO: parallel! - , manifold_info_initialized_(false) //TODO: parallel! - { - // We don't put it in the initialization list because - // std::atomic has no contructors - number_of_facets_ = 0; - number_of_cells_ = 0; - } - - /// Copy constructor - Mesh_complex_3_in_triangulation_3_base(const Self& rhs) - : Base() - , tr_(rhs.tr_) - , edge_facet_counter_(rhs.edge_facet_counter_) - , manifold_info_initialized_(rhs.manifold_info_initialized_) - { - Init_number_of_elements init; - init(number_of_facets_, rhs.number_of_facets_); - init(number_of_cells_, rhs.number_of_cells_); - } - - /// Move constructor - Mesh_complex_3_in_triangulation_3_base(Self&& rhs) - : Base() - , tr_(std::move(rhs.tr_)) - , edge_facet_counter_(std::move(rhs.edge_facet_counter_)) - , manifold_info_initialized_(std::exchange(rhs.manifold_info_initialized_, false)) - { - Init_number_of_elements init; - init(number_of_facets_, rhs.number_of_facets_); - init(number_of_cells_, rhs.number_of_cells_); - init(rhs.number_of_facets_); // set to 0 - init(rhs.number_of_cells_); // set to 0 - } - - /// Destructor - ~Mesh_complex_3_in_triangulation_3_base() {} - - void clear() { - number_of_cells_ = 0; - number_of_facets_ = 0; - clear_manifold_info(); - tr_.clear(); - } - - /// Assignment operator - Self& operator=(Self rhs) - { - swap(rhs); - return *this; - } - - /// Assignment operator, also serves as move-assignment - Self& operator=(Self&& rhs) - { - swap(rhs); - return *this; - } - - /// Returns the reference to the triangulation - Triangulation& triangulation() { return tr_; } - /// Returns a const reference to the triangulation - const Triangulation& triangulation() const { return tr_; } - - - /// Adds facet \c facet to the 2D complex, with surface index \c index - void add_to_complex(const Facet& facet, const Surface_patch_index& index) - { - add_to_complex(facet.first, facet.second, index); - } - - /// Adds facet(\c cell, \c i) to the 2D complex, with surface index \c index - void add_to_complex(const Cell_handle& cell, - const int i, - const Surface_patch_index& index); - - /// Removes facet \c facet from 2D complex - void remove_from_complex(const Facet& facet); - - /// Removes facet(\c cell, \c i) from 2D complex - void remove_from_complex(const Cell_handle& c, const int i) { - remove_from_complex(Facet(c, i)); - } - - /// Sets surface index of facet \c facet to \c index - void set_surface_patch_index(const Facet& f, const Surface_patch_index& index) - { - set_surface_patch_index(f.first, f.second, index); - } - - /// Sets surface index of facet(\c cell, \c i) to \c index - void set_surface_patch_index(const Cell_handle& cell, - const int i, - const Surface_patch_index& index) const - { - cell->set_surface_patch_index(i, index); - } - - /// Returns `NOT_IN_COMPLEX`, `BOUNDARY`, `REGULAR`, or `SINGULAR`, - /// depending on the number of incident facets in the complex, and the - /// number of connected components of its link - Face_status face_status(const Vertex_handle v) const - { - if(!manifold_info_initialized_) init_manifold_info(); - const std::size_t n = v->cached_number_of_incident_facets(); - - if(n == 0) return NOT_IN_COMPLEX; - - //test incident edges for REGULARITY and count BOUNDARY edges - typename std::vector edges; - edges.reserve(64); - if(tr_.is_parallel()) { - tr_.incident_edges_threadsafe(v, std::back_inserter(edges)); - } else { - tr_.incident_edges(v, std::back_inserter(edges)); - } - int number_of_boundary_incident_edges = 0; // could be a bool - for (typename std::vector::iterator - eit=edges.begin(), end = edges.end(); - eit != end; eit++) - { - switch( face_status(*eit) ) - { - case NOT_IN_COMPLEX: case REGULAR: break; - case BOUNDARY: ++number_of_boundary_incident_edges; break; - default : -#ifdef CGAL_MESHES_DEBUG_REFINEMENT_POINTS - std::cerr << "singular edge...\n"; - std::cerr << tr_.point(v) << std::endl; -#endif // CGAL_MESHES_DEBUG_REFINEMENT_POINTS - return SINGULAR; - } - } - - // From here all incident edges (in complex) are REGULAR or BOUNDARY. - const std::size_t nb_components = union_find_of_incident_facets(v); - if(nb_components > 1) { -#ifdef CGAL_MESHES_DEBUG_REFINEMENT_POINTS - std::cerr << "singular vertex: nb_components=" << nb_components << std::endl; - std::cerr << tr_.point(v) << std::endl; -#endif // CGAL_MESHES_DEBUG_REFINEMENT_POINTS - return SINGULAR; - } - else { // REGULAR OR BOUNDARY -#ifdef CGAL_MESHES_DEBUG_REFINEMENT_POINTS - std::cerr << "regular or boundary: " << tr_.point(v) << std::endl; -#endif // CGAL_MESHES_DEBUG_REFINEMENT_POINTS - if (number_of_boundary_incident_edges != 0) - return BOUNDARY; - else - return REGULAR; - } - } - - /// This function should be called only when incident edges - /// are known to be REGULAR OR BOUNDARY - bool is_regular_or_boundary_for_vertices(Vertex_handle v) const { - return union_find_of_incident_facets(v) == 1; - } - - /// Returns `NOT_IN_COMPLEX`, `BOUNDARY`, `REGULAR`, or `SINGULAR`, - /// depending on the number of incident facets in the complex - Face_status face_status(const Edge& edge) const - { - if(!manifold_info_initialized_) init_manifold_info(); - -#ifdef CGAL_LINKED_WITH_TBB - typename Edge_facet_counter::const_accessor accessor; - if(!edge_facet_counter_.find(accessor, - this->make_ordered_pair(edge))) - return NOT_IN_COMPLEX; - switch(accessor->second) -#else // not CGAL_LINKED_WITH_TBB - switch(edge_facet_counter_[this->make_ordered_pair(edge)]) -#endif // not CGAL_LINKED_WITH_TBB - { - case 0: return NOT_IN_COMPLEX; - case 1: return BOUNDARY; - case 2: return REGULAR; - default: return SINGULAR; - } - } - - /// Returns true if the vertex \c v has is incident to at least a facet - /// of the complex - bool has_incident_facets_in_complex(const Vertex_handle& v) const - { - if(!manifold_info_initialized_) init_manifold_info(); - return v->cached_number_of_incident_facets() > 0; - } - - /// Returns true if facet \c facet is in complex - bool is_in_complex(const Facet& facet) const - { - return is_in_complex(facet.first, facet.second); - } - - /// Returns true if facet (\c cell, \c i) is in 2D complex - bool is_in_complex(const Cell_handle& cell, const int i) const - { - return ( cell->is_facet_on_surface(i) ); - } - - /// Returns surface index of facet \c f - Surface_patch_index surface_patch_index(const Facet& f) const - { - return surface_patch_index(f.first,f.second); - } - - /// Returns surface index of facet(\c cell, \c i) - Surface_patch_index surface_patch_index(const Cell_handle& cell, - const int i) const - { - return cell->surface_patch_index(i); - } - - /// Returns the number of surface facets of the mesh - size_type number_of_facets_in_complex() const { return number_of_facets_; } - - /// Adds cell \c cell to the 3D complex, with subdomain index \c index - void add_to_complex(const Cell_handle& cell, const Subdomain_index& index) - { - CGAL_precondition( !( index == Subdomain_index() ) ); - - if ( ! is_in_complex(cell) ) - { - set_subdomain_index(cell, index); - ++number_of_cells_; - } - } - - /// Removes cell \c cell from the 3D complex - void remove_from_complex(const Cell_handle& cell) - { - if ( is_in_complex(cell) ) - { - set_subdomain_index(cell, Subdomain_index()); - --number_of_cells_; - } - } - - - /// Sets subdomain index of cell \c cell to \c index - void set_subdomain_index(const Cell_handle& cell, - const Subdomain_index& index) const - { - cell->set_subdomain_index(index); - } - - /// Sets index of vertex \c vertex to \c index - void set_index(const Vertex_handle& vertex, const Index& index) const - { - vertex->set_index(index); - } - - /// Sets dimension of vertex \c vertex to \c dimension - void set_dimension(const Vertex_handle& vertex, int dimension) const - { - vertex->set_dimension(dimension); - } - - /// Returns the number of cells which belongs to the 3D complex - size_type number_of_cells_in_complex() const - { - return number_of_cells_; - } - - /// Returns \c true if cell \c cell belongs to the 3D complex - bool is_in_complex(const Cell_handle& cell) const - { - return !( subdomain_index(cell) == Subdomain_index() ); - } - - /// Returns the subdomain index of cell \c cell - Subdomain_index subdomain_index(const Cell_handle& cell) const - { - return cell->subdomain_index(); - } - - /// Returns the dimension of the lowest dimensional face of the input 3D - /// complex that contains the vertex - int in_dimension(const Vertex_handle& v) const { return v->in_dimension(); } - - /// Returns the index of vertex \c v - Index index(const Vertex_handle& v) const { return v->index(); } - - /// Outputs the mesh to medit - void output_to_medit(std::ostream& os, - bool rebind = true, - bool show_patches = false) const - { - // Call global function - CGAL::output_to_medit(os,*this,rebind,show_patches); - } - - /// Outputs the mesh to maya - void output_to_maya(std::ostream& os, - bool surfaceOnly = true) const - { - // Call global function - CGAL::output_to_maya(os,*this,surfaceOnly); - } - - //------------------------------------------------------- - // Undocumented features - //------------------------------------------------------- - /** - * @brief insert \c [first,last[ in the triangulation (with dimension 2) - * @param first the iterator on the first point to insert - * @param last the iterator past the last point to insert - * - * InputIterator value type must be \c std::pair - */ - template - void insert_surface_points(InputIterator first, InputIterator last) - { - typename Tr::Geom_traits::Construct_weighted_point_3 cwp = - tr_.geom_traits().construct_weighted_point_3_object(); - - while ( first != last ) - { - Vertex_handle vertex = tr_.insert(cwp((*first).first)); - vertex->set_index((*first).second); - vertex->set_dimension(2); - ++first; - } - } - - /** - * @brief insert \c [first,last[ in the triangulation (with dimension 2 and - * index \c default_index) - * @param first the iterator on the first point to insert - * @param last the iterator past the last point to insert - * @param default_index the index to be used to insert points - * - * InputIterator value type must be \c Tr::Point - */ - template - void insert_surface_points(InputIterator first, - InputIterator last, - const Index& default_index) - { - typename Tr::Geom_traits::Construct_weighted_point_3 cwp = - tr_.geom_traits().construct_weighted_point_3_object(); - - while ( first != last ) - { - Vertex_handle vertex = tr_.insert(cwp(*first)); - vertex->set_index(default_index); - vertex->set_dimension(2); - ++first; - } - } - - /// Swaps this & rhs - void swap(Self& rhs) - { - Swap_elements swapper; - swapper(rhs.number_of_facets_, number_of_facets_); - tr_.swap(rhs.tr_); - swapper(rhs.number_of_cells_, number_of_cells_); - } - - /// Returns bbox - Bbox_3 bbox() const; - - void clear_cells_and_facets_from_c3t3() { - for(typename Tr::Finite_cells_iterator - cit = this->triangulation().finite_cells_begin(), - end = this->triangulation().finite_cells_end(); - cit != end; ++cit) - { - set_subdomain_index(cit, Subdomain_index()); - } - this->number_of_cells_ = 0; - for(typename Tr::Finite_facets_iterator - fit = this->triangulation().finite_facets_begin(), - end = this->triangulation().finite_facets_end(); - fit != end; ++fit) - { - Facet facet = *fit; - set_surface_patch_index(facet.first, facet.second, Surface_patch_index()); - if(this->triangulation().dimension() > 2) { - Facet mirror = tr_.mirror_facet(facet); - set_surface_patch_index(mirror.first, mirror.second, Surface_patch_index()); - } - } - this->number_of_facets_ = 0; - clear_manifold_info(); - } - - void clear_manifold_info() { - edge_facet_counter_.clear(); - manifold_info_initialized_ = false; - } - -private: - void init_manifold_info() const { - for(typename Tr::All_vertices_iterator - vit = triangulation().finite_vertices_begin(), - end = triangulation().finite_vertices_end(); - vit != end; ++vit) - { - vit->set_c2t3_cache(0, (std::numeric_limits::max)()); - } - - edge_facet_counter_.clear(); - - for(typename Tr::Finite_facets_iterator - fit = triangulation().finite_facets_begin(), - end = triangulation().finite_facets_end(); - fit != end; ++fit) - { - if ( is_in_complex(*fit) ) { - const Cell_handle cell = fit->first; - const int i = fit->second; - for(int j = 0; j < 3; ++j) - { - const int edge_index_va = tr_.vertex_triple_index(i, j); - const int edge_index_vb = tr_.vertex_triple_index(i, (j == 2) ? 0 : (j+1)); - const Vertex_handle edge_va = cell->vertex(edge_index_va); - const Vertex_handle edge_vb = cell->vertex(edge_index_vb); -#ifndef CGAL_LINKED_WITH_TBB - ++edge_facet_counter_[this->make_ordered_pair(edge_va, edge_vb)]; -#else // CGAL_LINKED_WITH_TBB - { - typename Edge_facet_counter::accessor accessor; - edge_facet_counter_.insert(accessor, - this->make_ordered_pair(edge_va, edge_vb)); - ++accessor->second; - } -#endif // CGAL_LINKED_WITH_TBB - - const std::size_t n = edge_va->cached_number_of_incident_facets(); - edge_va->set_c2t3_cache(n+1, (std::numeric_limits::max)()); - } - } - } - manifold_info_initialized_ = true; - } - - /// Extract the subset `F` of facets of the complex incident to `v` and - /// return the number of connected component of the adjacency graph of `F`. - std::size_t union_find_of_incident_facets(const Vertex_handle v) const - { - if( v->is_c2t3_cache_valid() ) - { - const std::size_t n = v->cached_number_of_components(); - if(n != (std::numeric_limits::max)()) return n; - } - - Union_find facets; - { // fill the union find - std::vector non_filtered_facets; - if(tr_.is_parallel()) { - tr_.incident_facets_threadsafe(v, std::back_inserter(non_filtered_facets)); - } else { - tr_.incident_facets(v, std::back_inserter(non_filtered_facets)); - } - - for(typename std::vector::iterator - fit = non_filtered_facets.begin(), - end = non_filtered_facets.end(); - fit != end; ++fit) - { - if(is_in_complex(*fit)) facets.push_back(*fit); - } - } - - typedef boost::unordered_map::handle, - Hash_fct> Vertex_set_map; - typedef typename Vertex_set_map::iterator Vertex_set_map_iterator; - - Vertex_set_map vsmap; - - for(typename Union_find::iterator - it = facets.begin(), end = facets.end(); - it != end; ++it) - { - const Cell_handle& ch = (*it).first; - const int& i = (*it).second; - for(int j=0; j < 3; ++j) { - const Vertex_handle w = ch->vertex(tr_.vertex_triple_index(i,j)); - if(w != v){ - Vertex_set_map_iterator vsm_it = vsmap.find(w); - if(vsm_it != vsmap.end()){ - facets.unify_sets(vsm_it->second, it); - } else { - vsmap.insert(std::make_pair(w, it)); - } - } - } - } - const std::size_t nb_components = facets.number_of_sets(); - - const std::size_t n = v->cached_number_of_incident_facets(); - v->set_c2t3_cache(n, nb_components); - return nb_components; - } - - //------------------------------------------------------- - // Traversal - //------------------------------------------------------- -private: - typedef MDS_3::internal::Iterator_not_in_complex Iterator_not_in_complex; - - class Facet_iterator_not_in_complex - { - const Self* c3t3_; - Surface_patch_index index_; //need by SWIG: should be const Surface_patch_index - public: - Facet_iterator_not_in_complex(){} //need by SWIG - Facet_iterator_not_in_complex(const Self& c3t3, - const Surface_patch_index& index = Surface_patch_index()) - : c3t3_(&c3t3) - , index_(index) { } - - template - bool operator()(Iterator it) const - { - if ( index_ == Surface_patch_index() ) { return ! c3t3_->is_in_complex(*it); } - else { return !( c3t3_->surface_patch_index(*it) == index_ ); } - } - }; - - /** - * @class Cell_not_in_complex - * @brief A class to filter cells which do not belong to the complex - */ - class Cell_not_in_complex - { - const Self* r_self_; - Subdomain_index index_;//needed by SWIG, should be const Subdomain_index - public: - Cell_not_in_complex(){}//needed by SWIG - Cell_not_in_complex(const Self& self, - const Subdomain_index& index = Subdomain_index()) - : r_self_(&self) - , index_(index) { } - - bool operator()(Cell_handle ch) const - { - if ( index_ == Subdomain_index() ) { return !r_self_->is_in_complex(ch); } - else { return !( r_self_->subdomain_index(ch) == index_ ); } - } - }; // end class Cell_not_in_complex - -public: - /// Iterator type to visit the facets of the 2D complex. - typedef Filter_iterator< - typename Triangulation::Finite_facets_iterator, - Facet_iterator_not_in_complex > Facets_in_complex_iterator; - - /// Returns a Facets_in_complex_iterator to the first facet of the 2D complex - Facets_in_complex_iterator facets_in_complex_begin() const - { - return CGAL::filter_iterator(tr_.finite_facets_end(), - Facet_iterator_not_in_complex(*this), - tr_.finite_facets_begin()); - } - - /// Returns a Facets_in_complex_iterator to the first facet of the 2D complex - Facets_in_complex_iterator - facets_in_complex_begin(const Surface_patch_index& index) const - { - return CGAL::filter_iterator(tr_.finite_facets_end(), - Facet_iterator_not_in_complex(*this,index), - tr_.finite_facets_begin()); - } - - /// Returns past-the-end iterator on facet of the 2D complex - Facets_in_complex_iterator facets_in_complex_end(const Surface_patch_index = Surface_patch_index()) const - { - return CGAL::filter_iterator(tr_.finite_facets_end(), - Facet_iterator_not_in_complex(*this)); - } - - /** - * @class Cells_in_complex_iterator - * @brief Iterator type to visit the cells of triangulation belonging - * to the 3D complex - * - * This class is usefull to ensure that Cells_in_complex_iterator is convertible - * to Cell_handle - */ - class Cells_in_complex_iterator : - public Filter_iterator - { - private: - typedef typename Triangulation::Finite_cells_iterator Tr_iterator; - typedef Filter_iterator Base; - typedef Cells_in_complex_iterator Self; - - public: - Cells_in_complex_iterator() : Base() { } - Cells_in_complex_iterator(Base i) : Base(i) { } - - Self& operator++() { Base::operator++(); return *this; } - Self& operator--() { Base::operator--(); return *this; } - Self operator++(int) { Self tmp(*this); ++(*this); return tmp; } - Self operator--(int) { Self tmp(*this); --(*this); return tmp; } - - operator Cell_handle() const { return Cell_handle(this->base()); } - }; // end class Cells_in_complex_iterator - - - /// Returns a \c Cells_in_complex_iterator to the first cell of the 3D complex - Cells_in_complex_iterator cells_in_complex_begin() const - { - return CGAL::filter_iterator(tr_.finite_cells_end(), - Cell_not_in_complex(*this), - tr_.finite_cells_begin()); - } - - /// Returns a \c Cells_in_complex_iterator to the first cell of the 3D complex - Cells_in_complex_iterator - cells_in_complex_begin(const Subdomain_index& index) const - { - return CGAL::filter_iterator(tr_.finite_cells_end(), - Cell_not_in_complex(*this,index), - tr_.finite_cells_begin()); - } - - /// Returns the past-the-end iterator for the cells of the 3D complex - Cells_in_complex_iterator cells_in_complex_end() const - { - return CGAL::filter_iterator(tr_.finite_cells_end(), - Cell_not_in_complex(*this)); - } - - // ----------------------------------- - // Backward Compatibility - // ----------------------------------- -#ifndef CGAL_MESH_3_NO_DEPRECATED_SURFACE_INDEX - typedef Surface_patch_index Surface_index; - - void set_surface_index(const Facet& f, const Surface_index& index) - { set_surface_patch_index(f, index); } - - void set_surface_index(const Cell_handle& c, const int i, const Surface_index& index) - { set_surface_patch_index(c,i,index); } - - Surface_index surface_index(const Facet& f) const - { return surface_patch_index(f); } - - Surface_index surface_index(const Cell_handle& c, const int i) const - { return surface_patch_index(c,i); } -#endif // CGAL_MESH_3_NO_DEPRECATED_SURFACE_INDEX - -#ifndef CGAL_MESH_3_NO_DEPRECATED_C3T3_ITERATORS - typedef Facets_in_complex_iterator Facet_iterator; - typedef Cells_in_complex_iterator Cell_iterator; - - Facet_iterator facets_begin() const - { return facets_in_complex_begin(); } - - Facet_iterator facets_end() const - { return facets_in_complex_end(); } - - Cell_iterator cells_begin() const - { return cells_in_complex_begin(); } - - Cell_iterator cells_end() const - { return cells_in_complex_end(); } -#endif // CGAL_MESH_3_NO_DEPRECATED_C3T3_ITERATORS - // ----------------------------------- - // End backward Compatibility - // ----------------------------------- - - size_type number_of_facets() const - { return number_of_facets_in_complex(); } - - size_type number_of_cells() const - { return number_of_cells_in_complex(); } - -public: - template - friend - std::istream & - operator>> (std::istream& is, - Mesh_complex_3_in_triangulation_3_base &c3t3); - - void rescan_after_load_of_triangulation(); - - static - std::string io_signature() - { - return - Get_io_signature()(); - } -private: - - // Sequential: non-atomic - // "dummy" is here to allow the specialization (see below) - // See http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/285ab1eec49e1cb6 - template - struct Number_of_elements - { - typedef size_type type; - }; - - template - struct Init_number_of_elements - { - template - void operator()(T& a, const T& b) - { - a = b; - } - template - void operator()(T& a) - { - a = 0; - } - }; - - template - struct Swap_elements - { - template - void operator()(T& a, T& b) - { - std::swap(a, b); - } - }; -#ifdef CGAL_LINKED_WITH_TBB - // Parallel: atomic - template - struct Number_of_elements - { - typedef std::atomic type; - }; - - template - struct Init_number_of_elements - { - template - void operator()(T& a, const T& b) - { - a = b.load(); - } - template - void operator()(T& a) - { - a = 0; - } - }; - - template - struct Swap_elements - { - template - void operator()(T& a, T& b) - { - T tmp; - tmp.exchange(a); - a.exchange(b); - b.exchange(tmp); - } - }; -#endif // CGAL_LINKED_WITH_TBB - - // Private date members - Triangulation tr_; - - typedef typename Base::Pair_of_vertices Pair_of_vertices; -#ifdef CGAL_LINKED_WITH_TBB - typedef tbb::concurrent_hash_map Edge_facet_counter; -#else // not CGAL_LINKED_WITH_TBB - typedef std::map Edge_facet_counter; -#endif // not CGAL_LINKED_WITH_TBB - - mutable Edge_facet_counter edge_facet_counter_; - - typename Number_of_elements::type number_of_facets_; - typename Number_of_elements::type number_of_cells_; - - mutable bool manifold_info_initialized_; -}; // end class Mesh_complex_3_in_triangulation_3_base - - -template -void -Mesh_complex_3_in_triangulation_3_base::add_to_complex( - const Cell_handle& cell, - const int i, - const Surface_patch_index& index) -{ - CGAL_precondition( !( index == Surface_patch_index() ) ); - - if ( ! is_in_complex(cell,i) ) - { - Facet mirror = tr_.mirror_facet(std::make_pair(cell,i)); - set_surface_patch_index(cell, i, index); - set_surface_patch_index(mirror.first, mirror.second, index); - ++number_of_facets_; - if(manifold_info_initialized_) { - for(int j = 0; j < 3; ++j) - { - int edge_index_va = tr_.vertex_triple_index(i, j); - int edge_index_vb = tr_.vertex_triple_index(i, (j == 2) ? 0 : (j+1)); - Vertex_handle edge_va = cell->vertex(edge_index_va); - Vertex_handle edge_vb = cell->vertex(edge_index_vb); -#ifdef CGAL_LINKED_WITH_TBB - { - typename Edge_facet_counter::accessor accessor; - edge_facet_counter_.insert(accessor, - this->make_ordered_pair(edge_va, edge_vb)); - ++accessor->second; - } -#else // not CGAL_LINKED_WITH_TBB - ++edge_facet_counter_[this->make_ordered_pair(edge_va, edge_vb)]; -#endif // not CGAL_LINKED_WITH_TBB - - const std::size_t n = edge_va->cached_number_of_incident_facets(); - const std::size_t m = edge_va->cached_number_of_components(); - edge_va->set_c2t3_cache(n+1, m); - } - const int dimension_plus_1 = tr_.dimension() + 1; - // update c2t3 for vertices of f - for (int j = 0; j < dimension_plus_1; j++) { - if (j != i) { -#ifdef CGAL_MESHES_DEBUG_REFINEMENT_POINTS - if(cell->vertex(j)->is_c2t3_cache_valid()) - std::cerr << "(" << tr_.point(cell, j) << ")->invalidate_c2t3_cache()\n"; -#endif // CGAL_MESHES_DEBUG_REFINEMENT_POINTS - cell->vertex(j)->invalidate_c2t3_cache(); - } - } - } - } -} - - -template -void -Mesh_complex_3_in_triangulation_3_base::remove_from_complex(const Facet& facet) -{ - if ( is_in_complex(facet) ) - { - Facet mirror = tr_.mirror_facet(facet); - set_surface_patch_index(facet.first, facet.second, Surface_patch_index()); - set_surface_patch_index(mirror.first, mirror.second, Surface_patch_index()); - --number_of_facets_; - if(manifold_info_initialized_) { - const Cell_handle cell = facet.first; - const int i = facet.second; - for(int j = 0; j < 3; ++j) - { - const int edge_index_va = tr_.vertex_triple_index(i, j); - const int edge_index_vb = tr_.vertex_triple_index(i, (j == 2) ? 0 : (j+1)); - const Vertex_handle edge_va = cell->vertex(edge_index_va); - const Vertex_handle edge_vb = cell->vertex(edge_index_vb); -#ifdef CGAL_LINKED_WITH_TBB - { - typename Edge_facet_counter::accessor accessor; - edge_facet_counter_.insert(accessor, - this->make_ordered_pair(edge_va, edge_vb)); - --accessor->second; - } -#else // not CGAL_LINKED_WITH_TBB - --edge_facet_counter_[this->make_ordered_pair(edge_va, edge_vb)]; -#endif // not CGAL_LINKED_WITH_TBB - - const std::size_t n = edge_va->cached_number_of_incident_facets(); - CGAL_assertion(n>0); - const std::size_t m = edge_va->cached_number_of_components(); - edge_va->set_c2t3_cache(n-1, m); - } - const int dimension_plus_1 = tr_.dimension() + 1; - // update c2t3 for vertices of f - for (int j = 0; j < dimension_plus_1; j++) { - if (j != facet.second) { -#ifdef CGAL_MESHES_DEBUG_REFINEMENT_POINTS - if(cell->vertex(j)->is_c2t3_cache_valid()) - std::cerr << "(" << tr_.point(cell, j) << ")->invalidate_c2t3_cache()\n"; -#endif // CGAL_MESHES_DEBUG_REFINEMENT_POINTS - cell->vertex(j)->invalidate_c2t3_cache(); - } - } - } - } -} - - -// ----------------------------------- -// Undocumented -// ----------------------------------- -template -Bbox_3 -Mesh_complex_3_in_triangulation_3_base:: -bbox() const -{ - if ( 0 == triangulation().number_of_vertices() ) - { - return Bbox_3(); - } - - typename Tr::Finite_vertices_iterator vit = tr_.finite_vertices_begin(); - Bbox_3 result = tr_.point(vit++).bbox(); - - for(typename Tr::Finite_vertices_iterator end = tr_.finite_vertices_end(); - vit != end ; ++vit) - { - result = result + tr_.point(vit).bbox(); - } - - return result; -} - -template -std::ostream & -operator<< (std::ostream& os, - const Mesh_complex_3_in_triangulation_3_base &c3t3) -{ - return os << c3t3.triangulation(); -} - - -template -std::istream & -operator>> (std::istream& is, - Mesh_complex_3_in_triangulation_3_base &c3t3) -{ - c3t3.clear(); - is >> c3t3.triangulation(); - - if(!is) { - c3t3.clear(); - return is; - } - - c3t3.rescan_after_load_of_triangulation(); - return is; -} - -template -void -Mesh_complex_3_in_triangulation_3_base:: -rescan_after_load_of_triangulation() { - this->number_of_facets_ = 0; - for(typename Tr::Finite_facets_iterator - fit = this->triangulation().finite_facets_begin(), - end = this->triangulation().finite_facets_end(); - fit != end; ++fit) - { - if ( this->is_in_complex(*fit) ) { - ++this->number_of_facets_; - } - } - - this->number_of_cells_ = 0; - for(typename Tr::Finite_cells_iterator - cit = this->triangulation().finite_cells_begin(), - end = this->triangulation().finite_cells_end(); - cit != end; ++cit) - { - if ( this->is_in_complex(cit) ) { - ++this->number_of_cells_; - } - } -} - -} // end namespace MDS_3 -} // end namespace CGAL - -#include - -#endif // CGAL_MESH_3_MESH_COMPLEX_3_IN_TRIANGULATION_3_BASE_H diff --git a/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 9016ff5a129..5af0e044041 100644 --- a/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -24,9 +24,14 @@ #include #include #include -#include #include #include +#include +#include +#include + +#include +#include #include #include @@ -36,12 +41,86 @@ #include #include #include +#include + +#include +#include + + +#ifdef CGAL_LINKED_WITH_TBB +#include +#include + +namespace CGAL { + template < class DSC, bool Const > + std::size_t tbb_hasher(const CGAL::internal::CC_iterator& it) + { + return CGAL::internal::hash_value(it); + } + + // As Marc Glisse pointed out the TBB hash of a std::pair is + // simplistic and leads to the + // TBB Warning: Performance is not optimal because the hash function + // produces bad randomness in lower bits in class + // tbb::interface5::concurrent_hash_map + template < class DSC, bool Const > + std::size_t tbb_hasher(const std::pair, + CGAL::internal::CC_iterator >& p) + { + return boost::hash, + CGAL::internal::CC_iterator > >()(p); + } +}//end namespace CGAL +#endif namespace CGAL { + namespace MDS_3 { + + namespace details { + + template + class C3t3_helper_class + { + protected: + typedef typename Tr::Vertex_handle Vertex_handle; + typedef typename Tr::Cell_handle Cell_handle; + typedef typename Tr::Facet Facet; + typedef typename Tr::Edge Edge; + + typedef std::pair Pair_of_vertices; + + // computes and returns an ordered pair of Vertex + Pair_of_vertices + make_ordered_pair(const Vertex_handle vh1, const Vertex_handle vh2) const { + if (vh1 < vh2) { + return std::make_pair(vh1, vh2); + } + else { + return std::make_pair(vh2, vh1); + } + } + // same from an Edge + Pair_of_vertices + make_ordered_pair(const Edge e) const { + return make_ordered_pair(e.first->vertex(e.second), + e.first->vertex(e.third)); + } + Facet canonical_facet(Cell_handle c, int i) const { + Cell_handle c2 = c->neighbor(i); + return (c2 < c) ? std::make_pair(c2, c2->index(c)) : std::make_pair(c, i); + } + }; // end class template C3t3_helper_class + + } // end namespace MDS_3::details + } //end namesapce MDS_3 + /*! \ingroup PkgMDS3Classes + * @brief A data-structure to represent and maintain a 3D complex embedded + * in a 3D triangulation. + The class `Mesh_complex_3_in_triangulation_3` implements a data structure to store the 3D restricted Delaunay triangulation used by a mesh generation process. @@ -80,8 +159,7 @@ template class Mesh_complex_3_in_triangulation_3 : - public MDS_3::Mesh_complex_3_in_triangulation_3_base< - Tr, typename Tr::Concurrency_tag> + public CGAL::MDS_3::details::C3t3_helper_class , public CGAL::MDS_3::internal::Debug_messages_tools { public: @@ -89,9 +167,8 @@ public: private: typedef Mesh_complex_3_in_triangulation_3< - Tr,CornerIndex,CurveIndex> Self; - typedef MDS_3::Mesh_complex_3_in_triangulation_3_base< - Tr,Concurrency_tag> Base; + Tr,CornerIndex,CurveIndex> Self; + typedef MDS_3::details::C3t3_helper_class Base; typedef CGAL::Hash_handles_with_or_without_timestamps Hash_fct; public: @@ -131,20 +208,6 @@ public: typedef CurveIndex Curve_index; /// @} -#ifndef DOXYGEN_RUNNING - BOOST_STATIC_ASSERT( - boost::is_same::value); - BOOST_STATIC_ASSERT( - boost::is_same::value); - BOOST_STATIC_ASSERT( - boost::is_same::value); - BOOST_STATIC_ASSERT( - boost::is_same::value); - BOOST_STATIC_ASSERT( - boost::is_same::value); - BOOST_STATIC_ASSERT( - boost::is_same::value); -#endif private: // Type to store the edges: @@ -168,13 +231,35 @@ private: typedef std::vector Far_vertices_vec; public: + enum Face_status { + NOT_IN_COMPLEX = 0, + ISOLATED = 1, // - An ISOLATED edge is a marked edge, + // without any incident facets. + BOUNDARY, // - An edge is on BOUNDARY if it has only + // one incident facet. + // - A vertex is on BOUNDARY if all its + // incident edges are REGULAR or on + // BOUNDARY, at least one is on + // BOUNDARY, and the incident facets + // form only one connected component. + REGULAR, // - A facet that is in the complex is + // REGULAR. + // - An edge is REGULAR if it has + // exactly two incident facets. + // - A vertex is REGULAR if all it + // incident edges are REGULAR, and the + // incident facets form only one + // connected component. + SINGULAR // - SINGULAR is for all other cases. + }; + /// \name Constructors /// @{ /** - * Default constructor + * @brief Constructor + * Builds an empty 3D complex. */ - Mesh_complex_3_in_triangulation_3() = default; - + Mesh_complex_3_in_triangulation_3(); /** * Copy constructor */ @@ -183,16 +268,12 @@ public: /** * Move constructor */ - Mesh_complex_3_in_triangulation_3(Self&& rhs) - : Base(std::move(rhs)) - , edges_(std::move(rhs.edges_)) - , corners_(std::move(rhs.corners_)) - , far_vertices_(std::move(rhs.far_vertices_)) - {} + Mesh_complex_3_in_triangulation_3(Self&& rhs); /// @} /// \name Operators /// @{ + /** * Assignement operator, also serves as move-assignement */ @@ -203,11 +284,15 @@ public: } /** - * Swaps this & rhs + * Swaps `this` and `rhs` */ void swap(Self& rhs) { - Base::swap(rhs); + Swap_elements swapper; + swapper(rhs.number_of_facets_, number_of_facets_); + tr_.swap(rhs.tr_); + swapper(rhs.number_of_cells_, number_of_cells_); + edges_.swap(rhs.edges_); corners_.swap(rhs.corners_); far_vertices_.swap(rhs.far_vertices_); @@ -218,23 +303,47 @@ public: */ void clear() { - Base::clear(); + number_of_cells_ = 0; + number_of_facets_ = 0; + clear_manifold_info(); + tr_.clear(); edges_.clear(); corners_.clear(); far_vertices_.clear(); } /// @} - /// Import Base functions - using Base::is_in_complex; - using Base::add_to_complex; - using Base::remove_from_complex; - using Base::triangulation; - using Base::set_surface_patch_index; - using Base::surface_patch_index; + /// Returns the reference to the triangulation + Triangulation& triangulation() { return tr_; } + /// Returns a const reference to the triangulation + const Triangulation& triangulation() const { return tr_; } - /** - * Add edge e to complex, with Curve_index index + + /** Adds cell \c cell to the 3D complex, with subdomain index \c index + */ + void add_to_complex(const Cell_handle& cell, const Subdomain_index& index) + { + CGAL_precondition(!(index == Subdomain_index())); + + if (!is_in_complex(cell)) + { + set_subdomain_index(cell, index); + ++number_of_cells_; + } + } + /** Adds facet \c facet to the 2D complex, with surface index \c index + */ + void add_to_complex(const Facet& facet, const Surface_patch_index& index) + { + add_to_complex(facet.first, facet.second, index); + } + /** Adds facet(\c cell, \c i) to the 2D complex, with surface index \c index + */ + void add_to_complex(const Cell_handle& cell, + const int i, + const Surface_patch_index& index); + + /** Adds edge e to complex, with Curve_index index */ void add_to_complex(const Edge& e, const Curve_index& index) @@ -245,7 +354,7 @@ public: } /** - * Add edge (v1,v2) to complex, with Curve_index index + * Adds edge (v1,v2) to complex, with Curve_index index */ void add_to_complex(const Vertex_handle& v1, const Vertex_handle& v2, @@ -263,6 +372,25 @@ public: corners_.insert(std::make_pair(v,index)); } + /** Removes cell \c cell from the 3D complex + */ + void remove_from_complex(const Cell_handle& cell) + { + if (is_in_complex(cell)) + { + set_subdomain_index(cell, Subdomain_index()); + --number_of_cells_; + } + } + /** Removes facet \c facet from 2D complex + */ + void remove_from_complex(const Facet& facet); + + /** Removes facet(\c cell, \c i) from 2D complex + */ + void remove_from_complex(const Cell_handle& c, const int i) { + remove_from_complex(Facet(c, i)); + } /** * Remove edge \c e from complex */ @@ -288,6 +416,72 @@ public: v->set_dimension(-1); } + /** Returns the index of vertex \c v + */ + Index index(const Vertex_handle& v) const { return v->index(); } + + /** Sets index of vertex \c vertex to \c index + */ + void set_index(const Vertex_handle& vertex, const Index& index) const + { + vertex->set_index(index); + } + + /** Returns the subdomain index of cell \c cell + */ + Subdomain_index subdomain_index(const Cell_handle& cell) const + { + return cell->subdomain_index(); + } + /** Returns surface index of facet \c f + */ + Surface_patch_index surface_patch_index(const Facet& f) const + { + return surface_patch_index(f.first, f.second); + } + + /** Returns surface index of facet(\c cell, \c i) + */ + Surface_patch_index surface_patch_index(const Cell_handle& cell, + const int i) const + { + return cell->surface_patch_index(i); + } + /** Sets surface index of facet \c facet to \c index + */ + void set_surface_patch_index(const Facet& f, const Surface_patch_index& index) + { + set_surface_patch_index(f.first, f.second, index); + } + /** Sets surface index of facet(\c cell, \c i) to \c index + */ + void set_surface_patch_index(const Cell_handle& cell, + const int i, + const Surface_patch_index& index) const + { + cell->set_surface_patch_index(i, index); + } + + /** Sets subdomain index of cell \c cell to \c index + */ + void set_subdomain_index(const Cell_handle& cell, + const Subdomain_index& index) const + { + cell->set_subdomain_index(index); + } + + /** Sets dimension of vertex \c vertex to \c dimension + */ + void set_dimension(const Vertex_handle& vertex, int dimension) const + { + vertex->set_dimension(dimension); + } + + /** Returns the dimension of the lowest dimensional face of the input 3D + * complex that contains the vertex + */ + int in_dimension(const Vertex_handle& v) const { return v->in_dimension(); } + std::size_t number_of_far_points() const { return far_vertices_.size(); @@ -346,6 +540,28 @@ public: far_vertices_.clear(); } + /** + * Returns the number of cells which belongs to the 3D complex + */ + size_type number_of_cells_in_complex() const { return number_of_cells_; } + /** + * Returns the number of cells which belongs to the 3D complex + */ + size_type number_of_cells() const + { + return number_of_cells_in_complex(); + } + /** + * Returns the number of surface facets of c3t3 + */ + size_type number_of_facets_in_complex() const { return number_of_facets_; } + /** + * Returns the number of surface facets of c3t3 + */ + size_type number_of_facets() const + { + return number_of_facets_in_complex(); + } /** * Returns the number of edges of c3t3 */ @@ -353,6 +569,9 @@ public: { return edges_.size(); } + /** + * Returns the number of edges of c3t3 + */ size_type number_of_edges() const { return edges_.size(); @@ -365,6 +584,9 @@ public: { return corners_.size(); } + /** + * Returns the number of corners of c3t3 + */ size_type number_of_corners() const { return corners_.size(); @@ -372,6 +594,25 @@ public: void rescan_after_load_of_triangulation(); + /** Returns \c true if cell \c cell belongs to the 3D complex + */ + bool is_in_complex(const Cell_handle& cell) const + { + return !(subdomain_index(cell) == Subdomain_index()); + } + /** Returns true if facet \c facet is in complex + */ + bool is_in_complex(const Facet& facet) const + { + return is_in_complex(facet.first, facet.second); + } + + /** Returns true if facet (\c cell, \c i) is in 2D complex + */ + bool is_in_complex(const Cell_handle& cell, const int i) const + { + return (cell->is_facet_on_surface(i)); + } /** * Returns true if edge \c e is in complex */ @@ -469,9 +710,25 @@ public: Outputs the mesh to `os` in Medit format. */ +#ifdef DOXYGEN_RUNNING void output_to_medit(std::ostream& os) const +#else + void output_to_medit(std::ostream& os, + bool rebind = true, + bool show_patches = false) const +#endif { - Base::output_to_medit(os); + // Call global function + CGAL::output_to_medit(os, *this, rebind, show_patches); + } + + /*! + * Outputs the mesh to `os` in Maya format. + */ + void output_to_maya(std::ostream& os, bool surfaceOnly = true) const + { + // Call global function + CGAL::output_to_maya(os, *this, surfaceOnly); } /// @} @@ -489,15 +746,55 @@ public: // Undocumented // ----------------------------------- - /** - * Returns true if c3t3 is valid - */ bool is_valid(bool verbose = false) const; // ----------------------------------- // Complex traversal // ----------------------------------- private: + /** + * @class Cell_not_in_complex + * @brief A class to filter cells which do not belong to the complex + */ + class Cell_not_in_complex + { + const Self* r_self_; + Subdomain_index index_;//needed by SWIG, should be const Subdomain_index + public: + Cell_not_in_complex() {}//needed by SWIG + Cell_not_in_complex(const Self& self, + const Subdomain_index& index = Subdomain_index()) + : r_self_(&self) + , index_(index) { } + + bool operator()(Cell_handle ch) const + { + if (index_ == Subdomain_index()) { return !r_self_->is_in_complex(ch); } + else { return !(r_self_->subdomain_index(ch) == index_); } + } + }; // end class Cell_not_in_complex + + typedef MDS_3::internal::Iterator_not_in_complex Iterator_not_in_complex; + + class Facet_iterator_not_in_complex + { + const Self* c3t3_; + Surface_patch_index index_; //need by SWIG: should be const Surface_patch_index + public: + Facet_iterator_not_in_complex() {} //need by SWIG + Facet_iterator_not_in_complex(const Self& c3t3, + const Surface_patch_index& index = Surface_patch_index()) + : c3t3_(&c3t3) + , index_(index) { } + + template + bool operator()(Iterator it) const + { + if (index_ == Surface_patch_index()) { return !c3t3_->is_in_complex(*it); } + else { return !(c3t3_->surface_patch_index(*it) == index_); } + } + }; + class Edge_iterator_not_in_complex { const Self& c3t3_; @@ -578,12 +875,108 @@ private: }; public: - /// Iterator type to visit the edges of the 1D complex. +#ifdef DOXYGEN_RUNNING + /// Iterator type to visit the cells of the 3D complex + typedef unspecified_type Cells_in_complex_iterator; + /// Iterator type to visit the facets of the 2D complex + typedef unspecified_type Facets_in_complex_iterator; + /// Iterator type to visit the edges of the 1D complex + typedef unspecified_type Edges_in_complex_iterator; + /// Iterator type to visit the edges of the 0D complex + typedef unspecified_type Vertices_in_complex_iterator; + +#else typedef Filter_iterator< typename Triangulation::Finite_edges_iterator, - Edge_iterator_not_in_complex > Edges_in_complex_iterator; + Edge_iterator_not_in_complex > Edges_in_complex_iterator; + typedef Vertex_map_iterator_first_dereference Vertices_in_complex_iterator; + typedef Filter_iterator< + typename Triangulation::Finite_facets_iterator, + Facet_iterator_not_in_complex > Facets_in_complex_iterator; - /// Returns a Facets_in_complex_iterator to the first facet of the 1D complex + /** + * @class Cells_in_complex_iterator + * @brief Iterator type to visit the cells of triangulation belonging + * to the 3D complex + * + * This class is useful to ensure that Cells_in_complex_iterator is convertible + * to Cell_handle + */ + class Cells_in_complex_iterator : + public Filter_iterator + { + private: + typedef typename Triangulation::Finite_cells_iterator Tr_iterator; + typedef Filter_iterator Base; + typedef Cells_in_complex_iterator Self; + + public: + Cells_in_complex_iterator() : Base() { } + Cells_in_complex_iterator(Base i) : Base(i) { } + + Self& operator++() { Base::operator++(); return *this; } + Self& operator--() { Base::operator--(); return *this; } + Self operator++(int) { Self tmp(*this); ++(*this); return tmp; } + Self operator--(int) { Self tmp(*this); --(*this); return tmp; } + + operator Cell_handle() const { return Cell_handle(this->base()); } + }; // end class Cells_in_complex_iterator + +#endif + +/// \name Iterators +/// @{ + + /// Returns a \c Cells_in_complex_iterator to the first cell of the 3D complex + Cells_in_complex_iterator cells_in_complex_begin() const + { + return CGAL::filter_iterator(tr_.finite_cells_end(), + Cell_not_in_complex(*this), + tr_.finite_cells_begin()); + } + + /// Returns a \c Cells_in_complex_iterator to the first cell of the 3D complex + Cells_in_complex_iterator cells_in_complex_begin(const Subdomain_index& index) const + { + return CGAL::filter_iterator(tr_.finite_cells_end(), + Cell_not_in_complex(*this, index), + tr_.finite_cells_begin()); + } + + /// Returns the past-the-end iterator for the cells of the 3D complex + Cells_in_complex_iterator cells_in_complex_end() const + { + return CGAL::filter_iterator(tr_.finite_cells_end(), + Cell_not_in_complex(*this)); + } + + /// Returns a `Facets_in_complex_iterator` to the first facet of the 2D complex + Facets_in_complex_iterator facets_in_complex_begin() const + { + return CGAL::filter_iterator(tr_.finite_facets_end(), + Facet_iterator_not_in_complex(*this), + tr_.finite_facets_begin()); + } + + /// Returns a `Facets_in_complex_iterator` to the first facet of the 2D complex + Facets_in_complex_iterator + facets_in_complex_begin(const Surface_patch_index& index) const + { + return CGAL::filter_iterator(tr_.finite_facets_end(), + Facet_iterator_not_in_complex(*this, index), + tr_.finite_facets_begin()); + } + + /// Returns past-the-end iterator on facet of the 2D complex + Facets_in_complex_iterator facets_in_complex_end(const Surface_patch_index = Surface_patch_index()) const + { + return CGAL::filter_iterator(tr_.finite_facets_end(), + Facet_iterator_not_in_complex(*this)); + } + + /// Returns a `Edges_in_complex_iterator` to the first edge of the 1D complex Edges_in_complex_iterator edges_in_complex_begin() const { return CGAL::filter_iterator(this->triangulation().finite_edges_end(), @@ -591,7 +984,7 @@ public: this->triangulation().finite_edges_begin()); } - /// Returns a Facets_in_complex_iterator to the first facet of the 1D complex + /// Returns a `Edges_in_complex_iterator` to the first edge of the 1D complex Edges_in_complex_iterator edges_in_complex_begin(const Curve_index& index) const { @@ -600,17 +993,14 @@ public: this->triangulation().finite_edges_begin()); } - /// Returns past-the-end iterator on facet of the 1D complex + /// Returns past-the-end iterator on edges of the 1D complex Edges_in_complex_iterator edges_in_complex_end(const Curve_index& = Curve_index()) const { return CGAL::filter_iterator(this->triangulation().finite_edges_end(), Edge_iterator_not_in_complex(*this)); } - /// Iterator type to visit the edges of the 0D complex. - typedef Vertex_map_iterator_first_dereference Vertices_in_complex_iterator; - - /// Returns a Vertices_in_complex_iterator to the first vertex of the 0D complex + /// Returns a `Vertices_in_complex_iterator` to the first vertex of the 0D complex Vertices_in_complex_iterator vertices_in_complex_begin() const { return CGAL::filter_iterator(corners_.end(), @@ -618,7 +1008,7 @@ public: corners_.begin()); } - /// Returns a Vertices_in_complex_iterator to the first vertex of the 0D complex + /// Returns a `Vertices_in_complex_iterator` to the first vertex of the 0D complex Vertices_in_complex_iterator vertices_in_complex_begin(const Corner_index& index) const { @@ -627,17 +1017,30 @@ public: corners_.begin()); } - /// Returns past-the-end iterator on facet of the 0D complex + /// Returns past-the-end iterator on vertices of the 0D complex Vertices_in_complex_iterator vertices_in_complex_end() const { return CGAL::filter_iterator(corners_.end(), Vertex_iterator_not_in_complex(*this)); } +/// @} + +public: + template + friend + std::istream& operator>>(std::istream& is, + Mesh_complex_3_in_triangulation_3& c3t3); + + static std::string io_signature() + { + return Get_io_signature()(); + } -private: /** + * @cond SKIP_IN_MANUAL * Creates an Internal_edge object (i.e a pair of ordered Vertex_handle) + * @endcond SKIP_IN_MANUAL */ Internal_edge make_internal_edge(const Vertex_handle& v1, const Vertex_handle& v2) const @@ -647,7 +1050,9 @@ private: } /** + * @cond SKIP_IN_MANUAL * Returns true if \c edge is in C3T3 + * @endcond SKIP_IN_MANUAL */ bool is_in_complex(const Internal_edge& edge) const { @@ -655,7 +1060,9 @@ private: } /** - * Add edge \c edge to complex, with Curve_index index + * @cond SKIP_IN_MANUAL + * Add edge \c edge to complex, with `Curve_index` `index` + * @endcond SKIP_IN_MANUAL */ void add_to_complex(const Internal_edge& edge, const Curve_index& index) { @@ -670,7 +1077,9 @@ private: } /** + * @cond SKIP_IN_MANUAL * Remove edge \c edge from complex + * @endcond SKIP_IN_MANUAL */ void remove_from_complex(const Internal_edge& edge) { @@ -678,8 +1087,10 @@ private: } /** - * Returns Curve_index of edge \c edge - */ + * @cond SKIP_IN_MANUAL + * Returns Curve_index of edge \c edge + * @endcond SKIP_IN_MANUAL + */ Curve_index curve_index(const Internal_edge& edge) const { typename Edge_map::const_iterator it = edges_.find(edge); @@ -687,20 +1098,483 @@ private: return Curve_index(); } + /// @cond SKIP_IN_MANUAL + /// Returns `NOT_IN_COMPLEX`, `BOUNDARY`, `REGULAR`, or `SINGULAR`, + /// depending on the number of incident facets in the complex, and the + /// number of connected components of its link + /// @endcond SKIP_IN_MANUAL + Face_status face_status(const Vertex_handle v) const + { + if (!manifold_info_initialized_) init_manifold_info(); + const std::size_t n = v->cached_number_of_incident_facets(); + + if (n == 0) return NOT_IN_COMPLEX; + + //test incident edges for REGULARITY and count BOUNDARY edges + typename std::vector edges; + edges.reserve(64); + if (tr_.is_parallel()) { + tr_.incident_edges_threadsafe(v, std::back_inserter(edges)); + } + else { + tr_.incident_edges(v, std::back_inserter(edges)); + } + int number_of_boundary_incident_edges = 0; // could be a bool + for (typename std::vector::iterator + eit = edges.begin(), end = edges.end(); + eit != end; eit++) + { + switch (face_status(*eit)) + { + case NOT_IN_COMPLEX: case REGULAR: break; + case BOUNDARY: ++number_of_boundary_incident_edges; break; + default: +#ifdef CGAL_MESHES_DEBUG_REFINEMENT_POINTS + std::cerr << "singular edge...\n"; + std::cerr << tr_.point(v) << std::endl; +#endif // CGAL_MESHES_DEBUG_REFINEMENT_POINTS + return SINGULAR; + } + } + + // From here all incident edges (in complex) are REGULAR or BOUNDARY. + const std::size_t nb_components = union_find_of_incident_facets(v); + if (nb_components > 1) { +#ifdef CGAL_MESHES_DEBUG_REFINEMENT_POINTS + std::cerr << "singular vertex: nb_components=" << nb_components << std::endl; + std::cerr << tr_.point(v) << std::endl; +#endif // CGAL_MESHES_DEBUG_REFINEMENT_POINTS + return SINGULAR; + } + else { // REGULAR OR BOUNDARY +#ifdef CGAL_MESHES_DEBUG_REFINEMENT_POINTS + std::cerr << "regular or boundary: " << tr_.point(v) << std::endl; +#endif // CGAL_MESHES_DEBUG_REFINEMENT_POINTS + if (number_of_boundary_incident_edges != 0) + return BOUNDARY; + else + return REGULAR; + } + } + + /// @cond SKIP_IN_MANUAL + /// This function should be called only when incident edges + /// are known to be REGULAR OR BOUNDARY + /// @endcond SKIP_IN_MANUAL + bool is_regular_or_boundary_for_vertices(Vertex_handle v) const { + return union_find_of_incident_facets(v) == 1; + } + + /// @cond SKIP_IN_MANUAL + /// Returns `NOT_IN_COMPLEX`, `BOUNDARY`, `REGULAR`, or `SINGULAR`, + /// depending on the number of incident facets in the complex + /// @endcond SKIP_IN_MANUAL + Face_status face_status(const Edge& edge) const + { + if (!manifold_info_initialized_) init_manifold_info(); + +#ifdef CGAL_LINKED_WITH_TBB + typename Edge_facet_counter::const_accessor accessor; + if (!edge_facet_counter_.find(accessor, + this->make_ordered_pair(edge))) + return NOT_IN_COMPLEX; + switch (accessor->second) +#else // not CGAL_LINKED_WITH_TBB + switch (edge_facet_counter_[this->make_ordered_pair(edge)]) +#endif // not CGAL_LINKED_WITH_TBB + { + case 0: return NOT_IN_COMPLEX; + case 1: return BOUNDARY; + case 2: return REGULAR; + default: return SINGULAR; + } + } + + /// Returns true if the vertex \c v has is incident to at least a facet + /// of the complex + bool has_incident_facets_in_complex(const Vertex_handle& v) const + { + if (!manifold_info_initialized_) init_manifold_info(); + return v->cached_number_of_incident_facets() > 0; + } + + /** + * @cond SKIP_IN_MANUAL + * @brief insert \c [first,last[ in the triangulation (with dimension 2) + * @param first the iterator on the first point to insert + * @param last the iterator past the last point to insert + * + * InputIterator value type must be \c std::pair + * @endcond SKIP_IN_MANUAL + */ + template + void insert_surface_points(InputIterator first, InputIterator last) + { + typename Tr::Geom_traits::Construct_weighted_point_3 cwp = + tr_.geom_traits().construct_weighted_point_3_object(); + + while (first != last) + { + Vertex_handle vertex = tr_.insert(cwp((*first).first)); + vertex->set_index((*first).second); + vertex->set_dimension(2); + ++first; + } + } + + /** + * @cond SKIP_IN_MANUAL + * @brief insert \c [first,last[ in the triangulation (with dimension 2 and + * index \c default_index) + * @param first the iterator on the first point to insert + * @param last the iterator past the last point to insert + * @param default_index the index to be used to insert points + * + * InputIterator value type must be \c Tr::Point + * @endcond SKIP_IN_MANUAL + */ + template + void insert_surface_points(InputIterator first, + InputIterator last, + const Index& default_index) + { + typename Tr::Geom_traits::Construct_weighted_point_3 cwp = + tr_.geom_traits().construct_weighted_point_3_object(); + + while (first != last) + { + Vertex_handle vertex = tr_.insert(cwp(*first)); + vertex->set_index(default_index); + vertex->set_dimension(2); + ++first; + } + } + + void clear_cells_and_facets_from_c3t3() { + for (typename Tr::Finite_cells_iterator + cit = this->triangulation().finite_cells_begin(), + end = this->triangulation().finite_cells_end(); + cit != end; ++cit) + { + set_subdomain_index(cit, Subdomain_index()); + } + this->number_of_cells_ = 0; + for (typename Tr::Finite_facets_iterator + fit = this->triangulation().finite_facets_begin(), + end = this->triangulation().finite_facets_end(); + fit != end; ++fit) + { + Facet facet = *fit; + set_surface_patch_index(facet.first, facet.second, Surface_patch_index()); + if (this->triangulation().dimension() > 2) { + Facet mirror = tr_.mirror_facet(facet); + set_surface_patch_index(mirror.first, mirror.second, Surface_patch_index()); + } + } + this->number_of_facets_ = 0; + clear_manifold_info(); + } + + void clear_manifold_info() { + edge_facet_counter_.clear(); + manifold_info_initialized_ = false; + } + + /** @cond SKIP_IN_MANUAL + * Returns bbox + * @endcond SKIP_IN_MANUAL + */ + Bbox_3 bbox() const; + private: + // Sequential: non-atomic + // "dummy" is here to allow the specialization (see below) + // See http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/285ab1eec49e1cb6 + template + struct Number_of_elements + { + typedef size_type type; + }; + + template + struct Init_number_of_elements + { + template + void operator()(T& a, const T& b) + { + a = b; + } + template + void operator()(T& a) + { + a = 0; + } + }; + + template + struct Swap_elements + { + template + void operator()(T& a, T& b) + { + std::swap(a, b); + } + }; +#ifdef CGAL_LINKED_WITH_TBB + // Parallel: atomic + template + struct Number_of_elements + { + typedef std::atomic type; + }; + + template + struct Init_number_of_elements + { + template + void operator()(T& a, const T& b) + { + a = b.load(); + } + template + void operator()(T& a) + { + a = 0; + } + }; + + template + struct Swap_elements + { + template + void operator()(T& a, T& b) + { + T tmp; + tmp.exchange(a); + a.exchange(b); + b.exchange(tmp); + } + }; +#endif // CGAL_LINKED_WITH_TBB + +private: + void init_manifold_info() const + { + for (typename Tr::All_vertices_iterator + vit = triangulation().finite_vertices_begin(), + end = triangulation().finite_vertices_end(); + vit != end; ++vit) + { + vit->set_c2t3_cache(0, (std::numeric_limits::max)()); + } + + edge_facet_counter_.clear(); + + for (typename Tr::Finite_facets_iterator + fit = triangulation().finite_facets_begin(), + end = triangulation().finite_facets_end(); + fit != end; ++fit) + { + if (is_in_complex(*fit)) { + const Cell_handle cell = fit->first; + const int i = fit->second; + for (int j = 0; j < 3; ++j) + { + const int edge_index_va = tr_.vertex_triple_index(i, j); + const int edge_index_vb = tr_.vertex_triple_index(i, (j == 2) ? 0 : (j + 1)); + const Vertex_handle edge_va = cell->vertex(edge_index_va); + const Vertex_handle edge_vb = cell->vertex(edge_index_vb); +#ifndef CGAL_LINKED_WITH_TBB + ++edge_facet_counter_[this->make_ordered_pair(edge_va, edge_vb)]; +#else // CGAL_LINKED_WITH_TBB + { + typename Edge_facet_counter::accessor accessor; + edge_facet_counter_.insert(accessor, + this->make_ordered_pair(edge_va, edge_vb)); + ++accessor->second; + } +#endif // CGAL_LINKED_WITH_TBB + + const std::size_t n = edge_va->cached_number_of_incident_facets(); + edge_va->set_c2t3_cache(n + 1, (std::numeric_limits::max)()); + } + } + } + manifold_info_initialized_ = true; + } + + /// Extract the subset `F` of facets of the complex incident to `v` and + /// return the number of connected component of the adjacency graph of `F`. + std::size_t union_find_of_incident_facets(const Vertex_handle v) const + { + if (v->is_c2t3_cache_valid()) + { + const std::size_t n = v->cached_number_of_components(); + if (n != (std::numeric_limits::max)()) return n; + } + + Union_find facets; + { // fill the union find + std::vector non_filtered_facets; + if (tr_.is_parallel()) { + tr_.incident_facets_threadsafe(v, std::back_inserter(non_filtered_facets)); + } + else { + tr_.incident_facets(v, std::back_inserter(non_filtered_facets)); + } + + for (typename std::vector::iterator + fit = non_filtered_facets.begin(), + end = non_filtered_facets.end(); + fit != end; ++fit) + { + if (is_in_complex(*fit)) facets.push_back(*fit); + } + } + + typedef boost::unordered_map::handle, + Hash_fct> Vertex_set_map; + typedef typename Vertex_set_map::iterator Vertex_set_map_iterator; + + Vertex_set_map vsmap; + + for (typename Union_find::iterator + it = facets.begin(), end = facets.end(); + it != end; ++it) + { + const Cell_handle& ch = (*it).first; + const int& i = (*it).second; + for (int j = 0; j < 3; ++j) { + const Vertex_handle w = ch->vertex(tr_.vertex_triple_index(i, j)); + if (w != v) { + Vertex_set_map_iterator vsm_it = vsmap.find(w); + if (vsm_it != vsmap.end()) { + facets.unify_sets(vsm_it->second, it); + } + else { + vsmap.insert(std::make_pair(w, it)); + } + } + } + } + const std::size_t nb_components = facets.number_of_sets(); + + const std::size_t n = v->cached_number_of_incident_facets(); + v->set_c2t3_cache(n, nb_components); + return nb_components; + } + +public: + // ----------------------------------- + // Backward Compatibility + // ----------------------------------- +#ifndef DOXYGEN_RUNNING +#ifndef CGAL_MESH_3_NO_DEPRECATED_SURFACE_INDEX + typedef Surface_patch_index Surface_index; + + void set_surface_index(const Facet& f, const Surface_index& index) + { + set_surface_patch_index(f, index); + } + + void set_surface_index(const Cell_handle& c, const int i, const Surface_index& index) + { + set_surface_patch_index(c, i, index); + } + + Surface_index surface_index(const Facet& f) const + { + return surface_patch_index(f); + } + + Surface_index surface_index(const Cell_handle& c, const int i) const + { + return surface_patch_index(c, i); + } +#endif // CGAL_MESH_3_NO_DEPRECATED_SURFACE_INDEX + +#ifndef CGAL_MESH_3_NO_DEPRECATED_C3T3_ITERATORS + typedef Facets_in_complex_iterator Facet_iterator; + typedef Cells_in_complex_iterator Cell_iterator; + + Facet_iterator facets_begin() const + { + return facets_in_complex_begin(); + } + + Facet_iterator facets_end() const + { + return facets_in_complex_end(); + } + + Cell_iterator cells_begin() const + { + return cells_in_complex_begin(); + } + + Cell_iterator cells_end() const + { + return cells_in_complex_end(); + } +#endif // CGAL_MESH_3_NO_DEPRECATED_C3T3_ITERATORS +#endif // DOXYGEN_RUNNING + // ----------------------------------- + // End backward Compatibility + // ----------------------------------- + + +private: + // Private data members + Triangulation tr_; + + typedef typename Base::Pair_of_vertices Pair_of_vertices; +#ifdef CGAL_LINKED_WITH_TBB + typedef tbb::concurrent_hash_map Edge_facet_counter; +#else // not CGAL_LINKED_WITH_TBB + typedef std::map Edge_facet_counter; +#endif // not CGAL_LINKED_WITH_TBB + + mutable Edge_facet_counter edge_facet_counter_; + + typename Number_of_elements::type number_of_facets_; + typename Number_of_elements::type number_of_cells_; + + mutable bool manifold_info_initialized_; + Edge_map edges_; Corner_map corners_; Far_vertices_vec far_vertices_; }; +template +Mesh_complex_3_in_triangulation_3:: +Mesh_complex_3_in_triangulation_3() + : Base() + , tr_() + , edge_facet_counter_() //TODO: parallel! + , manifold_info_initialized_(false) //TODO: parallel! +{ + // We don't put it in the initialization list because + // std::atomic has no contructors + number_of_facets_ = 0; + number_of_cells_ = 0; +} template Mesh_complex_3_in_triangulation_3:: Mesh_complex_3_in_triangulation_3(const Self& rhs) : Base(rhs) + , tr_(rhs.tr_) + , edge_facet_counter_(rhs.edge_facet_counter_) + , manifold_info_initialized_(rhs.manifold_info_initialized_) , edges_() , corners_() { + Init_number_of_elements init; + init(number_of_facets_, rhs.number_of_facets_); + init(number_of_cells_, rhs.number_of_cells_); + // Copy edges for ( typename Edge_map::const_iterator it = rhs.edges_.begin(), end = rhs.edges_.end() ; it != end ; ++it ) @@ -741,6 +1615,23 @@ Mesh_complex_3_in_triangulation_3(const Self& rhs) } } +template +Mesh_complex_3_in_triangulation_3:: +Mesh_complex_3_in_triangulation_3(Self&& rhs) + : Base() + , tr_(std::move(rhs.tr_)) + , edge_facet_counter_(std::move(rhs.edge_facet_counter_)) + , manifold_info_initialized_(std::exchange(rhs.manifold_info_initialized_, false)) + , edges_(std::move(rhs.edges_)) + , corners_(std::move(rhs.corners_)) + , far_vertices_(std::move(rhs.far_vertices_)) +{ + Init_number_of_elements init; + init(number_of_facets_, rhs.number_of_facets_); + init(number_of_cells_, rhs.number_of_cells_); + init(rhs.number_of_facets_); // set to 0 + init(rhs.number_of_cells_); // set to 0 +} template template @@ -837,10 +1728,136 @@ is_valid(bool verbose) const return true; } +template +void +Mesh_complex_3_in_triangulation_3:: +add_to_complex(const Cell_handle& cell, + const int i, + const Surface_patch_index& index) +{ + CGAL_precondition(!(index == Surface_patch_index())); + + if (!is_in_complex(cell, i)) + { + Facet mirror = tr_.mirror_facet(std::make_pair(cell, i)); + set_surface_patch_index(cell, i, index); + set_surface_patch_index(mirror.first, mirror.second, index); + ++number_of_facets_; + if (manifold_info_initialized_) { + for (int j = 0; j < 3; ++j) + { + int edge_index_va = tr_.vertex_triple_index(i, j); + int edge_index_vb = tr_.vertex_triple_index(i, (j == 2) ? 0 : (j + 1)); + Vertex_handle edge_va = cell->vertex(edge_index_va); + Vertex_handle edge_vb = cell->vertex(edge_index_vb); +#ifdef CGAL_LINKED_WITH_TBB + { + typename Edge_facet_counter::accessor accessor; + edge_facet_counter_.insert(accessor, + this->make_ordered_pair(edge_va, edge_vb)); + ++accessor->second; + } +#else // not CGAL_LINKED_WITH_TBB + ++edge_facet_counter_[this->make_ordered_pair(edge_va, edge_vb)]; +#endif // not CGAL_LINKED_WITH_TBB + + const std::size_t n = edge_va->cached_number_of_incident_facets(); + const std::size_t m = edge_va->cached_number_of_components(); + edge_va->set_c2t3_cache(n + 1, m); + } + const int dimension_plus_1 = tr_.dimension() + 1; + // update c2t3 for vertices of f + for (int j = 0; j < dimension_plus_1; j++) { + if (j != i) { +#ifdef CGAL_MESHES_DEBUG_REFINEMENT_POINTS + if (cell->vertex(j)->is_c2t3_cache_valid()) + std::cerr << "(" << tr_.point(cell, j) << ")->invalidate_c2t3_cache()\n"; +#endif // CGAL_MESHES_DEBUG_REFINEMENT_POINTS + cell->vertex(j)->invalidate_c2t3_cache(); + } + } + } + } +} + +template +void +Mesh_complex_3_in_triangulation_3:: +remove_from_complex(const Facet& facet) +{ + if (is_in_complex(facet)) + { + Facet mirror = tr_.mirror_facet(facet); + set_surface_patch_index(facet.first, facet.second, Surface_patch_index()); + set_surface_patch_index(mirror.first, mirror.second, Surface_patch_index()); + --number_of_facets_; + if (manifold_info_initialized_) { + const Cell_handle cell = facet.first; + const int i = facet.second; + for (int j = 0; j < 3; ++j) + { + const int edge_index_va = tr_.vertex_triple_index(i, j); + const int edge_index_vb = tr_.vertex_triple_index(i, (j == 2) ? 0 : (j + 1)); + const Vertex_handle edge_va = cell->vertex(edge_index_va); + const Vertex_handle edge_vb = cell->vertex(edge_index_vb); +#ifdef CGAL_LINKED_WITH_TBB + { + typename Edge_facet_counter::accessor accessor; + edge_facet_counter_.insert(accessor, + this->make_ordered_pair(edge_va, edge_vb)); + --accessor->second; + } +#else // not CGAL_LINKED_WITH_TBB + --edge_facet_counter_[this->make_ordered_pair(edge_va, edge_vb)]; +#endif // not CGAL_LINKED_WITH_TBB + + const std::size_t n = edge_va->cached_number_of_incident_facets(); + CGAL_assertion(n > 0); + const std::size_t m = edge_va->cached_number_of_components(); + edge_va->set_c2t3_cache(n - 1, m); + } + const int dimension_plus_1 = tr_.dimension() + 1; + // update c2t3 for vertices of f + for (int j = 0; j < dimension_plus_1; j++) { + if (j != facet.second) { +#ifdef CGAL_MESHES_DEBUG_REFINEMENT_POINTS + if (cell->vertex(j)->is_c2t3_cache_valid()) + std::cerr << "(" << tr_.point(cell, j) << ")->invalidate_c2t3_cache()\n"; +#endif // CGAL_MESHES_DEBUG_REFINEMENT_POINTS + cell->vertex(j)->invalidate_c2t3_cache(); + } + } + } + } +} + +template +Bbox_3 +Mesh_complex_3_in_triangulation_3:: +bbox() const +{ + if (0 == triangulation().number_of_vertices()) + { + return Bbox_3(); + } + + typename Tr::Finite_vertices_iterator vit = tr_.finite_vertices_begin(); + Bbox_3 result = tr_.point(vit++).bbox(); + + for (typename Tr::Finite_vertices_iterator end = tr_.finite_vertices_end(); + vit != end; ++vit) + { + result = result + tr_.point(vit).bbox(); + } + + return result; +} + template void Mesh_complex_3_in_triangulation_3:: -rescan_after_load_of_triangulation() { +rescan_after_load_of_triangulation() +{ corners_.clear(); for(typename Tr::Finite_vertices_iterator vit = this->triangulation().finite_vertices_begin(), @@ -851,7 +1868,28 @@ rescan_after_load_of_triangulation() { add_to_complex(vit, Corner_index(1)); } } - Base::rescan_after_load_of_triangulation(); + + this->number_of_facets_ = 0; + for (typename Tr::Finite_facets_iterator + fit = this->triangulation().finite_facets_begin(), + end = this->triangulation().finite_facets_end(); + fit != end; ++fit) + { + if (this->is_in_complex(*fit)) { + ++this->number_of_facets_; + } + } + + this->number_of_cells_ = 0; + for (typename Tr::Finite_cells_iterator + cit = this->triangulation().finite_cells_begin(), + end = this->triangulation().finite_cells_end(); + cit != end; ++cit) + { + if (this->is_in_complex(cit)) { + ++this->number_of_cells_; + } + } } template @@ -861,8 +1899,7 @@ operator<< (std::ostream& os, { // TODO: implement edge saving typedef typename Mesh_complex_3_in_triangulation_3::Concurrency_tag Concurrency_tag; - return os << static_cast< - const MDS_3::Mesh_complex_3_in_triangulation_3_base&>(c3t3); + return os << c3t3.triangulation(); } @@ -872,9 +1909,14 @@ operator>> (std::istream& is, Mesh_complex_3_in_triangulation_3 &c3t3) { // TODO: implement edge loading - typedef typename Mesh_complex_3_in_triangulation_3::Concurrency_tag Concurrency_tag; - is >> static_cast< - MDS_3::Mesh_complex_3_in_triangulation_3_base&>(c3t3); + c3t3.clear(); + is >> c3t3.triangulation(); + + if (!is) { + c3t3.clear(); + return is; + } + c3t3.rescan_after_load_of_triangulation(); return is; } diff --git a/MDS_3/test/MDS_3/test_c3t3.cpp b/MDS_3/test/MDS_3/test_c3t3.cpp index a20a8ba74c2..4a9eb729f2f 100644 --- a/MDS_3/test/MDS_3/test_c3t3.cpp +++ b/MDS_3/test/MDS_3/test_c3t3.cpp @@ -37,10 +37,6 @@ struct Tester typedef typename CGAL::Mesh_triangulation_3::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; - typedef CGAL::MDS_3::Mesh_complex_3_in_triangulation_3_base C3t3_base_sequential; - typedef CGAL::MDS_3::Mesh_complex_3_in_triangulation_3_base C3t3_base_parallel; typedef typename Tr::Bare_point Bare_point; typedef typename Tr::Weighted_point Weighted_point; From 44ff89983c0524fab708ef6fc9a76aed5e950d14 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 27 Apr 2021 17:08:16 +0200 Subject: [PATCH 15/79] reorganize code to have documentation sorted as in the concept --- .../CGAL/Mesh_complex_3_in_triangulation_3.h | 239 ++++++++++-------- 1 file changed, 127 insertions(+), 112 deletions(-) diff --git a/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 5af0e044041..4a0e668f10a 100644 --- a/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -172,13 +172,6 @@ private: typedef CGAL::Hash_handles_with_or_without_timestamps Hash_fct; public: - typedef Tr Triangulation; - typedef typename Tr::size_type size_type; - typedef typename Tr::Point Point; - typedef typename Tr::Edge Edge; - typedef typename Tr::Facet Facet; - typedef typename Tr::Vertex_handle Vertex_handle; - typedef typename Tr::Cell_handle Cell_handle; #ifndef CGAL_NO_DEPRECATED_CODE typedef CurveIndex Curve_segment_index; @@ -186,6 +179,13 @@ public: /// \name Types /// @{ + typedef Tr Triangulation; + typedef typename Tr::size_type size_type; + typedef typename Tr::Point Point; + typedef typename Tr::Edge Edge; + typedef typename Tr::Facet Facet; + typedef typename Tr::Vertex_handle Vertex_handle; + typedef typename Tr::Cell_handle Cell_handle; /*! Index type. */ @@ -253,9 +253,9 @@ public: SINGULAR // - SINGULAR is for all other cases. }; -/// \name Constructors +/// \name Creation /// @{ - /** + /** * @brief Constructor * Builds an empty 3D complex. */ @@ -269,14 +269,10 @@ public: * Move constructor */ Mesh_complex_3_in_triangulation_3(Self&& rhs); -/// @} - -/// \name Operators -/// @{ /** - * Assignement operator, also serves as move-assignement - */ + * Assignement operator, also serves as move-assignement + */ Self& operator=(Self rhs) { swap(rhs); @@ -298,6 +294,23 @@ public: far_vertices_.swap(rhs.far_vertices_); } +/// @} + +/// \name Access Functions +/// @{ + /// Returns a const reference to the triangulation + const Triangulation& triangulation() const { return tr_; } +/// @} + +/// \name Non const access +/// @{ + /// Returns the reference to the triangulation + Triangulation& triangulation() { return tr_; } +/// @} + + +/// \name Modifiers +/// @{ /** * Clears data of c3t3 */ @@ -311,13 +324,6 @@ public: corners_.clear(); far_vertices_.clear(); } -/// @} - - /// Returns the reference to the triangulation - Triangulation& triangulation() { return tr_; } - /// Returns a const reference to the triangulation - const Triangulation& triangulation() const { return tr_; } - /** Adds cell \c cell to the 3D complex, with subdomain index \c index */ @@ -416,16 +422,46 @@ public: v->set_dimension(-1); } - /** Returns the index of vertex \c v - */ - Index index(const Vertex_handle& v) const { return v->index(); } - /** Sets index of vertex \c vertex to \c index */ void set_index(const Vertex_handle& vertex, const Index& index) const { vertex->set_index(index); } + /** Sets surface index of facet \c facet to \c index + */ + void set_surface_patch_index(const Facet& f, const Surface_patch_index& index) + { + set_surface_patch_index(f.first, f.second, index); + } + /** Sets surface index of facet(\c cell, \c i) to \c index + */ + void set_surface_patch_index(const Cell_handle& cell, + const int i, + const Surface_patch_index& index) const + { + cell->set_surface_patch_index(i, index); + } + /** Sets subdomain index of cell \c cell to \c index + */ + void set_subdomain_index(const Cell_handle& cell, + const Subdomain_index& index) const + { + cell->set_subdomain_index(index); + } + /** Sets dimension of vertex \c vertex to \c dimension + */ + void set_dimension(const Vertex_handle& vertex, int dimension) const + { + vertex->set_dimension(dimension); + } +/// @} + +/// \name Queries on the identifier of the face complex including triangulation cells, facets and vertices. +/// @{ + /** Returns the index of vertex \c v + */ + Index index(const Vertex_handle& v) const { return v->index(); } /** Returns the subdomain index of cell \c cell */ @@ -447,41 +483,55 @@ public: { return cell->surface_patch_index(i); } - /** Sets surface index of facet \c facet to \c index - */ - void set_surface_patch_index(const Facet& f, const Surface_patch_index& index) - { - set_surface_patch_index(f.first, f.second, index); - } - /** Sets surface index of facet(\c cell, \c i) to \c index - */ - void set_surface_patch_index(const Cell_handle& cell, - const int i, - const Surface_patch_index& index) const - { - cell->set_surface_patch_index(i, index); - } - - /** Sets subdomain index of cell \c cell to \c index - */ - void set_subdomain_index(const Cell_handle& cell, - const Subdomain_index& index) const - { - cell->set_subdomain_index(index); - } - - /** Sets dimension of vertex \c vertex to \c dimension - */ - void set_dimension(const Vertex_handle& vertex, int dimension) const - { - vertex->set_dimension(dimension); - } - /** Returns the dimension of the lowest dimensional face of the input 3D * complex that contains the vertex */ int in_dimension(const Vertex_handle& v) const { return v->in_dimension(); } + /** + * Returns Curve_index of edge \c e + */ + Curve_index curve_index(const Edge& e) const + { + return curve_index(e.first->vertex(e.second), + e.first->vertex(e.third)); + } + + /** + * Returns Curve_index of the edge formed by \c v1 and \c v2 + */ + Curve_index curve_index(const Vertex_handle& v1, + const Vertex_handle& v2) const + { + return curve_index(make_internal_edge(v1, v2)); + } + + /** + * Returns Corner_index of vertex \c v + */ + Corner_index corner_index(const Vertex_handle& v) const + { + typename Corner_map::const_iterator it = corners_.find(v); + if (corners_.end() != it) { return it->second; } + return Corner_index(); + } +/// @} + +#ifndef CGAL_NO_DEPRECATED_CODE + CGAL_DEPRECATED + Curve_index curve_segment_index(const Edge& e) const + { + return curve_index(e); + } + + CGAL_DEPRECATED + Curve_index curve_segment_index(const Vertex_handle& v1, + const Vertex_handle& v2) const + { + return curve_index(v1, v2); + } +#endif // CGAL_NO_DEPRECATED_CODE + std::size_t number_of_far_points() const { return far_vertices_.size(); @@ -540,6 +590,10 @@ public: far_vertices_.clear(); } + void rescan_after_load_of_triangulation(); + +/// \name Queries on the faces of the embedded complex +/// @{ /** * Returns the number of cells which belongs to the 3D complex */ @@ -576,7 +630,6 @@ public: { return edges_.size(); } - /** * Returns the number of corners of c3t3 */ @@ -591,10 +644,8 @@ public: { return corners_.size(); } - - void rescan_after_load_of_triangulation(); - - /** Returns \c true if cell \c cell belongs to the 3D complex + /** + * Returns \c true if cell \c cell belongs to the 3D complex */ bool is_in_complex(const Cell_handle& cell) const { @@ -636,48 +687,10 @@ public: { return (corners_.find(v) != corners_.end()); } +/// @} - /** - * Returns Curve_index of edge \c e - */ - Curve_index curve_index(const Edge& e) const - { - return curve_index(e.first->vertex(e.second), - e.first->vertex(e.third)); - } - Curve_index curve_index(const Vertex_handle& v1, - const Vertex_handle& v2) const - { - return curve_index(make_internal_edge(v1,v2)); - } - -#ifndef CGAL_NO_DEPRECATED_CODE - CGAL_DEPRECATED - Curve_index curve_segment_index(const Edge& e) const - { - return curve_index(e); - } - - CGAL_DEPRECATED - Curve_index curve_segment_index(const Vertex_handle& v1, - const Vertex_handle& v2) const - { - return curve_index(v1, v2); - } -#endif // CGAL_NO_DEPRECATED_CODE - - /** - * Returns Corner_index of vertex \c v - */ - Corner_index corner_index(const Vertex_handle& v) const - { - typename Corner_map::const_iterator it = corners_.find(v); - if ( corners_.end() != it ) { return it->second; } - return Corner_index(); - } - - /// \name Operations + /// \name I/O Functions /// @{ /** * Outputs the outer boundary of the entire domain with facets oriented outward. @@ -875,6 +888,8 @@ private: }; public: +/// \name Traversal of the complex +/// @{ #ifdef DOXYGEN_RUNNING /// Iterator type to visit the cells of the 3D complex typedef unspecified_type Cells_in_complex_iterator; @@ -1040,7 +1055,7 @@ public: /** * @cond SKIP_IN_MANUAL * Creates an Internal_edge object (i.e a pair of ordered Vertex_handle) - * @endcond SKIP_IN_MANUAL + * @endcond */ Internal_edge make_internal_edge(const Vertex_handle& v1, const Vertex_handle& v2) const @@ -1052,7 +1067,7 @@ public: /** * @cond SKIP_IN_MANUAL * Returns true if \c edge is in C3T3 - * @endcond SKIP_IN_MANUAL + * @endcond */ bool is_in_complex(const Internal_edge& edge) const { @@ -1062,7 +1077,7 @@ public: /** * @cond SKIP_IN_MANUAL * Add edge \c edge to complex, with `Curve_index` `index` - * @endcond SKIP_IN_MANUAL + * @endcond */ void add_to_complex(const Internal_edge& edge, const Curve_index& index) { @@ -1079,7 +1094,7 @@ public: /** * @cond SKIP_IN_MANUAL * Remove edge \c edge from complex - * @endcond SKIP_IN_MANUAL + * @endcond */ void remove_from_complex(const Internal_edge& edge) { @@ -1089,7 +1104,7 @@ public: /** * @cond SKIP_IN_MANUAL * Returns Curve_index of edge \c edge - * @endcond SKIP_IN_MANUAL + * @endcond */ Curve_index curve_index(const Internal_edge& edge) const { @@ -1102,7 +1117,7 @@ public: /// Returns `NOT_IN_COMPLEX`, `BOUNDARY`, `REGULAR`, or `SINGULAR`, /// depending on the number of incident facets in the complex, and the /// number of connected components of its link - /// @endcond SKIP_IN_MANUAL + /// @endcond Face_status face_status(const Vertex_handle v) const { if (!manifold_info_initialized_) init_manifold_info(); @@ -1160,7 +1175,7 @@ public: /// @cond SKIP_IN_MANUAL /// This function should be called only when incident edges /// are known to be REGULAR OR BOUNDARY - /// @endcond SKIP_IN_MANUAL + /// @endcond bool is_regular_or_boundary_for_vertices(Vertex_handle v) const { return union_find_of_incident_facets(v) == 1; } @@ -1168,7 +1183,7 @@ public: /// @cond SKIP_IN_MANUAL /// Returns `NOT_IN_COMPLEX`, `BOUNDARY`, `REGULAR`, or `SINGULAR`, /// depending on the number of incident facets in the complex - /// @endcond SKIP_IN_MANUAL + /// @endcond Face_status face_status(const Edge& edge) const { if (!manifold_info_initialized_) init_manifold_info(); @@ -1205,7 +1220,7 @@ public: * @param last the iterator past the last point to insert * * InputIterator value type must be \c std::pair - * @endcond SKIP_IN_MANUAL + * @endcond */ template void insert_surface_points(InputIterator first, InputIterator last) @@ -1231,7 +1246,7 @@ public: * @param default_index the index to be used to insert points * * InputIterator value type must be \c Tr::Point - * @endcond SKIP_IN_MANUAL + * @endcond */ template void insert_surface_points(InputIterator first, @@ -1282,7 +1297,7 @@ public: /** @cond SKIP_IN_MANUAL * Returns bbox - * @endcond SKIP_IN_MANUAL + * @endcond */ Bbox_3 bbox() const; From 5a36e53a4a23f2dbf43abd3dc1f4f24356525395 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 29 Apr 2021 17:58:03 +0200 Subject: [PATCH 16/79] move build_triangulation_from_file to MDS_3 namespace and simplify template parameters --- .../Mesh_complex_3_in_triangulation_3_fwd.h | 18 ++-- MDS_3/doc/MDS_3/PackageDescription.txt | 1 + MDS_3/examples/MDS_3/CMakeLists.txt | 1 + .../tetrahedron_soup_to_c3t3_example.cpp | 42 +++++++++ MDS_3/include/CGAL/IO/File_medit.h | 2 +- MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h | 25 +++-- .../tetrahedron_soup_to_triangulation_3.h | 94 +++++++++++++++++++ .../Polyhedron/Plugins/IO/VTK_io_plugin.cpp | 2 +- .../Plugins/Mesh_3/C3t3_io_plugin.cpp | 2 +- 9 files changed, 164 insertions(+), 23 deletions(-) create mode 100644 MDS_3/examples/MDS_3/tetrahedron_soup_to_c3t3_example.cpp create mode 100644 MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h diff --git a/Installation/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h b/Installation/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h index 9dc5d8a794f..f541bf5bc73 100644 --- a/Installation/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h +++ b/Installation/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h @@ -22,14 +22,18 @@ template class Mesh_complex_3_in_triangulation_3; -template -bool build_triangulation_from_file(std::istream& is, - Tr& tr, - bool replace_domain_0); +namespace MDS_3 { -template -bool build_triangulation_from_file(std::istream& is, - Tr& tr); + template + bool build_triangulation_from_file(std::istream& is, + Tr& tr, + bool replace_domain_0); + + template + bool build_triangulation_from_file(std::istream& is, + Tr& tr); + +} // MDS_3 } // CGAL #endif diff --git a/MDS_3/doc/MDS_3/PackageDescription.txt b/MDS_3/doc/MDS_3/PackageDescription.txt index 087ce57e1d0..a057d712020 100644 --- a/MDS_3/doc/MDS_3/PackageDescription.txt +++ b/MDS_3/doc/MDS_3/PackageDescription.txt @@ -51,6 +51,7 @@ Here are the main concepts of this package: \cgalCRPSection{Function Templates} - `CGAL::facets_in_complex_3_to_triangle_mesh()` +- `CGAL::tetrahedron_soup_to_triangulation_3()` \cgalCRPSection{Input/Output Functions} - `CGAL::output_to_medit()` diff --git a/MDS_3/examples/MDS_3/CMakeLists.txt b/MDS_3/examples/MDS_3/CMakeLists.txt index 4b911246120..f7f51e3372b 100644 --- a/MDS_3/examples/MDS_3/CMakeLists.txt +++ b/MDS_3/examples/MDS_3/CMakeLists.txt @@ -19,3 +19,4 @@ endif() # Creating entries for all C++ files with "main" routine # ########################################################## create_single_source_cgal_program( "c3t3_example.cpp" ) +create_single_source_cgal_program( "tetrahedron_soup_to_c3t3_example.cpp" ) diff --git a/MDS_3/examples/MDS_3/tetrahedron_soup_to_c3t3_example.cpp b/MDS_3/examples/MDS_3/tetrahedron_soup_to_c3t3_example.cpp new file mode 100644 index 00000000000..2e4658754cc --- /dev/null +++ b/MDS_3/examples/MDS_3/tetrahedron_soup_to_c3t3_example.cpp @@ -0,0 +1,42 @@ +#include + +#include +#include +#include +#include + +#include + +#include + +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; + +typedef CGAL::Delaunay_triangulation_3 DT3; +typedef CGAL::Tetrahedral_remeshing::Remeshing_triangulation_3 Remeshing_triangulation; + +typedef K::Point_3 Point_3; +typedef K::Tetrahedron_3 Tetrahedron_3; + + +int main(int argc, char* argv[]) +{ + //build a triangulation + DT3 delaunay; + CGAL::Random_points_in_cube_3 randp(2.); + while (delaunay.number_of_vertices() < 100) + delaunay.insert(*randp++); + + //collect tetrahedra + std::vector tetrahedra(delaunay.number_of_finite_cells()); + for (DT3::Cell_handle c : delaunay.finite_cell_handles()) + tetrahedra.push_back(delaunay.tetrahedron(c)); + + //build triangulation + Remeshing_triangulation tr; + CGAL::tetrahedron_soup_to_triangulation_3(tetrahedra, tr); + + std::ofstream os("dt_rebuilt.mesh"); + CGAL::write_MEDIT(os, tr); + + return EXIT_SUCCESS; +} diff --git a/MDS_3/include/CGAL/IO/File_medit.h b/MDS_3/include/CGAL/IO/File_medit.h index 1041c4ba2a3..35979a1838a 100644 --- a/MDS_3/include/CGAL/IO/File_medit.h +++ b/MDS_3/include/CGAL/IO/File_medit.h @@ -910,7 +910,7 @@ template bool read_MEDIT(std::istream& in, T3& t3) { CGAL_assertion(!(!in)); - return CGAL::build_triangulation_from_file(in, t3); + return CGAL::MDS_3::build_triangulation_from_file(in, t3); } } // end namespace CGAL diff --git a/MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h b/MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h index 5c2f6d69a08..c06fa872790 100644 --- a/MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h +++ b/MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h @@ -14,8 +14,8 @@ // //****************************************************************************** -#ifndef CGAL_MESH_3_TET_SOUP_TO_C3T3_H -#define CGAL_MESH_3_TET_SOUP_TO_C3T3_H +#ifndef CGAL_MDS_3_TET_SOUP_TO_C3T3_H +#define CGAL_MDS_3_TET_SOUP_TO_C3T3_H #include @@ -32,7 +32,8 @@ namespace CGAL { - +namespace MDS_3 +{ template std::array make_ordered_vertex_array(const Vh vh0, const Vh vh1, const Vh vh2) { @@ -335,7 +336,7 @@ bool assign_neighbors(Tr& tr, return true; } -template +template bool build_triangulation(Tr& tr, const std::vector& points, const std::vector >& finite_cells, @@ -390,13 +391,10 @@ bool build_triangulation(Tr& tr, if(verbose) std::cout << tr.number_of_vertices() << " vertices" << std::endl; - if(c3t3_loader_failed) - return true; - else - return tr.tds().is_valid(); + return tr.tds().is_valid(); } -template +template bool build_triangulation_from_file(std::istream& is, Tr& tr, bool replace_domain_0) @@ -487,19 +485,20 @@ bool build_triangulation_from_file(std::istream& is, return false; std::vector vertices(points.size() + 1); - bool is_well_built = build_triangulation(tr, + bool is_well_built = build_triangulation(tr, points, finite_cells, border_facets, vertices, false, replace_domain_0); return is_well_built; } -template +template bool build_triangulation_from_file(std::istream& is, Tr& tr) { - return build_triangulation_from_file(is, tr, false); + return build_triangulation_from_file(is, tr, false); } +} // namespace MDS_3 } // namespace CGAL #include -#endif // CGAL_MESH_3_TET_SOUP_TO_C3T3_H +#endif // CGAL_MDS_3_TET_SOUP_TO_C3T3_H diff --git a/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h b/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h new file mode 100644 index 00000000000..bcc04556811 --- /dev/null +++ b/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h @@ -0,0 +1,94 @@ +// Copyright (c) 2009-2014 INRIA Sophia-Antipolis (France). +// Copyright (c) 2010-2013 GeometryFactory Sarl (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) : Mael Rouxel-Labbé, Maxime Gimeno, Jane Tournois +// +//****************************************************************************** +// File Description : +//****************************************************************************** + +#ifndef CGAL_MDS_3_TETRAHEDRON_SOUP_TO_C3T3_H +#define CGAL_MDS_3_TETRAHEDRON_SOUP_TO_C3T3_H + +#include + +#include + +#include +#include +#include + +namespace CGAL { + + /*! + \ingroup PkgMDS3Functions + + * @brief + * + * @tparam TetrahedronRange + * @tparam Triangulation model of + * @param tets + * @param tr + * + * @pre convex volume + */ + template + void tetrahedron_soup_to_triangulation_3(const TetrahedronRange& tets, + Triangulation& tr) + { + typedef Triangulation Tr; + typedef typename Tr::Cell_handle Cell_handle; + typedef typename Tr::Vertex_handle Vertex_handle; + typedef typename Tr::Point Point; + + std::vector points; + std::vector > finite_cells; + std::map, typename Tr::Cell::Surface_patch_index> border_facets; + std::vector vertex_handle_vector; + std::map v2i; + + for (typename TetrahedronRange::value_type tet : tets) + { + CGAL_assertion(tet.orientation() != CGAL::NEGATIVE); + std::array cell; + + Cell_handle hint = Cell_handle(); + for (int i = 0; i < 4; ++i) + { + const Point& pi = tet[i]; + typename Tr::Locate_type lt; + int li, lj; + hint = tr.locate(pi, lt, li, lj, hint); + if (lt != Tr::Locate_type::VERTEX) + { + points.push_back(pi); + Vertex_handle newv = tr.insert(pi, lt, hint, li, lj); + vertex_handle_vector.push_back(newv); + + CGAL_assertion(points.size() == vertex_handle_vector.size()); + v2i.insert(std::make_pair(newv, points.size() - 1)); + cell[i] = static_cast(points.size() - 1); + } + else + cell[i] = v2i.at(hint->vertex(li)); + } + cell[4] = 1; + finite_cells.push_back(cell); + } + + CGAL::MDS_3::build_triangulation(tr, points, finite_cells, + border_facets, vertex_handle_vector); + } + +} //namespace CGAL + + +#endif // CGAL_MDS_3_TETRAHEDRON_SOUP_TO_C3T3_H diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp index 1e90b794e17..3441316accd 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp @@ -421,7 +421,7 @@ public: } } std::vector new_vertices; - CGAL::build_triangulation(c3t3_item->c3t3().triangulation(), + CGAL::MDS_3::build_triangulation(c3t3_item->c3t3().triangulation(), points, finite_cells, border_facets, new_vertices); for( C3t3::Triangulation::Finite_cells_iterator diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp index 41aee815337..a0853f5607f 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp @@ -127,7 +127,7 @@ Polyhedron_demo_c3t3_binary_io_plugin::load( item->setName(fileinfo.baseName()); item->set_valid(false); - if(CGAL::build_triangulation_from_file(in, item->c3t3().triangulation(), true)) + if(CGAL::MDS_3::build_triangulation_from_file(in, item->c3t3().triangulation(), true)) { item->c3t3().rescan_after_load_of_triangulation(); for( C3t3::Triangulation::Finite_cells_iterator From f595733bf2b2559493cda231300b5452af958fbe Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 29 Apr 2021 17:58:29 +0200 Subject: [PATCH 17/79] update license headers includes --- MDS_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h | 2 +- ...undary_of_subdomain_of_complex_3_in_triangulation_3_to_off.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MDS_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h b/MDS_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h index 74fc03c0e5c..be86d8c609e 100644 --- a/MDS_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h +++ b/MDS_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h @@ -14,7 +14,7 @@ #ifndef CGAL_FACETS_IN_COMPLEX_3_TO_TRIANGLE_MESH_H #define CGAL_FACETS_IN_COMPLEX_3_TO_TRIANGLE_MESH_H -#include +#include #include #include diff --git a/MDS_3/include/CGAL/internal/MDS_3/Boundary_of_subdomain_of_complex_3_in_triangulation_3_to_off.h b/MDS_3/include/CGAL/internal/MDS_3/Boundary_of_subdomain_of_complex_3_in_triangulation_3_to_off.h index 3c930811023..9423aa11ba9 100644 --- a/MDS_3/include/CGAL/internal/MDS_3/Boundary_of_subdomain_of_complex_3_in_triangulation_3_to_off.h +++ b/MDS_3/include/CGAL/internal/MDS_3/Boundary_of_subdomain_of_complex_3_in_triangulation_3_to_off.h @@ -12,7 +12,7 @@ #ifndef CGAL_INTERNAL_MESH_3_BOUNDARY_OF_SUDDOMAIN_OF_COMPLEX_3_IN_TRIANGULATION_3_TO_OFF_H #define CGAL_INTERNAL_MESH_3_BOUNDARY_OF_SUDDOMAIN_OF_COMPLEX_3_IN_TRIANGULATION_3_TO_OFF_H -#include +#include #include From 2bbdca32fb0cdb82afcec6ad8d9f2d634d672174 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 30 Apr 2021 17:02:56 +0200 Subject: [PATCH 18/79] fix nb of facets and cells in output_to_medit number_of_facets_in_complex() and number_of_cells_in_complex() are valid only after rescan_after_load_triangulation'), which is not const so let's count facets and cells using std::distance() --- MDS_3/include/CGAL/IO/File_medit.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/MDS_3/include/CGAL/IO/File_medit.h b/MDS_3/include/CGAL/IO/File_medit.h index 35979a1838a..7754ad86a04 100644 --- a/MDS_3/include/CGAL/IO/File_medit.h +++ b/MDS_3/include/CGAL/IO/File_medit.h @@ -794,7 +794,9 @@ output_to_medit(std::ostream& os, //------------------------------------------------------- // Facets //------------------------------------------------------- - typename C3T3::size_type number_of_triangles = c3t3.number_of_facets_in_complex(); + typename C3T3::size_type number_of_triangles + = std::distance(c3t3.facets_in_complex_begin(), + c3t3.facets_in_complex_end()); if ( print_each_facet_twice ) number_of_triangles += number_of_triangles; @@ -839,8 +841,11 @@ output_to_medit(std::ostream& os, //------------------------------------------------------- // Tetrahedra //------------------------------------------------------- + typename C3T3::size_type number_of_cells + = std::distance(c3t3.cells_in_complex_begin(), + c3t3.cells_in_complex_end()); os << "Tetrahedra\n" - << c3t3.number_of_cells_in_complex() << '\n'; + << number_of_cells << '\n'; for( Cell_iterator cit = c3t3.cells_in_complex_begin() ; cit != c3t3.cells_in_complex_end() ; From 595c969757ec1e109733c66dbe396380d22db68e Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 30 Apr 2021 17:05:43 +0200 Subject: [PATCH 19/79] add another version of tetrahedron_soup_to_triangulation_3 based on indices, similarly to polygon_soup_to_polygon_mesh and using named parameters for optional parameters use it in an example --- .../CGAL/boost/graph/parameters_interface.h | 3 + .../tetrahedron_soup_to_c3t3_example.cpp | 60 +++++++++--- MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h | 5 +- .../tetrahedron_soup_to_triangulation_3.h | 97 ++++++++++++++----- 4 files changed, 126 insertions(+), 39 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/parameters_interface.h b/BGL/include/CGAL/boost/graph/parameters_interface.h index a1fe60c5f75..abda58221b5 100644 --- a/BGL/include/CGAL/boost/graph/parameters_interface.h +++ b/BGL/include/CGAL/boost/graph/parameters_interface.h @@ -198,6 +198,9 @@ CGAL_add_named_parameter(cell_selector_t, cell_selector, cell_selector) CGAL_add_named_parameter(facet_is_constrained_t, facet_is_constrained, facet_is_constrained_map) CGAL_add_named_parameter(smooth_constrained_edges_t, smooth_constrained_edges, smooth_constrained_edges) +// MDS_3 parameters +CGAL_add_named_parameter(surface_facets_t, surface_facets, surface_facets) + // output parameters CGAL_add_named_parameter(face_proxy_map_t, face_proxy_map, face_proxy_map) CGAL_add_named_parameter(proxies_t, proxies, proxies) diff --git a/MDS_3/examples/MDS_3/tetrahedron_soup_to_c3t3_example.cpp b/MDS_3/examples/MDS_3/tetrahedron_soup_to_c3t3_example.cpp index 2e4658754cc..5cf18c3310c 100644 --- a/MDS_3/examples/MDS_3/tetrahedron_soup_to_c3t3_example.cpp +++ b/MDS_3/examples/MDS_3/tetrahedron_soup_to_c3t3_example.cpp @@ -8,35 +8,69 @@ #include #include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Delaunay_triangulation_3 DT3; typedef CGAL::Tetrahedral_remeshing::Remeshing_triangulation_3 Remeshing_triangulation; +typedef CGAL::Mesh_complex_3_in_triangulation_3 C3T3; -typedef K::Point_3 Point_3; -typedef K::Tetrahedron_3 Tetrahedron_3; - +typedef K::Point_3 Point_3; +typedef K::Tetrahedron_3 Tetrahedron_3; +typedef DT3::Vertex_handle Vertex_handle; int main(int argc, char* argv[]) { - //build a triangulation - DT3 delaunay; - CGAL::Random_points_in_cube_3 randp(2.); - while (delaunay.number_of_vertices() < 100) - delaunay.insert(*randp++); + const int nbv = 100; - //collect tetrahedra - std::vector tetrahedra(delaunay.number_of_finite_cells()); + //a triangulation + DT3 delaunay; + std::map v2i; + std::vector points(nbv); + std::vector tetrahedra; + std::vector > tets_by_indices; + + //insert random points + CGAL::Random_points_in_cube_3 randp(2.); + int i = 0; + while (i < nbv) + { + points[i] = *randp++; + Vertex_handle v = delaunay.insert(points[i]); + v2i[v] = i++; + } + + tetrahedra.reserve(delaunay.number_of_finite_cells()); + tets_by_indices.reserve(delaunay.number_of_finite_cells()); for (DT3::Cell_handle c : delaunay.finite_cell_handles()) + { tetrahedra.push_back(delaunay.tetrahedron(c)); - //build triangulation + std::array tet; + tet[0] = v2i.at(c->vertex(0)); + tet[1] = v2i.at(c->vertex(1)); + tet[2] = v2i.at(c->vertex(2)); + tet[3] = v2i.at(c->vertex(3)); + tet[4] = Remeshing_triangulation::Cell::Subdomain_index(1); + + tets_by_indices.push_back(tet); + } + + //build triangulation from tetrahedra Remeshing_triangulation tr; CGAL::tetrahedron_soup_to_triangulation_3(tetrahedra, tr); - std::ofstream os("dt_rebuilt.mesh"); - CGAL::write_MEDIT(os, tr); + //buid triangulation from indices + Remeshing_triangulation tr2; + CGAL::tetrahedron_soup_to_triangulation_3(points, tets_by_indices, tr2); + + //build a C3T3 + C3T3 c3t3; + c3t3.triangulation() = tr; + + std::ofstream ofs("c3t3_output.mesh"); + c3t3.output_to_medit(ofs); return EXIT_SUCCESS; } diff --git a/MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h b/MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h index c06fa872790..05d2c0cf1bc 100644 --- a/MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h +++ b/MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h @@ -341,7 +341,6 @@ bool build_triangulation(Tr& tr, const std::vector& points, const std::vector >& finite_cells, const std::map, typename Tr::Cell::Surface_patch_index>& border_facets, - std::vector& vertex_handle_vector, const bool verbose = false, bool replace_domain_0 = false) { @@ -354,6 +353,7 @@ bool build_triangulation(Tr& tr, typedef boost::unordered_map > Incident_cells_map; Incident_cells_map incident_cells_map; + std::vector vertex_handle_vector; vertex_handle_vector.resize(points.size() + 1); // id to vertex_handle //index 0 is for infinite vertex // 1 to n for points in `points` @@ -484,9 +484,8 @@ bool build_triangulation_from_file(std::istream& is, if(finite_cells.empty()) return false; - std::vector vertices(points.size() + 1); bool is_well_built = build_triangulation(tr, - points, finite_cells, border_facets, vertices, false, replace_domain_0); + points, finite_cells, border_facets, false, replace_domain_0); return is_well_built; } diff --git a/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h b/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h index bcc04556811..d0e08607224 100644 --- a/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h +++ b/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -28,11 +29,9 @@ namespace CGAL { - /*! - \ingroup PkgMDS3Functions - - * @brief - * + /** \ingroup PkgMDS3Functions + * builds a 3D triangulation from a soup of tetrahedra. + * * @tparam TetrahedronRange * @tparam Triangulation model of * @param tets @@ -45,47 +44,99 @@ namespace CGAL { Triangulation& tr) { typedef Triangulation Tr; - typedef typename Tr::Cell_handle Cell_handle; - typedef typename Tr::Vertex_handle Vertex_handle; typedef typename Tr::Point Point; std::vector points; std::vector > finite_cells; std::map, typename Tr::Cell::Surface_patch_index> border_facets; - std::vector vertex_handle_vector; - std::map v2i; + std::map p2i; for (typename TetrahedronRange::value_type tet : tets) { - CGAL_assertion(tet.orientation() != CGAL::NEGATIVE); + CGAL_assertion(tet.orientation() == CGAL::POSITIVE); std::array cell; - Cell_handle hint = Cell_handle(); for (int i = 0; i < 4; ++i) { const Point& pi = tet[i]; - typename Tr::Locate_type lt; - int li, lj; - hint = tr.locate(pi, lt, li, lj, hint); - if (lt != Tr::Locate_type::VERTEX) + if (p2i.find(pi) == p2i.end()) { points.push_back(pi); - Vertex_handle newv = tr.insert(pi, lt, hint, li, lj); - vertex_handle_vector.push_back(newv); - - CGAL_assertion(points.size() == vertex_handle_vector.size()); - v2i.insert(std::make_pair(newv, points.size() - 1)); + p2i.insert(std::make_pair(pi, points.size() - 1)); cell[i] = static_cast(points.size() - 1); } else - cell[i] = v2i.at(hint->vertex(li)); + cell[i] = p2i.at(pi); } cell[4] = 1; + + CGAL_assertion(CGAL::orientation(points[cell[0]], + points[cell[1]], points[cell[2]], points[cell[3]]) == CGAL::POSITIVE); + finite_cells.push_back(cell); } - CGAL::MDS_3::build_triangulation(tr, points, finite_cells, - border_facets, vertex_handle_vector); + CGAL::MDS_3::build_triangulation(tr, points, finite_cells, border_facets); + } + + /** \ingroup PkgMDS3Functions + * builds a 3D triangulation from a soup of tetrahedra. + * + * @tparam PointRange a model of the concept `RandomAccessContainer` + * whose value type is the point type + * @tparam TetrahedronRange a model of the concept `RandomAccessContainer` whose + * value type is a model of the concept `RandomAccessContainer` whose value type is `std::size_t` + * + * @param points points of the soup of tetrahedra + * @param tets each element in the range describes a tetrahedron using the indices of the points + * in `points` (indices 0 to 3), and the associated `Subdomain_index` (index 4) + * @param tr the 3D triangulation to be built + * @param np an optional sequence of \ref mds3_namedparameters "Named Parameters" among the ones listed below + * + * \cgalNamedParamsBegin + * \cgalParamNBegin{surface_facets} + * \cgalParamDescription{each element in the range describes a surface facet using the indices of points + * in `points` (indices 0 to 2), and the associated `Surface_patch_index` (index 3)} + * \cgalParamType{a class model of `AssociativeContainer` + * whose key type is model of `RandomAccessContainer` + * and mapped type is `Tr::Cell::Surface_patch_index`} + * \cgalParamDefault{An empty `std::map, typename Tr::Cell::Surface_patch_index>`} + * \cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t` + * must be available in `PolygonMesh`.} + * \cgalParamNEnd + * \cgalNamedParamsEnd + * + * @pre `points` contains each point only once + * + * @sa `CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh()` + */ + template + void tetrahedron_soup_to_triangulation_3(const PointRange& points, + const TetrahedronRange& tets, + Triangulation& tr, + const NamedParameters& np) + { + using parameters::choose_parameter; + using parameters::get_parameter; + + std::map, + typename Triangulation::Cell::Surface_patch_index> empty_map; + auto facets = choose_parameter(get_parameter(np, internal_np::surface_facets), empty_map); + + CGAL::MDS_3::build_triangulation(tr, points, tets, facets); + } + + template + void tetrahedron_soup_to_triangulation_3(const PointRange& points, + const TetrahedronRange& tets, + Triangulation& tr) + { + tetrahedron_soup_to_triangulation_3(points, tets, tr, parameters::all_default()); } } //namespace CGAL From 8bce167079db6e9bed6722e7e10d854f484ab820 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 3 May 2021 11:53:32 +0200 Subject: [PATCH 20/79] remove trailing whitespaces --- .../include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h | 2 +- MDS_3/examples/MDS_3/tetrahedron_soup_to_c3t3_example.cpp | 2 +- MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Installation/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h b/Installation/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h index f541bf5bc73..4d54cfdd8ae 100644 --- a/Installation/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h +++ b/Installation/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h @@ -28,7 +28,7 @@ namespace MDS_3 { bool build_triangulation_from_file(std::istream& is, Tr& tr, bool replace_domain_0); - + template bool build_triangulation_from_file(std::istream& is, Tr& tr); diff --git a/MDS_3/examples/MDS_3/tetrahedron_soup_to_c3t3_example.cpp b/MDS_3/examples/MDS_3/tetrahedron_soup_to_c3t3_example.cpp index 5cf18c3310c..58d4f2cff3e 100644 --- a/MDS_3/examples/MDS_3/tetrahedron_soup_to_c3t3_example.cpp +++ b/MDS_3/examples/MDS_3/tetrahedron_soup_to_c3t3_example.cpp @@ -30,7 +30,7 @@ int main(int argc, char* argv[]) std::vector points(nbv); std::vector tetrahedra; std::vector > tets_by_indices; - + //insert random points CGAL::Random_points_in_cube_3 randp(2.); int i = 0; diff --git a/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h b/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h index d0e08607224..cdda1c969ec 100644 --- a/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h +++ b/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h @@ -36,7 +36,7 @@ namespace CGAL { * @tparam Triangulation model of * @param tets * @param tr - * + * * @pre convex volume */ template From df13814d902e7a75316fb53d5ff1784eaba14f01 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 3 May 2021 16:42:51 +0200 Subject: [PATCH 21/79] fix license --- MDS_3/include/CGAL/internal/MDS_3/Handle_IO_for_pair_of_int.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MDS_3/include/CGAL/internal/MDS_3/Handle_IO_for_pair_of_int.h b/MDS_3/include/CGAL/internal/MDS_3/Handle_IO_for_pair_of_int.h index 0520ca92ea1..de344bdc7aa 100644 --- a/MDS_3/include/CGAL/internal/MDS_3/Handle_IO_for_pair_of_int.h +++ b/MDS_3/include/CGAL/internal/MDS_3/Handle_IO_for_pair_of_int.h @@ -13,7 +13,7 @@ #ifndef CGAL_INTERNAL_MESH_3_INTERNAL_HANDLE_IO_FOR_PAIR_OF_INT_H #define CGAL_INTERNAL_MESH_3_INTERNAL_HANDLE_IO_FOR_PAIR_OF_INT_H -#include +#include #include From 1cf19f469b9542f35fc59ba6ed11ee957e50d623 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 3 May 2021 16:43:10 +0200 Subject: [PATCH 22/79] add is_convex postcondition and more doc --- .../CGAL/internal/MDS_3/MDS_3_helper.h | 67 +++++++++++++++++++ .../tetrahedron_soup_to_triangulation_3.h | 31 ++++++--- 2 files changed, 90 insertions(+), 8 deletions(-) create mode 100644 MDS_3/include/CGAL/internal/MDS_3/MDS_3_helper.h diff --git a/MDS_3/include/CGAL/internal/MDS_3/MDS_3_helper.h b/MDS_3/include/CGAL/internal/MDS_3/MDS_3_helper.h new file mode 100644 index 00000000000..0605e766fdb --- /dev/null +++ b/MDS_3/include/CGAL/internal/MDS_3/MDS_3_helper.h @@ -0,0 +1,67 @@ +// Copyright (c) 2021 GeometryFactory +// 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_INTERNAL_MDS_3_HELPERS_H +#define CGAL_INTERNAL_MDS_3_HELPERS_H + +#include + +#include + +#include +#include + +namespace CGAL { +namespace MDS_3 { +namespace internal { + + template + bool is_convex(const Triangulation& tr) + { + typedef typename Triangulation::Facet Facet; + typedef typename Triangulation::Vertex_handle Vertex_handle; + typedef typename Triangulation::Cell_handle Cell_handle; + typedef typename Triangulation::Geom_traits::Point_3 Point_3; + typename Triangulation::Geom_traits::Construct_point_3 cp + = tr.geom_traits().construct_point_3_object(); + + std::vector infcells; + tr.incident_cells(tr.infinite_vertex(), std::back_inserter(infcells)); + for (Cell_handle c : infcells) + { + const Cell_handle neigh = c->neighbor(c->index(tr.infinite_vertex())); + const int i = neigh->index(c); + + const std::array pfacet = { cp(neigh->vertex((i + 1) % 4)->point()), + cp(neigh->vertex((i + 2) % 4)->point()), + cp(neigh->vertex((i + 3) % 4)->point())}; + const CGAL::Orientation o = CGAL::orientation( + pfacet[0], pfacet[1], pfacet[2], cp(neigh->vertex(i)->point())); + + for (Vertex_handle v : tr.finite_vertex_handles()) + { + if (c->has_vertex(v)) + continue; + if (o != CGAL::orientation(pfacet[0], pfacet[1], pfacet[2], + cp(neigh->vertex(i)->point()))) + return false; + } + } + + return true; + } + +} // end namespace internal +} // end namespace MDS_3 +} // end namespace CGAL + +#endif // CGAL_INTERNAL_MDS_3_HELPERS_H diff --git a/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h b/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h index cdda1c969ec..fce8e1debd6 100644 --- a/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h +++ b/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -30,14 +31,19 @@ namespace CGAL { /** \ingroup PkgMDS3Functions - * builds a 3D triangulation from a soup of tetrahedra. - * - * @tparam TetrahedronRange - * @tparam Triangulation model of - * @param tets - * @param tr - * - * @pre convex volume + * builds a 3D triangulation from a soup of tetrahedra. + * + * @tparam TetrahedronRange a model of `Range` whose value type is + * a `Tetrahedron_3` + * @tparam Triangulation a valid triangulation class that has + * a vertex base model of `MeshVertexBase_3` + * and a cell base model of `MeshCellBase_3` + * + * @param tets each element in the range is the geometric description of the + * corresponding cell in `tr` + * @param tr the 3D triangulation to be built + * + * @post the output triangulation should be a triangulation of the convex hull of `tets` */ template void tetrahedron_soup_to_triangulation_3(const TetrahedronRange& tets, @@ -77,6 +83,8 @@ namespace CGAL { } CGAL::MDS_3::build_triangulation(tr, points, finite_cells, border_facets); + + CGAL_assertion(CGAL::MDS_3::internal::is_convex(tr)); } /** \ingroup PkgMDS3Functions @@ -86,6 +94,10 @@ namespace CGAL { * whose value type is the point type * @tparam TetrahedronRange a model of the concept `RandomAccessContainer` whose * value type is a model of the concept `RandomAccessContainer` whose value type is `std::size_t` + * @tparam Triangulation a valid triangulation class that has + * a vertex base model of `MeshVertexBase_3` + * and a cell base model of `MeshCellBase_3` + * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" * * @param points points of the soup of tetrahedra * @param tets each element in the range describes a tetrahedron using the indices of the points @@ -107,6 +119,7 @@ namespace CGAL { * \cgalNamedParamsEnd * * @pre `points` contains each point only once + * @post the output triangulation should be a triangulation of the convex hull of `points` * * @sa `CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh()` */ @@ -127,6 +140,8 @@ namespace CGAL { auto facets = choose_parameter(get_parameter(np, internal_np::surface_facets), empty_map); CGAL::MDS_3::build_triangulation(tr, points, tets, facets); + + CGAL_assertion(CGAL::MDS_3::internal::is_convex(tr)); } template Date: Tue, 4 May 2021 09:47:17 +0200 Subject: [PATCH 23/79] wip user manual --- MDS_3/doc/MDS_3/MDS_3.txt | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/MDS_3/doc/MDS_3/MDS_3.txt b/MDS_3/doc/MDS_3/MDS_3.txt index 0fb6558590d..cfdbc90408a 100644 --- a/MDS_3/doc/MDS_3/MDS_3.txt +++ b/MDS_3/doc/MDS_3/MDS_3.txt @@ -14,12 +14,24 @@ Cut-view of a multi-domain 3D mesh generated from a segmented image. \section MDS_3_section_intro Introduction This package is devoted to the representation of 3-Dimensional Mesh Data Structures. -The domain to be meshed is a subset of 3D space, required to be bounded. + +A 3D mesh is a discretization of a given bounded subset of the 3D space, +that holds all geometric and combinatorial data to construct a valid +and consistent discretization. +In this chapter, we describe higher-level data structures available +for the description of such meshes. + +\section MDS_3_section_c3t3 + +CGAL provides 3D triangulations, that are described by +both their geometry and connectivity, using the +the `3D Triangulation` and `3D Triangulation Data Structure` packages. + +We introduce the concept of "mesh complex", that encodes extra information +on top of a 3D triangulation. -//The template parameter `C3T3` is required to be a model of -//the concept -//`MeshComplex_3InTriangulation_3`, a data structure devised to +`MeshComplex_3InTriangulation_3`, a data structure devised to //represent a three dimensional complex embedded in a 3D //triangulation. In both functions, an instance of type `C3T3` is used to maintain the current //approximating simplicial mesh From b414158f2d8ef287ebc3e926f2f0b2941ef65675 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 6 May 2021 11:43:49 +0200 Subject: [PATCH 24/79] wip user manual --- MDS_3/doc/MDS_3/MDS_3.txt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/MDS_3/doc/MDS_3/MDS_3.txt b/MDS_3/doc/MDS_3/MDS_3.txt index cfdbc90408a..f73a649757b 100644 --- a/MDS_3/doc/MDS_3/MDS_3.txt +++ b/MDS_3/doc/MDS_3/MDS_3.txt @@ -28,12 +28,18 @@ both their geometry and connectivity, using the the `3D Triangulation` and `3D Triangulation Data Structure` packages. We introduce the concept of "mesh complex", that encodes extra information -on top of a 3D triangulation. +on top of a 3D triangulation. A mesh complex describes one sub-complex +of the support 3D triangulation per dimension from 0 to 3 : +- corner vertices in 0D, +- feature edges in 1D, +- surface facets in 2D, +- domain cells in 3D. +The concept `MeshComplex_3InTriangulation_3` is a data structure devised to +represent a three dimensional complex embedded in a 3D +triangulation. -`MeshComplex_3InTriangulation_3`, a data structure devised to -//represent a three dimensional complex embedded in a 3D -//triangulation. In both functions, an instance of type `C3T3` is used to maintain the current +//In both functions, an instance of type `C3T3` is used to maintain the current //approximating simplicial mesh //and to represent the final 3D mesh at the end //of the procedure. From eaf8e9ee9821f1c1669f737124816dc31ab9404c Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 7 May 2021 11:19:30 +0200 Subject: [PATCH 25/79] add todo --- MDS_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MDS_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h b/MDS_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h index be86d8c609e..febd62466c1 100644 --- a/MDS_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h +++ b/MDS_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h @@ -156,6 +156,8 @@ void facets_in_complex_3_to_triangle_soup(const C3T3& c3t3, * * @param c3t3 an instance of `C3T3`. * @param graph an instance of `TriangleMesh`. + * + * @todo get the surface patch ids from `c3t3` to `graph` */ template void facets_in_complex_3_to_triangle_mesh(const C3T3& c3t3, TriangleMesh& graph) From 6ae0553d4f2ecf137e729d02824fbf139ba50b5d Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 7 May 2021 13:15:49 +0200 Subject: [PATCH 26/79] user manual --- MDS_3/doc/MDS_3/MDS_3.txt | 71 +++++++++++++------ MDS_3/doc/MDS_3/PackageDescription.txt | 2 +- MDS_3/doc/MDS_3/dependencies | 1 + MDS_3/doc/MDS_3/examples.txt | 1 + .../tetrahedron_soup_to_triangulation_3.h | 2 +- 5 files changed, 54 insertions(+), 23 deletions(-) diff --git a/MDS_3/doc/MDS_3/MDS_3.txt b/MDS_3/doc/MDS_3/MDS_3.txt index f73a649757b..579d0aafa4e 100644 --- a/MDS_3/doc/MDS_3/MDS_3.txt +++ b/MDS_3/doc/MDS_3/MDS_3.txt @@ -21,14 +21,20 @@ and consistent discretization. In this chapter, we describe higher-level data structures available for the description of such meshes. -\section MDS_3_section_c3t3 +\section MDS_3_section_c3t3 Mesh Complex -CGAL provides 3D triangulations, that are described by -both their geometry and connectivity, using the -the `3D Triangulation` and `3D Triangulation Data Structure` packages. +A 3D simplicial complex is composed of points, line segments, polygons, +polyhedral, and the combinatorial description of their n-dimension counterparts +(namely vertices, edges, faces and cells). +CGAL provides 3D triangulations, that describe +both the geometry and connectivity of a 3D simplicial complex made +of triangles, implemented in the +the \ref PkgTriangulation3 and \ref PkgTDS3 packages. We introduce the concept of "mesh complex", that encodes extra information -on top of a 3D triangulation. A mesh complex describes one sub-complex +on top of a 3D triangulation to represent a complete simplicial +complex. A mesh complex describes four sub-complexes +of simplices of the support 3D triangulation per dimension from 0 to 3 : - corner vertices in 0D, - feature edges in 1D, @@ -36,25 +42,48 @@ of the support 3D triangulation per dimension from 0 to 3 : - domain cells in 3D. The concept `MeshComplex_3InTriangulation_3` is a data structure devised to -represent a three dimensional complex embedded in a 3D -triangulation. +represent the three dimensional complexes embedded in a `Triangulation_3`. -//In both functions, an instance of type `C3T3` is used to maintain the current -//approximating simplicial mesh -//and to represent the final 3D mesh at the end -//of the procedure. -// -//The embedding 3D triangulation is required to be the nested type -//`CGAL::Mesh_triangulation_3::type`, provided by the class template -//`CGAL::Mesh_triangulation_3`. The type for this triangulation is a -//wrapper around the class `CGAL::Regular_triangulation_3` whose vertex and cell base classes -//are respectively models of the concepts `MeshVertexBase_3` and -//`MeshCellBase_3`. +@todo add figure -\subsection MDS_3ImplementationHistory Implementation History -The code of the package `MDS_3` was initially part of the package `Mesh_3`. -With the meshing processes becoming more versatile, it was moved to its own package in the +\section MDS_3_section_examples Examples + +\subsection TetSoupExample From Tetrahedron Soup to `Triangulation_3` + +In the example first example of this section, we build a random +`Delaunay_triangulation_3` and use it to build a consistent though +connectivity-free tetrahedron soup. +The tetrahedron soup is then put back together in a +`CGAL::Tetrahedral_remeshing::Remeshing_triangulation_3` before +being set as the reference triangulation of a `Mesh_complex_3_in_triangulation_3`. + +\cgalExample{MDS_3/tetrahedron_soup_to_c3t3_example.cpp} + + +\subsection IOExample Input/Output Example + +The example below illustrates how to use the IO functions +for reading and writing a triangulation with the `Medit` file format. + +\cgalExample{MDS_3/c3t3_example.cpp} + + +\subsection MoreExamples More Examples in other packages + +The `Mesh_complex_3_in_triangulation_3` is widely used in the \ref PkgMesh3 package. +Numerous more usage examples can be found in its \ref Mesh_3_section_examples section. + +The package \ref PkgTetrahedralRemeshing also makes use of the +`Mesh_complex_3_in_triangulation_3`, since it serves as a post-processing for +tetrahedral mesh generation. Some examples can be found in the \ref secTetRemeshingExamples +section. + + +\section MDS_3History Implementation History + +The code of the `MeshComplex_3InTriangulation_3` and its variants was initially part of the package `Mesh_3`. +With the meshing and remeshing processes becoming more versatile, it was moved to its own package in the release 5.4 of \cgal. */ diff --git a/MDS_3/doc/MDS_3/PackageDescription.txt b/MDS_3/doc/MDS_3/PackageDescription.txt index a057d712020..d6d8b8956b9 100644 --- a/MDS_3/doc/MDS_3/PackageDescription.txt +++ b/MDS_3/doc/MDS_3/PackageDescription.txt @@ -28,7 +28,7 @@ \cgalPkgManuals{Chapter_3D_Mesh_Data_Structures,PkgMDS3Ref} \cgalPkgSummaryEnd \cgalPkgShortInfoBegin -\cgalPkgSince{5.3} +\cgalPkgSince{5.4} \cgalPkgDependsOn{\ref PkgTriangulation3} \cgalPkgLicense{\ref licensesGPL "GPL"} \cgalPkgDemo{Polyhedron demo,polyhedron_3.zip} diff --git a/MDS_3/doc/MDS_3/dependencies b/MDS_3/doc/MDS_3/dependencies index 4db3ea7295e..94a47c3de6c 100644 --- a/MDS_3/doc/MDS_3/dependencies +++ b/MDS_3/doc/MDS_3/dependencies @@ -10,3 +10,4 @@ TDS_3 Polyhedron Miscellany Mesh_3 +Tetrahedral_remeshing diff --git a/MDS_3/doc/MDS_3/examples.txt b/MDS_3/doc/MDS_3/examples.txt index 03c1706466f..e152939aa57 100644 --- a/MDS_3/doc/MDS_3/examples.txt +++ b/MDS_3/doc/MDS_3/examples.txt @@ -1,3 +1,4 @@ /*! \example MDS_3/c3t3_example.cpp +\example MDS_3/tetrahedron_soup_to_c3t3_example.cpp */ diff --git a/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h b/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h index fce8e1debd6..63f76a5fec4 100644 --- a/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h +++ b/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h @@ -103,7 +103,7 @@ namespace CGAL { * @param tets each element in the range describes a tetrahedron using the indices of the points * in `points` (indices 0 to 3), and the associated `Subdomain_index` (index 4) * @param tr the 3D triangulation to be built - * @param np an optional sequence of \ref mds3_namedparameters "Named Parameters" among the ones listed below + * @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below * * \cgalNamedParamsBegin * \cgalParamNBegin{surface_facets} From 09673649a271b08057a1723772b10d53b939cf8d Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 7 May 2021 14:32:08 +0200 Subject: [PATCH 27/79] fix utf-8 --- MDS_3/doc/MDS_3/MDS_3.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MDS_3/doc/MDS_3/MDS_3.txt b/MDS_3/doc/MDS_3/MDS_3.txt index 579d0aafa4e..1344fb36475 100644 --- a/MDS_3/doc/MDS_3/MDS_3.txt +++ b/MDS_3/doc/MDS_3/MDS_3.txt @@ -31,7 +31,7 @@ both the geometry and connectivity of a 3D simplicial complex made of triangles, implemented in the the \ref PkgTriangulation3 and \ref PkgTDS3 packages. -We introduce the concept of "mesh complex", that encodes extra information +We introduce the concept of \em mesh \em complex, that encodes extra information on top of a 3D triangulation to represent a complete simplicial complex. A mesh complex describes four sub-complexes of simplices @@ -44,7 +44,7 @@ of the support 3D triangulation per dimension from 0 to 3 : The concept `MeshComplex_3InTriangulation_3` is a data structure devised to represent the three dimensional complexes embedded in a `Triangulation_3`. -@todo add figure +\todo add figure \section MDS_3_section_examples Examples From 8f97a9bcf457b1fb1bb3658a6bd3d83311927a2f Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 7 May 2021 15:22:18 +0200 Subject: [PATCH 28/79] CHANGES.md --- Installation/CHANGES.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index 38102e7205f..693eb6439aa 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -1,6 +1,18 @@ Release History =============== +[Release 5.4](https://github.com/CGAL/cgal/releases/tag/v5.4) +----------- + +Release date: + +### [Mesh Data Structure 3](https://doc.cgal.org/5.4/Manual/packages.html#PkgMDS3) (new package) + +- This new package wraps all the existing code that deals with a +` MeshComplex_3InTriangulation_3`, and makes the data structure independant +from the tetrahedral mesh generation package. + + [Release 5.3](https://github.com/CGAL/cgal/releases/tag/v5.3) ----------- From 3303b5c7f2b28d58b8810130839e768ab8bc1806 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 7 May 2021 15:32:26 +0200 Subject: [PATCH 29/79] add package to package overview --- Documentation/doc/Documentation/packages.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/doc/Documentation/packages.txt b/Documentation/doc/Documentation/packages.txt index 1ce8cb797a6..efc86338dd8 100644 --- a/Documentation/doc/Documentation/packages.txt +++ b/Documentation/doc/Documentation/packages.txt @@ -90,6 +90,7 @@ \package_listing{Mesh_2} \package_listing{Surface_mesher} \package_listing{Skin_surface_3} +\package_listing{MDS_3} \package_listing{Mesh_3} \package_listing{Tetrahedral_remeshing} \package_listing{Periodic_3_mesh_3} From 7f6c402c9ea3ace8fcf74e0262184b993aab51d6 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 7 May 2021 16:08:09 +0200 Subject: [PATCH 30/79] change charset to utf-8 and fix accents --- MDS_3/doc/MDS_3/MDS_3.txt | 2 +- MDS_3/doc/MDS_3/PackageDescription.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MDS_3/doc/MDS_3/MDS_3.txt b/MDS_3/doc/MDS_3/MDS_3.txt index 1344fb36475..cbd506981c1 100644 --- a/MDS_3/doc/MDS_3/MDS_3.txt +++ b/MDS_3/doc/MDS_3/MDS_3.txt @@ -4,7 +4,7 @@ namespace CGAL { \mainpage User Manual \anchor Chapter_3D_Mesh_Data_Structure \anchor userchaptermds3 -\authors Pierre Alliez, Clément Jamin, Laurent Rineau, Stéphane Tayeb, Jane Tournois, Mariette Yvinec +\authors Pierre Alliez, Clément Jamin, Laurent Rineau, Stéphane Tayeb, Jane Tournois, Mariette Yvinec \cgalAutoToc \cgalFigureBegin{figuremultilabel_mesher,multilabel_mesher.jpg} diff --git a/MDS_3/doc/MDS_3/PackageDescription.txt b/MDS_3/doc/MDS_3/PackageDescription.txt index d6d8b8956b9..c5deb046956 100644 --- a/MDS_3/doc/MDS_3/PackageDescription.txt +++ b/MDS_3/doc/MDS_3/PackageDescription.txt @@ -23,7 +23,7 @@ \todo add pkg picture \cgalPkgPicture{MDS_3/fig/c3t3.jpg} \cgalPkgSummaryBegin -\cgalPkgAuthors{Pierre Alliez, Clément Jamin, Laurent Rineau, Stéphane Tayeb, Jane Tournois, Mariette Yvinec} +\cgalPkgAuthors{Pierre Alliez, Clément Jamin, Laurent Rineau, Stéphane Tayeb, Jane Tournois, Mariette Yvinec} \cgalPkgDesc{This package is devoted to the description of 3D Mesh Data Structures.} \cgalPkgManuals{Chapter_3D_Mesh_Data_Structures,PkgMDS3Ref} \cgalPkgSummaryEnd From cd9e608f415eebaf1a68ed4d76ca3c6a1e8c1021 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 7 May 2021 15:26:05 +0100 Subject: [PATCH 31/79] change to utf-8 --- MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h b/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h index 63f76a5fec4..3b655e93e40 100644 --- a/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h +++ b/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h @@ -9,7 +9,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // -// Author(s) : Mael Rouxel-Labbé, Maxime Gimeno, Jane Tournois +// Author(s) : Mael Rouxel-Labbé, Maxime Gimeno, Jane Tournois // //****************************************************************************** // File Description : From bb547245986ccbf77bfc2da06b3003656ace854c Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 7 May 2021 17:22:21 +0200 Subject: [PATCH 32/79] fix namespace --- .../include/CGAL/Periodic_3_mesh_3/IO/File_medit.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/IO/File_medit.h b/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/IO/File_medit.h index 63c2b6bb934..fa9b46b779b 100644 --- a/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/IO/File_medit.h +++ b/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/IO/File_medit.h @@ -308,7 +308,7 @@ void output_to_medit(std::ostream& os, #endif CGAL_precondition(c3t3.triangulation().is_1_cover()); - typedef CGAL::Mesh_3::Medit_pmap_generator Generator; + typedef CGAL::MDS_3::Medit_pmap_generator Generator; typedef typename Generator::Cell_pmap Cell_pmap; typedef typename Generator::Facet_pmap Facet_pmap; typedef typename Generator::Facet_pmap_twice Facet_pmap_twice; From dd818412e539ea18e87a1338fba3e000f4b0ca25 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 10 May 2021 12:12:16 +0200 Subject: [PATCH 33/79] fix compilation --- Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp index 3441316accd..22d20416eee 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp @@ -420,9 +420,9 @@ public: std::swap(finite_cells[i][1], finite_cells[i][3]); } } - std::vector new_vertices; + CGAL::MDS_3::build_triangulation(c3t3_item->c3t3().triangulation(), - points, finite_cells, border_facets, new_vertices); + points, finite_cells, border_facets); for( C3t3::Triangulation::Finite_cells_iterator cit = c3t3_item->c3t3().triangulation().finite_cells_begin(); From b8da09f2e399800dfdf52effdd6b6b26ac97b49e Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 10 May 2021 14:11:16 +0200 Subject: [PATCH 34/79] add another version of build_triangulation and fix compilation --- MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h | 17 ++++++++++++++++- .../internal/collapse_short_edges.h | 6 +++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h b/MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h index 05d2c0cf1bc..23304df384e 100644 --- a/MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h +++ b/MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h @@ -341,6 +341,7 @@ bool build_triangulation(Tr& tr, const std::vector& points, const std::vector >& finite_cells, const std::map, typename Tr::Cell::Surface_patch_index>& border_facets, + std::vector& vertex_handle_vector, const bool verbose = false, bool replace_domain_0 = false) { @@ -353,7 +354,6 @@ bool build_triangulation(Tr& tr, typedef boost::unordered_map > Incident_cells_map; Incident_cells_map incident_cells_map; - std::vector vertex_handle_vector; vertex_handle_vector.resize(points.size() + 1); // id to vertex_handle //index 0 is for infinite vertex // 1 to n for points in `points` @@ -394,6 +394,21 @@ bool build_triangulation(Tr& tr, return tr.tds().is_valid(); } +template +bool build_triangulation(Tr& tr, + const std::vector& points, + const std::vector >& finite_cells, + const std::map, typename Tr::Cell::Surface_patch_index>& border_facets, + const bool verbose = false, + bool replace_domain_0 = false) +{ + std::vector vertex_handle_vector; + + return build_triangulation(tr, points, finite_cells, border_facets, + vertex_handle_vector, + verbose, replace_domain_0); +} + template bool build_triangulation_from_file(std::istream& is, Tr& tr, diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h index 99c06df497d..5d2275eb335 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h @@ -109,9 +109,9 @@ public: // finished std::vector new_vertices; std::map border_facets; - if (CGAL::build_triangulation(triangulation, - points, finite_cells, border_facets, - new_vertices, false/*verbose*/)) + if (CGAL::MDS_3::build_triangulation(triangulation, + points, finite_cells, border_facets, + new_vertices /*, verbose*/)) { CGAL_assertion(triangulation.tds().is_valid()); CGAL_assertion(triangulation.infinite_vertex() == new_vertices[0]); From 39120dbaf35eb453f909cdbfd11db9e8986b2d5c Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 10 May 2021 15:20:23 +0200 Subject: [PATCH 35/79] fix includes --- .../CGAL/Periodic_3_mesh_3/Protect_edges_sizing_field.h | 6 +++--- .../include/CGAL/Periodic_3_mesh_triangulation_3.h | 2 +- Periodic_3_mesh_3/include/CGAL/refine_periodic_3_mesh_3.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/Protect_edges_sizing_field.h b/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/Protect_edges_sizing_field.h index 8b0f3b1fb6c..ea2e71ccaed 100644 --- a/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/Protect_edges_sizing_field.h +++ b/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_3/Protect_edges_sizing_field.h @@ -31,12 +31,12 @@ #include -#include +#include #ifdef CGAL_MESH_3_DUMP_FEATURES_PROTECTION_ITERATIONS #include #endif #include -#include +#include #include #include @@ -75,7 +75,7 @@ namespace Periodic_3_mesh_3 { template class Protect_edges_sizing_field - : public CGAL::Mesh_3::internal::Debug_messages_tools + : public CGAL::MDS_3::internal::Debug_messages_tools { typedef Protect_edges_sizing_field Self; diff --git a/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_triangulation_3.h b/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_triangulation_3.h index 72f731760ec..7abce20f71f 100644 --- a/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_triangulation_3.h +++ b/Periodic_3_mesh_3/include/CGAL/Periodic_3_mesh_triangulation_3.h @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include diff --git a/Periodic_3_mesh_3/include/CGAL/refine_periodic_3_mesh_3.h b/Periodic_3_mesh_3/include/CGAL/refine_periodic_3_mesh_3.h index acb3b35decd..b3a8c8f465f 100644 --- a/Periodic_3_mesh_3/include/CGAL/refine_periodic_3_mesh_3.h +++ b/Periodic_3_mesh_3/include/CGAL/refine_periodic_3_mesh_3.h @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include #include From d9e0daca540f26ca4513746c99e6f3ff92686b3a Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 10 May 2021 15:58:24 +0200 Subject: [PATCH 36/79] add cgalPkgBib --- MDS_3/doc/MDS_3/PackageDescription.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/MDS_3/doc/MDS_3/PackageDescription.txt b/MDS_3/doc/MDS_3/PackageDescription.txt index c5deb046956..9fc2a28147d 100644 --- a/MDS_3/doc/MDS_3/PackageDescription.txt +++ b/MDS_3/doc/MDS_3/PackageDescription.txt @@ -30,6 +30,7 @@ \cgalPkgShortInfoBegin \cgalPkgSince{5.4} \cgalPkgDependsOn{\ref PkgTriangulation3} +\cgalPkgBib{cgal:ajrtty-mds3} \cgalPkgLicense{\ref licensesGPL "GPL"} \cgalPkgDemo{Polyhedron demo,polyhedron_3.zip} \cgalPkgShortInfoEnd From bdb37589f6689e15a16c7c9541b98b6e597edcd0 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 11 May 2021 09:29:14 +0200 Subject: [PATCH 37/79] use orientation function and avoid a compilation error about CGAL::orientation not defined because of missing includes --- MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h b/MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h index 23304df384e..4426770bf3d 100644 --- a/MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h +++ b/MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h @@ -17,7 +17,7 @@ #ifndef CGAL_MDS_3_TET_SOUP_TO_C3T3_H #define CGAL_MDS_3_TET_SOUP_TO_C3T3_H -#include +#include #include #include @@ -119,6 +119,8 @@ bool build_finite_cells(Tr& tr, CGAL_assertion_code( typename Tr::Geom_traits::Construct_point_3 cp = tr.geom_traits().construct_point_3_object(); + typename Tr::Geom_traits::Orientation_3 orientation = + tr.geom_traits().orientation_3_object(); ) int max_domain = 0; if(replace_domain_0) @@ -146,8 +148,8 @@ bool build_finite_cells(Tr& tr, } // this assertion also tests for degeneracy - CGAL_assertion(CGAL::orientation(cp(tr.point(vs[0])), cp(tr.point(vs[1])), - cp(tr.point(vs[2])), cp(tr.point(vs[3]))) + CGAL_assertion(orientation(cp(tr.point(vs[0])), cp(tr.point(vs[1])), + cp(tr.point(vs[2])), cp(tr.point(vs[3]))) == POSITIVE); Cell_handle c = tr.tds().create_cell(vs[0], vs[1], vs[2], vs[3]); From 2d093e8473ae402fb4e4ac7745f65c48c8ef1beb Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 11 May 2021 10:50:06 +0200 Subject: [PATCH 38/79] add doc dependencies --- MDS_3/doc/MDS_3/dependencies | 1 + 1 file changed, 1 insertion(+) diff --git a/MDS_3/doc/MDS_3/dependencies b/MDS_3/doc/MDS_3/dependencies index 94a47c3de6c..aba33fcd34a 100644 --- a/MDS_3/doc/MDS_3/dependencies +++ b/MDS_3/doc/MDS_3/dependencies @@ -1,4 +1,5 @@ Manual +BGL Kernel_23 STL_Extension Algebraic_foundations From 239a75e62bfa0a383a496fdb3cc1e0db6c03e63a Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 11 May 2021 11:44:56 +0200 Subject: [PATCH 39/79] use traits' orientation functor --- MDS_3/include/CGAL/internal/MDS_3/MDS_3_helper.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/MDS_3/include/CGAL/internal/MDS_3/MDS_3_helper.h b/MDS_3/include/CGAL/internal/MDS_3/MDS_3_helper.h index 0605e766fdb..4aa2c59ad09 100644 --- a/MDS_3/include/CGAL/internal/MDS_3/MDS_3_helper.h +++ b/MDS_3/include/CGAL/internal/MDS_3/MDS_3_helper.h @@ -33,6 +33,8 @@ namespace internal { typedef typename Triangulation::Geom_traits::Point_3 Point_3; typename Triangulation::Geom_traits::Construct_point_3 cp = tr.geom_traits().construct_point_3_object(); + typename Triangulation::Geom_traits::Orientation_3 orientation = + tr.geom_traits().orientation_3_object(); std::vector infcells; tr.incident_cells(tr.infinite_vertex(), std::back_inserter(infcells)); @@ -44,15 +46,15 @@ namespace internal { const std::array pfacet = { cp(neigh->vertex((i + 1) % 4)->point()), cp(neigh->vertex((i + 2) % 4)->point()), cp(neigh->vertex((i + 3) % 4)->point())}; - const CGAL::Orientation o = CGAL::orientation( + const CGAL::Orientation o = orientation( pfacet[0], pfacet[1], pfacet[2], cp(neigh->vertex(i)->point())); for (Vertex_handle v : tr.finite_vertex_handles()) { if (c->has_vertex(v)) continue; - if (o != CGAL::orientation(pfacet[0], pfacet[1], pfacet[2], - cp(neigh->vertex(i)->point()))) + if (o != orientation(pfacet[0], pfacet[1], pfacet[2], + cp(neigh->vertex(i)->point()))) return false; } } From 9618f18334c73564d6737638ac23659628962a47 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 11 May 2021 12:53:43 +0200 Subject: [PATCH 40/79] use orientation functor and fix conversion warning --- .../CGAL/tetrahedron_soup_to_triangulation_3.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h b/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h index 3b655e93e40..17229b2932c 100644 --- a/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h +++ b/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h @@ -57,6 +57,11 @@ namespace CGAL { std::map, typename Tr::Cell::Surface_patch_index> border_facets; std::map p2i; + CGAL_assertion_code( + typename Triangulation::Geom_traits::Orientation_3 orientation = + tr.geom_traits().orientation_3_object(); + ); + for (typename TetrahedronRange::value_type tet : tets) { CGAL_assertion(tet.orientation() == CGAL::POSITIVE); @@ -68,15 +73,16 @@ namespace CGAL { if (p2i.find(pi) == p2i.end()) { points.push_back(pi); - p2i.insert(std::make_pair(pi, points.size() - 1)); - cell[i] = static_cast(points.size() - 1); + int index = static_cast(points.size() - 1); + p2i.insert(std::make_pair(pi, index)); + cell[i] = index; } else cell[i] = p2i.at(pi); } cell[4] = 1; - CGAL_assertion(CGAL::orientation(points[cell[0]], + CGAL_assertion(orientation(points[cell[0]], points[cell[1]], points[cell[2]], points[cell[3]]) == CGAL::POSITIVE); finite_cells.push_back(cell); From fc525132e4fcd39f912d288bae5144e133113be8 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 11 May 2021 13:42:19 +0200 Subject: [PATCH 41/79] fix dependencies - code and doc --- Mesh_3/package_info/Mesh_3/dependencies | 1 + Tetrahedral_remeshing/doc/Tetrahedral_remeshing/dependencies | 1 + .../package_info/Tetrahedral_remeshing/dependencies | 1 + 3 files changed, 3 insertions(+) diff --git a/Mesh_3/package_info/Mesh_3/dependencies b/Mesh_3/package_info/Mesh_3/dependencies index 2bfb2043f8b..ef353eab235 100644 --- a/Mesh_3/package_info/Mesh_3/dependencies +++ b/Mesh_3/package_info/Mesh_3/dependencies @@ -19,6 +19,7 @@ Intersections_3 Interval_support Kernel_23 Kernel_d +MDS_3 Mesh_3 Mesher_level Modifier diff --git a/Tetrahedral_remeshing/doc/Tetrahedral_remeshing/dependencies b/Tetrahedral_remeshing/doc/Tetrahedral_remeshing/dependencies index 30913764fab..14160e269fd 100644 --- a/Tetrahedral_remeshing/doc/Tetrahedral_remeshing/dependencies +++ b/Tetrahedral_remeshing/doc/Tetrahedral_remeshing/dependencies @@ -8,3 +8,4 @@ Triangulation_3 BGL Mesh_3 TDS_3 +MDS_3 diff --git a/Tetrahedral_remeshing/package_info/Tetrahedral_remeshing/dependencies b/Tetrahedral_remeshing/package_info/Tetrahedral_remeshing/dependencies index 2311653695c..b90ad8d775b 100644 --- a/Tetrahedral_remeshing/package_info/Tetrahedral_remeshing/dependencies +++ b/Tetrahedral_remeshing/package_info/Tetrahedral_remeshing/dependencies @@ -14,6 +14,7 @@ Intersections_3 Interval_support Kernel_23 Kernel_d +MDS_3 Mesh_3 Modular_arithmetic Number_types From d411e9d06dbbd85f9715a25f7f11d3f2a522b5a5 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 11 May 2021 14:37:44 +0200 Subject: [PATCH 42/79] fix dependencies --- Periodic_3_mesh_3/package_info/Periodic_3_mesh_3/dependencies | 1 + 1 file changed, 1 insertion(+) diff --git a/Periodic_3_mesh_3/package_info/Periodic_3_mesh_3/dependencies b/Periodic_3_mesh_3/package_info/Periodic_3_mesh_3/dependencies index c07e2af9cd5..0592d98fa00 100644 --- a/Periodic_3_mesh_3/package_info/Periodic_3_mesh_3/dependencies +++ b/Periodic_3_mesh_3/package_info/Periodic_3_mesh_3/dependencies @@ -16,6 +16,7 @@ Intersections_3 Interval_support Kernel_23 Kernel_d +MDS_3 Mesh_3 Mesher_level Modular_arithmetic From b07e76135c941de65e5920a529983ba95b072957 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 11 May 2021 16:11:10 +0200 Subject: [PATCH 43/79] fix dependencies --- MDS_3/package_info/MDS_3/dependencies | 14 +------------- .../package_info/Periodic_3_mesh_3/dependencies | 1 - 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/MDS_3/package_info/MDS_3/dependencies b/MDS_3/package_info/MDS_3/dependencies index 2bfb2043f8b..63b1fb79d40 100644 --- a/MDS_3/package_info/MDS_3/dependencies +++ b/MDS_3/package_info/MDS_3/dependencies @@ -1,16 +1,11 @@ -AABB_tree Algebraic_foundations Arithmetic_kernel BGL -CGAL_ImageIO Cartesian_kernel Circulator -Convex_hull_2 Distance_2 Distance_3 Filtered_kernel -Generator -HalfedgeDS Hash_map Homogeneous_kernel Installation @@ -19,22 +14,15 @@ Intersections_3 Interval_support Kernel_23 Kernel_d -Mesh_3 -Mesher_level -Modifier +MDS_3 Modular_arithmetic Number_types Polygon Polygon_mesh_processing -Polyhedron -Principal_component_analysis -Principal_component_analysis_LGPL Profiling_tools Property_map Random_numbers STL_Extension -Solver_interface -Spatial_searching Spatial_sorting Stream_support TDS_3 diff --git a/Periodic_3_mesh_3/package_info/Periodic_3_mesh_3/dependencies b/Periodic_3_mesh_3/package_info/Periodic_3_mesh_3/dependencies index 0592d98fa00..9046a3843f9 100644 --- a/Periodic_3_mesh_3/package_info/Periodic_3_mesh_3/dependencies +++ b/Periodic_3_mesh_3/package_info/Periodic_3_mesh_3/dependencies @@ -35,4 +35,3 @@ Spatial_sorting Stream_support TDS_3 Triangulation_3 -Union_find From 57439c0235e0fa37de62a4779134f52ac043b535 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 18 May 2021 10:22:51 +0200 Subject: [PATCH 44/79] wip : transfer surface patch indices from c3t3 to Surface_mesh in export_facets_in_complex() --- .../CGAL/boost/graph/copy_face_graph.h | 31 ------- .../CGAL/boost/graph/internal/helpers.h | 36 ++++++++ .../CGAL/boost/graph/parameters_interface.h | 2 + .../IO/facets_in_complex_3_to_triangle_mesh.h | 85 +++++++++++++++++-- ...n_of_complex_3_in_triangulation_3_to_off.h | 9 +- .../polygon_soup_to_polygon_mesh.h | 34 +++++++- .../demo/Polyhedron/Scene_c3t3_item.cpp | 9 +- 7 files changed, 160 insertions(+), 46 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/copy_face_graph.h b/BGL/include/CGAL/boost/graph/copy_face_graph.h index 19755ac8e46..a557aa9a73b 100644 --- a/BGL/include/CGAL/boost/graph/copy_face_graph.h +++ b/BGL/include/CGAL/boost/graph/copy_face_graph.h @@ -25,7 +25,6 @@ #include #include #include -#include namespace CGAL { @@ -212,36 +211,6 @@ void copy_face_graph_impl(const SourceMesh& sm, TargetMesh& tm, } } // end of namespace internal -namespace impl -{ -template -struct Output_iterator_functor -{ - typedef typename boost::property_traits::key_type input_t; - typedef typename boost::property_traits::value_type output_t; - PMAP map; - Output_iterator_functor(PMAP map) - :map(map) - { - } - void operator()(const typename std::pair& pair) - { - put(map, pair.first, pair.second); - } - -}; - -template -boost::function_output_iterator > make_functor(PMAP map) -{ - return boost::make_function_output_iterator(Output_iterator_functor(map)); -} - -inline Emptyset_iterator make_functor(const internal_np::Param_not_found&) -{ - return Emptyset_iterator(); -} -}//end of impl /*! \ingroup PkgBGLHelperFct diff --git a/BGL/include/CGAL/boost/graph/internal/helpers.h b/BGL/include/CGAL/boost/graph/internal/helpers.h index 98d3c7ec28b..262d0d36abc 100644 --- a/BGL/include/CGAL/boost/graph/internal/helpers.h +++ b/BGL/include/CGAL/boost/graph/internal/helpers.h @@ -13,7 +13,11 @@ #include #include +#include +#include #include +#include +#include namespace CGAL { @@ -200,6 +204,38 @@ adjust_incoming_halfedge(typename boost::graph_traits::vertex_descriptor } // internal + +namespace impl +{ + template + struct Output_iterator_functor + { + typedef typename boost::property_traits::key_type input_t; + typedef typename boost::property_traits::value_type output_t; + PMAP map; + Output_iterator_functor(PMAP map) + :map(map) + { + } + void operator()(const typename std::pair& pair) + { + put(map, pair.first, pair.second); + } + + }; + + template + boost::function_output_iterator > make_functor(PMAP map) + { + return boost::make_function_output_iterator(Output_iterator_functor(map)); + } + + inline Emptyset_iterator make_functor(const internal_np::Param_not_found&) + { + return Emptyset_iterator(); + } +}//end of impl + } // CGAL diff --git a/BGL/include/CGAL/boost/graph/parameters_interface.h b/BGL/include/CGAL/boost/graph/parameters_interface.h index abda58221b5..03561471e21 100644 --- a/BGL/include/CGAL/boost/graph/parameters_interface.h +++ b/BGL/include/CGAL/boost/graph/parameters_interface.h @@ -32,6 +32,8 @@ CGAL_add_named_parameter(face_partition_id_t, face_partition_id, face_partition_ CGAL_add_named_parameter(vertex_to_vertex_output_iterator_t, vertex_to_vertex_output_iterator, vertex_to_vertex_output_iterator) CGAL_add_named_parameter(halfedge_to_halfedge_output_iterator_t, halfedge_to_halfedge_output_iterator, halfedge_to_halfedge_output_iterator) CGAL_add_named_parameter(face_to_face_output_iterator_t, face_to_face_output_iterator, face_to_face_output_iterator) +CGAL_add_named_parameter(point_to_vertex_output_iterator_t, point_to_vertex_output_iterator, point_to_vertex_output_iterator) +CGAL_add_named_parameter(polygon_to_face_output_iterator_t, polygon_to_face_output_iterator, polygon_to_face_output_iterator) CGAL_add_named_parameter(vertex_to_vertex_map_t, vertex_to_vertex_map, vertex_to_vertex_map) CGAL_add_named_parameter(halfedge_to_halfedge_map_t, halfedge_to_halfedge_map, halfedge_to_halfedge_map) diff --git a/MDS_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h b/MDS_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h index febd62466c1..af01e9c00fc 100644 --- a/MDS_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h +++ b/MDS_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h @@ -20,7 +20,10 @@ #include #include #include +#include +#include #include +#include #include #include @@ -48,11 +51,12 @@ void resize(std::array&, std::size_t CGAL_assertion_code(size)) CGAL_assertion(size == N); } -template +template void facets_in_complex_3_to_triangle_soup(const C3T3& c3t3, const typename C3T3::Subdomain_index sd_index, PointContainer& points, FaceContainer& faces, + PatchIndexContainer& patches, const bool normals_point_outside_of_the_subdomain = true, const bool export_all_facets = false) { @@ -60,6 +64,7 @@ void facets_in_complex_3_to_triangle_soup(const C3T3& c3t3, typedef typename FaceContainer::value_type Face; typedef typename C3T3::Triangulation Tr; + typedef typename C3T3::Surface_patch_index Surface_patch_index; typedef typename Tr::Vertex_handle Vertex_handle; typedef typename Tr::Cell_handle Cell_handle; @@ -74,6 +79,7 @@ void facets_in_complex_3_to_triangle_soup(const C3T3& c3t3, size_type nf = c3t3.number_of_facets_in_complex(); faces.reserve(faces.size() + nf); + patches.reserve(faces.size() + nf); points.reserve(points.size() + nf/2); // approximating Euler VHmap vh_to_ids; @@ -84,6 +90,7 @@ void facets_in_complex_3_to_triangle_soup(const C3T3& c3t3, { Cell_handle c = fit->first; int s = fit->second; + const Surface_patch_index spi = c->surface_patch_index(s); Face f; resize(f, 3); @@ -126,20 +133,50 @@ void facets_in_complex_3_to_triangle_soup(const C3T3& c3t3, } faces.push_back(f); + patches.push_back(spi); } } -template +template void facets_in_complex_3_to_triangle_soup(const C3T3& c3t3, PointContainer& points, - FaceContainer& faces) + FaceContainer& faces, + SurfacePatchContainer& patches) { typedef typename C3T3::Subdomain_index Subdomain_index; Subdomain_index useless = Subdomain_index(); - facets_in_complex_3_to_triangle_soup(c3t3, useless, points, faces, + facets_in_complex_3_to_triangle_soup(c3t3, useless, points, faces, patches, true/*point outward*/, true /*extract all facets*/); } +template +void set_face_patches(const Index2FaceMap&, + const SurfacePatchRange&, + internal_np::Param_not_found&) +{ + return; +} +template +void set_face_patches(const Index2FaceMap&, + const SurfacePatchRange&, + internal_np::No_property&) +{ + return; +} + +template +void set_face_patches(const Index2FaceMap& i2f, + const SurfacePatchRange& patches, + FacePatchMap& fpmap) +{ + for (auto index_and_face : i2f) + { + put(fpmap, index_and_face.second, patches[index_and_face.first]); + } +} + } // end namespace internal } // end namespace Mesh_3 @@ -153,32 +190,62 @@ void facets_in_complex_3_to_triangle_soup(const C3T3& c3t3, * * @tparam C3T3 a model of `MeshComplexWithFeatures_3InTriangulation_3`. * @tparam TriangleMesh a model of `MutableFaceGraph` with an internal point property map. The point type should be compatible with the one used in `C3T3`. + * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" * * @param c3t3 an instance of `C3T3`. * @param graph an instance of `TriangleMesh`. + * @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below * - * @todo get the surface patch ids from `c3t3` to `graph` + * \cgalNamedParamsBegin + * \cgalParamNBegin{face_patch_map} +* \cgalParamDescription{a property map with the patch id's associated to the faces of `faces(graph)`} +* \cgalParamType{a class model of `ReadWritePropertyMap` with `boost::graph_traits::%face_descriptor` +* as key type and the desired property, model of `CopyConstructible` and `LessThanComparable` as value type.} +* \cgalParamDefault{If not provided, faces patch ids are ignored.} +* \cgalParamExtra{The map is updated during the remeshing process while new faces are created.} +* \cgalParamNEnd +* \cgalNamedParamsEnd */ -template -void facets_in_complex_3_to_triangle_mesh(const C3T3& c3t3, TriangleMesh& graph) +template +void facets_in_complex_3_to_triangle_mesh(const C3T3& c3t3, + TriangleMesh& graph, + const NamedParameters& np) { namespace PMP = CGAL::Polygon_mesh_processing; typedef typename boost::property_map::type VertexPointMap; typedef typename boost::property_traits::value_type Point_3; + typedef typename boost::graph_traits::face_descriptor face_descriptor; + typedef typename C3T3::Surface_patch_index Surface_patch_index; typedef std::array Face; std::vector faces; + std::vector patches; std::vector points; - MDS_3::internal::facets_in_complex_3_to_triangle_soup(c3t3, points, faces); + MDS_3::internal::facets_in_complex_3_to_triangle_soup(c3t3, points, faces, patches); if(!PMP::is_polygon_soup_a_polygon_mesh(faces)) PMP::orient_polygon_soup(points, faces); CGAL_postcondition(PMP::is_polygon_soup_a_polygon_mesh(faces)); - PMP::polygon_soup_to_polygon_mesh(points, faces, graph); + boost::unordered_map i2f; + PMP::polygon_soup_to_polygon_mesh(points, faces, graph, + CGAL::parameters::polygon_to_face_output_iterator(std::inserter(i2f, i2f.end()))); + + using parameters::choose_parameter; + using parameters::get_parameter; + + MDS_3::internal::set_face_patches(i2f, + patches, + get_parameter(np, internal_np::face_patch)); +} + +template +void facets_in_complex_3_to_triangle_mesh(const C3T3& c3t3, TriangleMesh& graph) +{ + facets_in_complex_3_to_triangle_mesh(c3t3, graph, parameters::all_default()); } } // namespace CGAL diff --git a/MDS_3/include/CGAL/internal/MDS_3/Boundary_of_subdomain_of_complex_3_in_triangulation_3_to_off.h b/MDS_3/include/CGAL/internal/MDS_3/Boundary_of_subdomain_of_complex_3_in_triangulation_3_to_off.h index 9423aa11ba9..13b4e1e7797 100644 --- a/MDS_3/include/CGAL/internal/MDS_3/Boundary_of_subdomain_of_complex_3_in_triangulation_3_to_off.h +++ b/MDS_3/include/CGAL/internal/MDS_3/Boundary_of_subdomain_of_complex_3_in_triangulation_3_to_off.h @@ -58,11 +58,14 @@ output_boundary_of_c3t3_to_off(const C3T3& c3t3, { typedef typename C3T3::Triangulation::Geom_traits::Point_3 Point; typedef std::vector Face; + typedef typename C3T3::Surface_patch_index Surface_patch_index; std::vector points; std::vector faces; + std::vector patches; - CGAL::MDS_3::internal::facets_in_complex_3_to_triangle_soup(c3t3, sd_index, points, faces, normals_point_outside_of_the_subdomain); + CGAL::MDS_3::internal::facets_in_complex_3_to_triangle_soup(c3t3, sd_index, points, faces, + patches, normals_point_outside_of_the_subdomain); return output_polygon_soup_to_off(points, faces, out); } @@ -73,12 +76,14 @@ output_facets_in_complex_to_off(const C3T3& c3t3, std::ostream& out) { typedef typename C3T3::Triangulation::Geom_traits::Point_3 Point; + typedef typename C3T3::Surface_patch_index Surface_patch_index; typedef std::vector Face; std::vector points; std::vector faces; + std::vector patches; - CGAL::MDS_3::internal::facets_in_complex_3_to_triangle_soup(c3t3, points, faces); + CGAL::MDS_3::internal::facets_in_complex_3_to_triangle_soup(c3t3, points, faces, patches); return output_polygon_soup_to_off(points, faces, out); } diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h index 9e704870c18..9759baf0f30 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -74,9 +75,13 @@ public: m_pm(pm) { } - template + template //polygonindex-2-face void operator()(PolygonMesh& pmesh, VertexPointMap vpm, + V2V i2v, + F2F i2f, const bool insert_isolated_vertices = true) { typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; @@ -109,6 +114,7 @@ public: vertices[i] = add_vertex(pmesh); PM_Point pi = convert_to_pm_point(get(m_pm, m_points[i])); put(vpm, vertices[i], pi); + *i2v++ = std::make_pair(i, vertices[i]); } for(std::size_t i = 0, end = m_polygons.size(); i < end; ++i) @@ -121,9 +127,10 @@ public: for(std::size_t j = 0; j < size; ++j) vr[j] = vertices[polygon[j] ]; - CGAL_assertion_code(typename boost::graph_traits::face_descriptor fd =) + typename boost::graph_traits::face_descriptor fd = CGAL::Euler::add_face(vr, pmesh); CGAL_assertion(fd != boost::graph_traits::null_face()); + *i2f++ = std::make_pair(i, fd); } } @@ -248,6 +255,23 @@ bool is_polygon_soup_a_polygon_mesh(const PolygonRange& polygons) * of the vertex point map associated to the polygon mesh} * \cgalParamDefault{`CGAL::Identity_property_map`} * \cgalParamNEnd +* +* \cgalParamNBegin{point_to_vertex_output_iterator} +* \cgalParamDescription{an `OutputIterator` containing the pairs source-vertex-index +* from `points`, target-vertex.} +* \cgalParamType{a class model of `OutputIterator` accepting +* `std::pair<`int`, `boost::graph_traits::%vertex_descriptor>`} +* \cgalParamDefault{`Emptyset_iterator`} +* \cgalParamNEnd +* +* \cgalParamNBegin{polygon_to_face_output_iterator} +* \cgalParamDescription{an `OutputIterator` containing the pairs polygon-index +* from `polygons`, target-face.} +* \cgalParamType{a class model of `OutputIterator` accepting +* `std::pair<`int`, `boost::graph_traits::%face_descriptor>`} +* \cgalParamDefault{`Emptyset_iterator`} +* \cgalParamNEnd +* * \cgalNamedParamsEnd * * @param np_pm an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below @@ -290,7 +314,11 @@ void polygon_soup_to_polygon_mesh(const PointRange& points, get_property_map(CGAL::vertex_point, out)); internal::PS_to_PM_converter converter(points, polygons, pm); - converter(out, vpm); + converter(out, vpm, + choose_parameter(get_parameter(np_ps, internal_np::point_to_vertex_output_iterator), + impl::make_functor(get_parameter(np_ps, internal_np::vertex_to_vertex_map))), + choose_parameter(get_parameter(np_ps, internal_np::polygon_to_face_output_iterator), + impl::make_functor(get_parameter(np_ps, internal_np::face_to_face_map)))); } /// \cond SKIP_IN_MANUAL diff --git a/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp b/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp index a9a3626d544..34c59df579c 100644 --- a/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp @@ -1168,9 +1168,16 @@ double Scene_c3t3_item_priv::complex_diag() const { void Scene_c3t3_item::export_facets_in_complex() { SMesh outmesh; - CGAL::facets_in_complex_3_to_triangle_mesh(c3t3(), outmesh); + + boost::property_map >::type + fpmap = get(CGAL::face_patch_id_t(), outmesh); + + CGAL::facets_in_complex_3_to_triangle_mesh(c3t3(), outmesh, + CGAL::parameters::face_patch_map(fpmap)); + Scene_surface_mesh_item* item = new Scene_surface_mesh_item(std::move(outmesh)); item->setName(QString("%1_%2").arg(this->name()).arg("facets")); + item->setItemIsMulticolor(true); scene->addItem(item); this->setVisible(false); } From f12eadf49fdb7b2388504efd517eae40478088a7 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 18 May 2021 14:39:12 +0200 Subject: [PATCH 45/79] Fix the link to the user manual --- MDS_3/doc/MDS_3/MDS_3.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MDS_3/doc/MDS_3/MDS_3.txt b/MDS_3/doc/MDS_3/MDS_3.txt index cbd506981c1..c43160517c5 100644 --- a/MDS_3/doc/MDS_3/MDS_3.txt +++ b/MDS_3/doc/MDS_3/MDS_3.txt @@ -2,7 +2,7 @@ namespace CGAL { /*! \mainpage User Manual -\anchor Chapter_3D_Mesh_Data_Structure +\anchor Chapter_3D_Mesh_Data_Structures \anchor userchaptermds3 \authors Pierre Alliez, Clément Jamin, Laurent Rineau, Stéphane Tayeb, Jane Tournois, Mariette Yvinec \cgalAutoToc From 5deaccec09e78d7a0abea318734988580e3fc3d3 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 18 May 2021 15:59:30 +0200 Subject: [PATCH 46/79] Fix warnings about unused parameter names --- MDS_3/examples/MDS_3/tetrahedron_soup_to_c3t3_example.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MDS_3/examples/MDS_3/tetrahedron_soup_to_c3t3_example.cpp b/MDS_3/examples/MDS_3/tetrahedron_soup_to_c3t3_example.cpp index 58d4f2cff3e..c5fe669cd05 100644 --- a/MDS_3/examples/MDS_3/tetrahedron_soup_to_c3t3_example.cpp +++ b/MDS_3/examples/MDS_3/tetrahedron_soup_to_c3t3_example.cpp @@ -20,7 +20,7 @@ typedef K::Point_3 Point_3; typedef K::Tetrahedron_3 Tetrahedron_3; typedef DT3::Vertex_handle Vertex_handle; -int main(int argc, char* argv[]) +int main(int , char* []) { const int nbv = 100; From be5170a9c2d7b32aaf15323ce886960bfa1fa134 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 18 May 2021 16:26:32 +0200 Subject: [PATCH 47/79] update license headers using cmake -P generate_files.cmake --- Installation/include/CGAL/license/MDS_3.h | 5 ++--- Installation/include/CGAL/license/Orthtree.h | 8 ++++---- .../include/CGAL/license/Triangulation_on_sphere_2.h | 8 ++++---- Installation/include/CGAL/license/gpl_package_list.txt | 1 + 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Installation/include/CGAL/license/MDS_3.h b/Installation/include/CGAL/license/MDS_3.h index 41a1e9194f5..e3f38693334 100644 --- a/Installation/include/CGAL/license/MDS_3.h +++ b/Installation/include/CGAL/license/MDS_3.h @@ -38,9 +38,8 @@ #else // no CGAL_MDS_3_COMMERCIAL_LICENSE # if defined(CGAL_LICENSE_WARNING) - CGAL_pragma_warning("\nThe macro CGAL_MDS_3_COMMERCIAL_LICENSE " - "is not defined." - "\nYou use the CGAL 3D Mesh Generation package under " + CGAL_pragma_warning("\nThe macro CGAL_MDS_3_COMMERCIAL_LICENSE is not defined." + "\nYou use the CGAL 3D Mesh Data Structure package under " "the terms of the GPLv3+.") # endif // CGAL_LICENSE_WARNING diff --git a/Installation/include/CGAL/license/Orthtree.h b/Installation/include/CGAL/license/Orthtree.h index 9437a3ed4a4..8225e047ec3 100644 --- a/Installation/include/CGAL/license/Orthtree.h +++ b/Installation/include/CGAL/license/Orthtree.h @@ -24,12 +24,12 @@ # if defined(CGAL_LICENSE_WARNING) CGAL_pragma_warning("Your commercial license for CGAL does not cover " - "this release of the package.") + "this release of the Quadtrees, Octrees, and Orthrees package.") # endif # ifdef CGAL_LICENSE_ERROR # error "Your commercial license for CGAL does not cover this release \ - of the package. \ + of the Quadtrees, Octrees, and Orthrees package. \ You get this error, as you defined CGAL_LICENSE_ERROR." # endif // CGAL_LICENSE_ERROR @@ -39,13 +39,13 @@ # if defined(CGAL_LICENSE_WARNING) CGAL_pragma_warning("\nThe macro CGAL_ORTHTREE_COMMERCIAL_LICENSE is not defined." - "\nYou use the CGAL package under " + "\nYou use the CGAL Quadtrees, Octrees, and Orthrees package under " "the terms of the GPLv3+.") # endif // CGAL_LICENSE_WARNING # ifdef CGAL_LICENSE_ERROR # error "The macro CGAL_ORTHTREE_COMMERCIAL_LICENSE is not defined.\ - You use the CGAL package under the terms of \ + You use the CGAL Quadtrees, Octrees, and Orthrees package under the terms of \ the GPLv3+. You get this error, as you defined CGAL_LICENSE_ERROR." # endif // CGAL_LICENSE_ERROR diff --git a/Installation/include/CGAL/license/Triangulation_on_sphere_2.h b/Installation/include/CGAL/license/Triangulation_on_sphere_2.h index 5ec1bf7e76d..6e3447d7ae7 100644 --- a/Installation/include/CGAL/license/Triangulation_on_sphere_2.h +++ b/Installation/include/CGAL/license/Triangulation_on_sphere_2.h @@ -24,12 +24,12 @@ # if defined(CGAL_LICENSE_WARNING) CGAL_pragma_warning("Your commercial license for CGAL does not cover " - "this release of the 2D Triangulations on Sphere package.") + "this release of the 2D Triangulation on Sphere package.") # endif # ifdef CGAL_LICENSE_ERROR # error "Your commercial license for CGAL does not cover this release \ - of the 2D Triangulations on Sphere package. \ + of the 2D Triangulation on Sphere package. \ You get this error, as you defined CGAL_LICENSE_ERROR." # endif // CGAL_LICENSE_ERROR @@ -39,13 +39,13 @@ # if defined(CGAL_LICENSE_WARNING) CGAL_pragma_warning("\nThe macro CGAL_TRIANGULATION_ON_SPHERE_2_COMMERCIAL_LICENSE is not defined." - "\nYou use the CGAL 2D Triangulations on Sphere package under " + "\nYou use the CGAL 2D Triangulation on Sphere package under " "the terms of the GPLv3+.") # endif // CGAL_LICENSE_WARNING # ifdef CGAL_LICENSE_ERROR # error "The macro CGAL_TRIANGULATION_ON_SPHERE_2_COMMERCIAL_LICENSE is not defined.\ - You use the CGAL 2D Triangulations on Sphere package under the terms of \ + You use the CGAL 2D Triangulation on Sphere package under the terms of \ the GPLv3+. You get this error, as you defined CGAL_LICENSE_ERROR." # endif // CGAL_LICENSE_ERROR diff --git a/Installation/include/CGAL/license/gpl_package_list.txt b/Installation/include/CGAL/license/gpl_package_list.txt index 787702b4163..644258ed99c 100644 --- a/Installation/include/CGAL/license/gpl_package_list.txt +++ b/Installation/include/CGAL/license/gpl_package_list.txt @@ -27,6 +27,7 @@ Jet_fitting_3 Estimation of Local Differential Properties of Point-Sampled Surfa Matrix_search Monotone and Sorted Matrix Search Mesh_2 2D Conforming Triangulations and Meshes Mesh_3 3D Mesh Generation +MDS_3 3D Mesh Data Structure Minkowski_sum_2 2D Minkowski Sums Minkowski_sum_3 3D Minkowski Sum of Polyhedra Nef_2 2D Boolean Operations on Nef Polygons From 37d1f118dabaf3c94ed0ce714350ffb045e6fd31 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 18 May 2021 16:26:54 +0200 Subject: [PATCH 48/79] Add a link to the section in MDS_3 --- Mesh_3/doc/Mesh_3/PackageDescription.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Mesh_3/doc/Mesh_3/PackageDescription.txt b/Mesh_3/doc/Mesh_3/PackageDescription.txt index 4947d2a4fce..531a313bd0c 100644 --- a/Mesh_3/doc/Mesh_3/PackageDescription.txt +++ b/Mesh_3/doc/Mesh_3/PackageDescription.txt @@ -29,7 +29,7 @@ /// \defgroup PkgMesh3IOFunctions Input/Output Functions /// \ingroup PkgMesh3Ref -/// The free functions that can be used to read and write meshes. +/// See \ref PkgMDS3IOFunctions from 3D Mesh Data Structures. /*! \addtogroup PkgMesh3Ref @@ -134,4 +134,3 @@ and their associated classes: - `CGAL::Mesh_facet_topology` */ - From 0fb97a308e435e729991c374b12319d30a094c98 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 18 May 2021 16:30:20 +0200 Subject: [PATCH 49/79] update license --- MDS_3/include/CGAL/IO/File_maya.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MDS_3/include/CGAL/IO/File_maya.h b/MDS_3/include/CGAL/IO/File_maya.h index c482186b386..5b3d3bd1922 100644 --- a/MDS_3/include/CGAL/IO/File_maya.h +++ b/MDS_3/include/CGAL/IO/File_maya.h @@ -12,7 +12,7 @@ #ifndef CGAL_IO_FILE_MAYA_H #define CGAL_IO_FILE_MAYA_H -#include +#include #include #include From fc285d9d8f8d684ac46c23b3874c42b4f51a6272 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 18 May 2021 16:32:42 +0200 Subject: [PATCH 50/79] update CMakeLists.txt --- MDS_3/examples/MDS_3/CMakeLists.txt | 7 +------ MDS_3/test/MDS_3/CMakeLists.txt | 11 +---------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/MDS_3/examples/MDS_3/CMakeLists.txt b/MDS_3/examples/MDS_3/CMakeLists.txt index f7f51e3372b..2093c8a33df 100644 --- a/MDS_3/examples/MDS_3/CMakeLists.txt +++ b/MDS_3/examples/MDS_3/CMakeLists.txt @@ -1,7 +1,7 @@ # Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. -cmake_minimum_required(VERSION 3.1...3.14) +cmake_minimum_required(VERSION 3.1...3.20) project(MDS_3_Examples) @@ -10,11 +10,6 @@ find_package(CGAL REQUIRED) # Boost and its components find_package(Boost REQUIRED) -if(NOT Boost_FOUND) - message( - STATUS "This project requires the Boost library, and will not be compiled.") - return() -endif() # Creating entries for all C++ files with "main" routine # ########################################################## diff --git a/MDS_3/test/MDS_3/CMakeLists.txt b/MDS_3/test/MDS_3/CMakeLists.txt index 697236746d3..328fb8d86ed 100644 --- a/MDS_3/test/MDS_3/CMakeLists.txt +++ b/MDS_3/test/MDS_3/CMakeLists.txt @@ -1,22 +1,13 @@ # Created by the script cgal_create_cmake_script # This is the CMake script for compiling a CGAL application. -cmake_minimum_required(VERSION 3.1...3.15) +cmake_minimum_required(VERSION 3.1...3.20) project( MDS_3_Tests ) -if(POLICY CMP0074) - cmake_policy(SET CMP0074 NEW) -endif() - find_package(CGAL REQUIRED) # Use Eigen find_package(Eigen3 3.1.0 REQUIRED) #(3.1.0 or greater) -include(CGAL_Eigen3_support) -if (NOT TARGET CGAL::Eigen3_support) - message(STATUS "This project requires the Eigen library, and will not be compiled.") - return() -endif() create_single_source_cgal_program( "test_c3t3.cpp" ) create_single_source_cgal_program( "test_c3t3_io.cpp" ) From b58fd149a2256c0ef1fce6342299d541e831ca6b Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 18 May 2021 16:34:49 +0200 Subject: [PATCH 51/79] remove unused include --- MDS_3/examples/MDS_3/c3t3_example.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/MDS_3/examples/MDS_3/c3t3_example.cpp b/MDS_3/examples/MDS_3/c3t3_example.cpp index 22f8e650506..286b4749bef 100644 --- a/MDS_3/examples/MDS_3/c3t3_example.cpp +++ b/MDS_3/examples/MDS_3/c3t3_example.cpp @@ -5,7 +5,6 @@ #include #include -#include #include From 57f7c141ac159f15e59794ce0f4453fe94c95304 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 18 May 2021 16:35:34 +0200 Subject: [PATCH 52/79] add comment to improve example --- MDS_3/examples/MDS_3/c3t3_example.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/MDS_3/examples/MDS_3/c3t3_example.cpp b/MDS_3/examples/MDS_3/c3t3_example.cpp index 286b4749bef..946674ba5ae 100644 --- a/MDS_3/examples/MDS_3/c3t3_example.cpp +++ b/MDS_3/examples/MDS_3/c3t3_example.cpp @@ -21,6 +21,7 @@ int main(int argc, char* argv[]) std::ifstream is(filename, std::ios_base::in); CGAL::read_MEDIT(is, tr); + // [call to a remeshing algorithm] std::ofstream os("after_remeshing.mesh"); CGAL::write_MEDIT(os, tr); From 5f861e6fd0da0b1f466f3a3a5389280b2ead9063 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 18 May 2021 16:37:47 +0200 Subject: [PATCH 53/79] remove unrelated documentation --- MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h b/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h index 17229b2932c..dc78e68262f 100644 --- a/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h +++ b/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h @@ -119,8 +119,6 @@ namespace CGAL { * whose key type is model of `RandomAccessContainer` * and mapped type is `Tr::Cell::Surface_patch_index`} * \cgalParamDefault{An empty `std::map, typename Tr::Cell::Surface_patch_index>`} - * \cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t` - * must be available in `PolygonMesh`.} * \cgalParamNEnd * \cgalNamedParamsEnd * From 3cd23ca0cc77322375f2621ad2afb020b3846745 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 18 May 2021 16:39:25 +0200 Subject: [PATCH 54/79] hide dependencies from documentation --- MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 4a0e668f10a..155d3307b6b 100644 --- a/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -158,9 +158,11 @@ namespace CGAL { template -class Mesh_complex_3_in_triangulation_3 : - public CGAL::MDS_3::details::C3t3_helper_class +class Mesh_complex_3_in_triangulation_3 +#ifndef DOXYGEN_RUNNING + : public CGAL::MDS_3::details::C3t3_helper_class , public CGAL::MDS_3::internal::Debug_messages_tools +#endif { public: typedef typename Tr::Concurrency_tag Concurrency_tag; From 38561b78c48338e3a33b09c73f6581af6ad96ed5 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 18 May 2021 16:48:11 +0200 Subject: [PATCH 55/79] fix make_mesh_3 and refine_mesh_3 documentation --- Mesh_3/doc/Mesh_3/CGAL/make_mesh_3.h | 5 ++++- Mesh_3/doc/Mesh_3/CGAL/refine_mesh_3.h | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Mesh_3/doc/Mesh_3/CGAL/make_mesh_3.h b/Mesh_3/doc/Mesh_3/CGAL/make_mesh_3.h index 08bd5ee1761..312b556343f 100644 --- a/Mesh_3/doc/Mesh_3/CGAL/make_mesh_3.h +++ b/Mesh_3/doc/Mesh_3/CGAL/make_mesh_3.h @@ -33,7 +33,10 @@ traverse the resulting mesh data structure or can be written to a file \tparam C3T3 is required to be a model of -the concept `MeshComplex_3InTriangulation_3`. This is the return type. +the concept `MeshComplex_3InTriangulation_3`, +and a model of `MeshComplexWithFeatures_3InTriangulation_3` +if the domain is a model of `MeshDomainWithFeatures_3`. +This is the return type. The type `C3T3` is in particular required to provide a nested type `C3T3::Triangulation` for the 3D triangulation embedding the mesh. The vertex and cell base classes of the diff --git a/Mesh_3/doc/Mesh_3/CGAL/refine_mesh_3.h b/Mesh_3/doc/Mesh_3/CGAL/refine_mesh_3.h index 25ddc7311ed..afeebe8c634 100644 --- a/Mesh_3/doc/Mesh_3/CGAL/refine_mesh_3.h +++ b/Mesh_3/doc/Mesh_3/CGAL/refine_mesh_3.h @@ -39,7 +39,9 @@ not change from one refinement to the next one. \tparam C3T3 is required to be a model of the concept -`MeshComplex_3InTriangulation_3`. +`MeshComplex_3InTriangulation_3`, +and a model of `MeshComplexWithFeatures_3InTriangulation_3` +if the domain is a model of `MeshDomainWithFeatures_3`. The argument `c3t3` is passed by reference as this object is modified by the refinement process. As the refinement process only adds points to the triangulation, all From 365d2f7b691c60d47176c5b05c80fa7722d5a11b Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 25 May 2021 14:11:45 +0200 Subject: [PATCH 56/79] make functions generic and test it with new data types --- .../tetrahedron_soup_to_c3t3_example.cpp | 12 ++--- MDS_3/include/CGAL/IO/File_medit.h | 2 +- MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h | 44 ++++++++++++------- .../tetrahedron_soup_to_triangulation_3.h | 2 +- 4 files changed, 37 insertions(+), 23 deletions(-) diff --git a/MDS_3/examples/MDS_3/tetrahedron_soup_to_c3t3_example.cpp b/MDS_3/examples/MDS_3/tetrahedron_soup_to_c3t3_example.cpp index c5fe669cd05..09a9c0235d7 100644 --- a/MDS_3/examples/MDS_3/tetrahedron_soup_to_c3t3_example.cpp +++ b/MDS_3/examples/MDS_3/tetrahedron_soup_to_c3t3_example.cpp @@ -7,8 +7,8 @@ #include -#include -#include +#include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel K; @@ -26,10 +26,10 @@ int main(int , char* []) //a triangulation DT3 delaunay; - std::map v2i; - std::vector points(nbv); - std::vector tetrahedra; - std::vector > tets_by_indices; + boost::unordered_map v2i; + boost::container::vector points(nbv); + boost::container::vector tetrahedra; + boost::container::vector > tets_by_indices; //insert random points CGAL::Random_points_in_cube_3 randp(2.); diff --git a/MDS_3/include/CGAL/IO/File_medit.h b/MDS_3/include/CGAL/IO/File_medit.h index 7754ad86a04..c45dc9a02de 100644 --- a/MDS_3/include/CGAL/IO/File_medit.h +++ b/MDS_3/include/CGAL/IO/File_medit.h @@ -16,7 +16,7 @@ #include -#include +#include #include #include diff --git a/MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h b/MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h index 4426770bf3d..b73fd37c37c 100644 --- a/MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h +++ b/MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h @@ -44,9 +44,9 @@ std::array make_ordered_vertex_array(const Vh vh0, const Vh vh1, const Vh return ft; } -template +template void build_vertices(Tr& tr, - const std::vector& points, + const PointRange& points, std::vector& vertex_handle_vector) { typedef typename Tr::Vertex_handle Vertex_handle; @@ -100,15 +100,15 @@ bool add_facet_to_incident_cells_map(const typename Tr::Cell_handle c, int i, return true; } -template +template bool build_finite_cells(Tr& tr, - const std::vector >& finite_cells, + const CellRange& finite_cells, const std::vector& vertex_handle_vector, boost::unordered_map, std::vector > >& incident_cells_map, - const std::map, typename Tr::Cell::Surface_patch_index>& border_facets, + const FacetPatchMap& border_facets, const bool verbose, - bool replace_domain_0 = false) + bool replace_domain_0 = false) { typedef std::array Tet_with_ref; // 4 ids + 1 reference @@ -338,11 +338,17 @@ bool assign_neighbors(Tr& tr, return true; } -template +template bool build_triangulation(Tr& tr, - const std::vector& points, - const std::vector >& finite_cells, - const std::map, typename Tr::Cell::Surface_patch_index>& border_facets, + const PointRange& points, + const CellRange& finite_cells, + const FacetPatchMap& border_facets, +// const std::vector& points, +// const std::vector >& finite_cells, +// const std::map, typename Tr::Cell::Surface_patch_index>& border_facets, std::vector& vertex_handle_vector, const bool verbose = false, bool replace_domain_0 = false) @@ -396,14 +402,22 @@ bool build_triangulation(Tr& tr, return tr.tds().is_valid(); } -template +template bool build_triangulation(Tr& tr, - const std::vector& points, - const std::vector >& finite_cells, - const std::map, typename Tr::Cell::Surface_patch_index>& border_facets, + const PointRange& points, + const CellRange& finite_cells, + const FacetPatchMap& border_facets, const bool verbose = false, bool replace_domain_0 = false) +// const std::vector& points, //PointRange +// const std::vector >& finite_cells, //CellRange +// const std::map, typename Tr::Cell::Surface_patch_index>& border_facets,//FacetsMap { + BOOST_STATIC_ASSERT(boost::is_same::value); std::vector vertex_handle_vector; return build_triangulation(tr, points, finite_cells, border_facets, @@ -510,7 +524,7 @@ template bool build_triangulation_from_file(std::istream& is, Tr& tr) { - return build_triangulation_from_file(is, tr, false); + return build_triangulation_from_file(is, tr, false); } } // namespace MDS_3 } // namespace CGAL diff --git a/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h b/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h index dc78e68262f..ca6262fcc12 100644 --- a/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h +++ b/MDS_3/include/CGAL/tetrahedron_soup_to_triangulation_3.h @@ -116,7 +116,7 @@ namespace CGAL { * \cgalParamDescription{each element in the range describes a surface facet using the indices of points * in `points` (indices 0 to 2), and the associated `Surface_patch_index` (index 3)} * \cgalParamType{a class model of `AssociativeContainer` - * whose key type is model of `RandomAccessContainer` + * whose key type is model of `RandomAccessContainer` containing `int` * and mapped type is `Tr::Cell::Surface_patch_index`} * \cgalParamDefault{An empty `std::map, typename Tr::Cell::Surface_patch_index>`} * \cgalParamNEnd From f7a08e08a2b97a718f26d3bba3a6b8b8677b4c85 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 28 May 2021 15:27:10 +0200 Subject: [PATCH 57/79] remove unnecessary code --- MDS_3/include/CGAL/IO/File_avizo.h | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/MDS_3/include/CGAL/IO/File_avizo.h b/MDS_3/include/CGAL/IO/File_avizo.h index 20826b2e884..f2b31d68d6c 100644 --- a/MDS_3/include/CGAL/IO/File_avizo.h +++ b/MDS_3/include/CGAL/IO/File_avizo.h @@ -144,28 +144,10 @@ output_to_avizo(std::ostream& os, } // end namespace IO - #ifndef CGAL_NO_DEPRECATED_CODE using IO::output_to_avizo; #endif - - -/** - * \ingroup PkgMDS3IOFunctions - * @brief outputs mesh to avizo format - * @param os the stream - * @param c3t3 the mesh complex - * \see \ref IOStreamAvizo - */ -template -void -output_to_avizo(std::ostream& os, - const C3T3& c3t3) -{ - MDS_3::output_to_avizo(os,c3t3); -} - } // end namespace CGAL #endif // CGAL_IO_FILE_AVIZO_H From 6ee620f7f5bbb4d24b752547f458c7a131ee1ee4 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 18 May 2021 10:22:51 +0200 Subject: [PATCH 58/79] wip : transfer surface patch indices from c3t3 to Surface_mesh in export_facets_in_complex() --- ...ndary_of_subdomain_of_complex_3_in_triangulation_3_to_off.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MDS_3/include/CGAL/internal/MDS_3/Boundary_of_subdomain_of_complex_3_in_triangulation_3_to_off.h b/MDS_3/include/CGAL/internal/MDS_3/Boundary_of_subdomain_of_complex_3_in_triangulation_3_to_off.h index 8870f114025..22ad3eaffd7 100644 --- a/MDS_3/include/CGAL/internal/MDS_3/Boundary_of_subdomain_of_complex_3_in_triangulation_3_to_off.h +++ b/MDS_3/include/CGAL/internal/MDS_3/Boundary_of_subdomain_of_complex_3_in_triangulation_3_to_off.h @@ -81,8 +81,9 @@ output_facets_in_complex_to_off(const C3T3& c3t3, std::vector points; std::vector faces; + std::vector patches; - CGAL::MDS_3::internal::facets_in_complex_3_to_triangle_soup(c3t3, points, faces); + CGAL::MDS_3::internal::facets_in_complex_3_to_triangle_soup(c3t3, points, faces, patches); return output_polygon_soup_to_off(points, faces, out); } From c4c68ab9f7da942fb0af53a6933c51ee14fcca94 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 28 May 2021 17:23:12 +0200 Subject: [PATCH 59/79] make IO namespaces consistent with master --- .../IO/facets_in_complex_3_to_triangle_mesh.h | 234 +----------------- .../facets_in_complex_3_to_triangle_mesh.h | 167 +++++++++---- 2 files changed, 118 insertions(+), 283 deletions(-) diff --git a/MDS_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h b/MDS_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h index 78c6813efcd..4ac835a78d0 100644 --- a/MDS_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h +++ b/MDS_3/include/CGAL/IO/facets_in_complex_3_to_triangle_mesh.h @@ -16,240 +16,12 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include +#ifndef CGAL_NO_DEPRECATED_CODE +#include #define CGAL_DEPRECATED_HEADER "" #define CGAL_REPLACEMENT_HEADER "" #include #endif -#include -#include -#include -#include - -namespace CGAL { - -namespace MDS_3 { - -namespace internal { - -template -void resize(Polygon& p, std::size_t size) -{ - p.resize(size); -} - -template -void resize(std::array&, std::size_t CGAL_assertion_code(size)) -{ - CGAL_assertion(size == N); -} - -template -void facets_in_complex_3_to_triangle_soup(const C3T3& c3t3, - const typename C3T3::Subdomain_index sd_index, - PointContainer& points, - FaceContainer& faces, - PatchIndexContainer& patches, - const bool normals_point_outside_of_the_subdomain = true, - const bool export_all_facets = false) -{ - typedef typename PointContainer::value_type Point_3; - typedef typename FaceContainer::value_type Face; - - typedef typename C3T3::Triangulation Tr; - typedef typename C3T3::Surface_patch_index Surface_patch_index; - - typedef typename Tr::Vertex_handle Vertex_handle; - typedef typename Tr::Cell_handle Cell_handle; - typedef typename Tr::Weighted_point Weighted_point; - - typedef typename C3T3::Facets_in_complex_iterator Ficit; - - typedef CGAL::Hash_handles_with_or_without_timestamps Hash_fct; - typedef boost::unordered_map VHmap; - - typedef typename C3T3::size_type size_type; - - size_type nf = c3t3.number_of_facets_in_complex(); - faces.reserve(faces.size() + nf); - patches.reserve(faces.size() + nf); - points.reserve(points.size() + nf/2); // approximating Euler - - VHmap vh_to_ids; - std::size_t inum = 0; - - for(Ficit fit = c3t3.facets_in_complex_begin(), - end = c3t3.facets_in_complex_end(); fit != end; ++fit) - { - Cell_handle c = fit->first; - int s = fit->second; - const Surface_patch_index spi = c->surface_patch_index(s); - Face f; - resize(f, 3); - - typename C3T3::Subdomain_index cell_sdi = c3t3.subdomain_index(c); - typename C3T3::Subdomain_index opp_sdi = c3t3.subdomain_index(c->neighbor(s)); - - if(!export_all_facets && cell_sdi != sd_index && opp_sdi != sd_index) - continue; - - for(std::size_t i=1; i<4; ++i) - { - typename VHmap::iterator map_entry; - bool is_new; - Vertex_handle v = c->vertex((s+i)&3); - CGAL_assertion(v != Vertex_handle() && !c3t3.triangulation().is_infinite(v)); - - boost::tie(map_entry, is_new) = vh_to_ids.insert(std::make_pair(v, inum)); - if(is_new) - { - const Weighted_point& p = c3t3.triangulation().point(c, (s+i)&3); - const Point_3 bp = Point_3(CGAL::to_double(p.x()), - CGAL::to_double(p.y()), - CGAL::to_double(p.z())); - points.push_back(bp); - ++inum; - } - - f[i-1] = map_entry->second; - } - - if(export_all_facets) - { - if((cell_sdi > opp_sdi) == (s%2 == 1)) - std::swap(f[0], f[1]); - } - else - { - if(((cell_sdi == sd_index) == (s%2 == 1)) == normals_point_outside_of_the_subdomain) - std::swap(f[0], f[1]); - } - - faces.push_back(f); - patches.push_back(spi); - } -} - -template -void facets_in_complex_3_to_triangle_soup(const C3T3& c3t3, - PointContainer& points, - FaceContainer& faces, - SurfacePatchContainer& patches) -{ - typedef typename C3T3::Subdomain_index Subdomain_index; - Subdomain_index useless = Subdomain_index(); - facets_in_complex_3_to_triangle_soup(c3t3, useless, points, faces, patches, - true/*point outward*/, true /*extract all facets*/); -} - -template -void set_face_patches(const Index2FaceMap&, - const SurfacePatchRange&, - internal_np::Param_not_found&) -{ - return; -} -template -void set_face_patches(const Index2FaceMap&, - const SurfacePatchRange&, - internal_np::No_property&) -{ - return; -} - -template -void set_face_patches(const Index2FaceMap& i2f, - const SurfacePatchRange& patches, - FacePatchMap& fpmap) -{ - for (auto index_and_face : i2f) - { - put(fpmap, index_and_face.second, patches[index_and_face.first]); - } -} - -} // end namespace internal - -} // end namespace Mesh_3 - -/** - * @ingroup PkgMDS3Functions - * - * @brief builds a `TriangleMesh` from the surface facets, with a consistent orientation at the interface of two subdomains. - * - * This function exports the surface as a `TriangleMesh` and appends it to `graph`, using `orient_polygon_soup()`. - * - * @tparam C3T3 a model of `MeshComplexWithFeatures_3InTriangulation_3`. - * @tparam TriangleMesh a model of `MutableFaceGraph` with an internal point property map. The point type should be compatible with the one used in `C3T3`. - * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" - * - * @param c3t3 an instance of `C3T3`. - * @param graph an instance of `TriangleMesh`. - * @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below - * - * \cgalNamedParamsBegin - * \cgalParamNBegin{face_patch_map} -* \cgalParamDescription{a property map with the patch id's associated to the faces of `faces(graph)`} -* \cgalParamType{a class model of `ReadWritePropertyMap` with `boost::graph_traits::%face_descriptor` -* as key type and the desired property, model of `CopyConstructible` and `LessThanComparable` as value type.} -* \cgalParamDefault{If not provided, faces patch ids are ignored.} -* \cgalParamExtra{The map is updated during the remeshing process while new faces are created.} -* \cgalParamNEnd -* \cgalNamedParamsEnd -*/ -template -void facets_in_complex_3_to_triangle_mesh(const C3T3& c3t3, - TriangleMesh& graph, - const NamedParameters& np) -{ - namespace PMP = CGAL::Polygon_mesh_processing; - - typedef typename boost::property_map::type VertexPointMap; - typedef typename boost::property_traits::value_type Point_3; - typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef typename C3T3::Surface_patch_index Surface_patch_index; - - typedef std::array Face; - - std::vector faces; - std::vector patches; - std::vector points; - - MDS_3::internal::facets_in_complex_3_to_triangle_soup(c3t3, points, faces, patches); - - if(!PMP::is_polygon_soup_a_polygon_mesh(faces)) - PMP::orient_polygon_soup(points, faces); - CGAL_postcondition(PMP::is_polygon_soup_a_polygon_mesh(faces)); - - boost::unordered_map i2f; - PMP::polygon_soup_to_polygon_mesh(points, faces, graph, - CGAL::parameters::polygon_to_face_output_iterator(std::inserter(i2f, i2f.end()))); - - using parameters::choose_parameter; - using parameters::get_parameter; - - MDS_3::internal::set_face_patches(i2f, - patches, - get_parameter(np, internal_np::face_patch)); -} - -template -void facets_in_complex_3_to_triangle_mesh(const C3T3& c3t3, TriangleMesh& graph) -{ - facets_in_complex_3_to_triangle_mesh(c3t3, graph, parameters::all_default()); -} - -} // namespace CGAL - -#endif // CGAL_FACETS_IN_COMPLEX_3_TO_TRIANGLE_MESH_H +#endif // CGAL_IO_FACETS_IN_COMPLEX_3_TO_TRIANGLE_MESH_H diff --git a/MDS_3/include/CGAL/facets_in_complex_3_to_triangle_mesh.h b/MDS_3/include/CGAL/facets_in_complex_3_to_triangle_mesh.h index 7a0b6ae5519..5fbb4f2c04e 100644 --- a/MDS_3/include/CGAL/facets_in_complex_3_to_triangle_mesh.h +++ b/MDS_3/include/CGAL/facets_in_complex_3_to_triangle_mesh.h @@ -14,16 +14,18 @@ #ifndef CGAL_FACETS_IN_COMPLEX_3_TO_TRIANGLE_MESH_H #define CGAL_FACETS_IN_COMPLEX_3_TO_TRIANGLE_MESH_H -#include +#include #include #include #include #include +#include +#include #include +#include #include -#include #include #include @@ -48,12 +50,12 @@ void resize(std::array&, std::size_t CGAL_assertion_code(size)) CGAL_assertion(size == N); } -template +template void facets_in_complex_3_to_triangle_soup(const C3T3& c3t3, const typename C3T3::Subdomain_index sd_index, PointContainer& points, FaceContainer& faces, - SurfacePatchContainer& surface_patches, + PatchIndexContainer& patches, const bool normals_point_outside_of_the_subdomain = true, const bool export_all_facets = false) { @@ -61,6 +63,7 @@ void facets_in_complex_3_to_triangle_soup(const C3T3& c3t3, typedef typename FaceContainer::value_type Face; typedef typename C3T3::Triangulation Tr; + typedef typename C3T3::Surface_patch_index Surface_patch_index; typedef typename Tr::Vertex_handle Vertex_handle; typedef typename Tr::Cell_handle Cell_handle; @@ -75,6 +78,7 @@ void facets_in_complex_3_to_triangle_soup(const C3T3& c3t3, size_type nf = c3t3.number_of_facets_in_complex(); faces.reserve(faces.size() + nf); + patches.reserve(faces.size() + nf); points.reserve(points.size() + nf/2); // approximating Euler VHmap vh_to_ids; @@ -85,6 +89,7 @@ void facets_in_complex_3_to_triangle_soup(const C3T3& c3t3, { Cell_handle c = fit->first; int s = fit->second; + const Surface_patch_index spi = c->surface_patch_index(s); Face f; resize(f, 3); @@ -110,80 +115,138 @@ void facets_in_complex_3_to_triangle_soup(const C3T3& c3t3, CGAL::to_double(p.z())); points.push_back(bp); ++inum; + + f[i - 1] = map_entry->second; } - f[i-1] = map_entry->second; - } + if (export_all_facets) + { + if ((cell_sdi > opp_sdi) == (s % 2 == 1)) + std::swap(f[0], f[1]); + } + else + { + if (((cell_sdi == sd_index) == (s % 2 == 1)) == normals_point_outside_of_the_subdomain) + std::swap(f[0], f[1]); + } - if(export_all_facets) - { - if((cell_sdi > opp_sdi) == (s%2 == 1)) - std::swap(f[0], f[1]); + faces.push_back(f); + patches.push_back(spi); } - else - { - if(((cell_sdi == sd_index) == (s%2 == 1)) == normals_point_outside_of_the_subdomain) - std::swap(f[0], f[1]); - } - - faces.push_back(f); - surface_patches.push_back(c3t3.surface_patch_index(c, s)); } } -template +template void facets_in_complex_3_to_triangle_soup(const C3T3& c3t3, PointContainer& points, - FaceContainer& faces) + FaceContainer& faces, + SurfacePatchContainer& patches) { typedef typename C3T3::Subdomain_index Subdomain_index; - typedef typename C3T3::Surface_patch_index Surface_patch_index; - Subdomain_index useless = Subdomain_index(); - std::vector patches; facets_in_complex_3_to_triangle_soup(c3t3, useless, points, faces, patches, true/*point outward*/, true /*extract all facets*/); } +template +void set_face_patches(const Index2FaceMap&, + const SurfacePatchRange&, + internal_np::Param_not_found&) +{ + return; +} + +template +void set_face_patches(const Index2FaceMap&, + const SurfacePatchRange&, + internal_np::No_property&) +{ + return; +} + +template +void set_face_patches(const Index2FaceMap& i2f, + const SurfacePatchRange& patches, + FacePatchMap& fpmap) +{ + for (auto index_and_face : i2f) + { + put(fpmap, index_and_face.second, patches[index_and_face.first]); + } +} + } // end namespace internal } // end namespace MDS_3 -//! \ingroup PkgMesh3Functions -//! -//! \brief builds a `TriangleMesh` from the surface facets, with a consistent orientation -//! at the interface of two subdomains. -//! -//! This function exports the surface as a `TriangleMesh` and appends it to `graph`, using -//! `orient_polygon_soup()`. -//! -//! @tparam C3T3 a model of `MeshComplexWithFeatures_3InTriangulation_3`. -//! @tparam TriangleMesh a model of `MutableFaceGraph` with an internal point property map. -//! The point type should be compatible with the one used in `C3T3`. -//! -//! @param c3t3 an instance of `C3T3`. -//! @param graph an instance of `TriangleMesh`. -template -void facets_in_complex_3_to_triangle_mesh(const C3T3& c3t3, TriangleMesh& graph) -{ - namespace PMP = CGAL::Polygon_mesh_processing; + /** + * @ingroup PkgMDS3Functions + * + * @brief builds a `TriangleMesh` from the surface facets, with a consistent orientation at the interface of two subdomains. + * + * This function exports the surface as a `TriangleMesh` and appends it to `graph`, using `orient_polygon_soup()`. + * + * @tparam C3T3 a model of `MeshComplexWithFeatures_3InTriangulation_3`. + * @tparam TriangleMesh a model of `MutableFaceGraph` with an internal point property map. The point type should be compatible with the one used in `C3T3`. + * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" + * + * @param c3t3 an instance of `C3T3`. + * @param graph an instance of `TriangleMesh`. + * @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below + * + * \cgalNamedParamsBegin + * \cgalParamNBegin{face_patch_map} + * \cgalParamDescription{a property map with the patch id's associated to the faces of `faces(graph)`} + * \cgalParamType{a class model of `ReadWritePropertyMap` with `boost::graph_traits::%face_descriptor` + * as key type and the desired property, model of `CopyConstructible` and `LessThanComparable` as value type.} + * \cgalParamDefault{If not provided, faces patch ids are ignored.} + * \cgalParamExtra{The map is updated during the remeshing process while new faces are created.} + * \cgalParamNEnd + * \cgalNamedParamsEnd + */ + template + void facets_in_complex_3_to_triangle_mesh(const C3T3& c3t3, + TriangleMesh& graph, + const NamedParameters& np) + { + namespace PMP = CGAL::Polygon_mesh_processing; - typedef typename boost::property_map::type VertexPointMap; - typedef typename boost::property_traits::value_type Point_3; + typedef typename boost::property_map::type VertexPointMap; + typedef typename boost::property_traits::value_type Point_3; + typedef typename boost::graph_traits::face_descriptor face_descriptor; + typedef typename C3T3::Surface_patch_index Surface_patch_index; - typedef std::array Face; + typedef std::array Face; - std::vector faces; - std::vector points; + std::vector faces; + std::vector patches; + std::vector points; - MDS_3::internal::facets_in_complex_3_to_triangle_soup(c3t3, points, faces); + MDS_3::internal::facets_in_complex_3_to_triangle_soup(c3t3, points, faces, patches); - if(!PMP::is_polygon_soup_a_polygon_mesh(faces)) - PMP::orient_polygon_soup(points, faces); - CGAL_postcondition(PMP::is_polygon_soup_a_polygon_mesh(faces)); + if (!PMP::is_polygon_soup_a_polygon_mesh(faces)) + PMP::orient_polygon_soup(points, faces); + CGAL_postcondition(PMP::is_polygon_soup_a_polygon_mesh(faces)); - PMP::polygon_soup_to_polygon_mesh(points, faces, graph); -} + boost::unordered_map i2f; + PMP::polygon_soup_to_polygon_mesh(points, faces, graph, + CGAL::parameters::polygon_to_face_output_iterator(std::inserter(i2f, i2f.end()))); + + using parameters::choose_parameter; + using parameters::get_parameter; + + MDS_3::internal::set_face_patches(i2f, + patches, + get_parameter(np, internal_np::face_patch)); + } + + template + void facets_in_complex_3_to_triangle_mesh(const C3T3& c3t3, TriangleMesh& graph) + { + facets_in_complex_3_to_triangle_mesh(c3t3, graph, parameters::all_default()); + } } // namespace CGAL From 4f9066310bb717799028ee109adea0557cf50658 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 31 May 2021 12:20:25 +0200 Subject: [PATCH 60/79] fix conversion warning --- MDS_3/include/CGAL/facets_in_complex_3_to_triangle_mesh.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MDS_3/include/CGAL/facets_in_complex_3_to_triangle_mesh.h b/MDS_3/include/CGAL/facets_in_complex_3_to_triangle_mesh.h index 5fbb4f2c04e..a371a49e125 100644 --- a/MDS_3/include/CGAL/facets_in_complex_3_to_triangle_mesh.h +++ b/MDS_3/include/CGAL/facets_in_complex_3_to_triangle_mesh.h @@ -230,7 +230,7 @@ void set_face_patches(const Index2FaceMap& i2f, PMP::orient_polygon_soup(points, faces); CGAL_postcondition(PMP::is_polygon_soup_a_polygon_mesh(faces)); - boost::unordered_map i2f; + boost::unordered_map i2f; PMP::polygon_soup_to_polygon_mesh(points, faces, graph, CGAL::parameters::polygon_to_face_output_iterator(std::inserter(i2f, i2f.end()))); From 658e6fa65459501f72ab92718b96e35248cb3beb Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 31 May 2021 15:04:18 +0200 Subject: [PATCH 61/79] add missing include --- MDS_3/include/CGAL/IO/File_medit.h | 1 + 1 file changed, 1 insertion(+) diff --git a/MDS_3/include/CGAL/IO/File_medit.h b/MDS_3/include/CGAL/IO/File_medit.h index a394556ad54..90071d4811e 100644 --- a/MDS_3/include/CGAL/IO/File_medit.h +++ b/MDS_3/include/CGAL/IO/File_medit.h @@ -16,6 +16,7 @@ #include +#include #include #include From 04c0f8ae6ce186701b921a1f3397a8159bdb8009 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 31 May 2021 15:04:34 +0200 Subject: [PATCH 62/79] fix compilation of surf_io_plugin --- .../Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h index 9759baf0f30..e904ed5a2cc 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h @@ -138,7 +138,11 @@ public: void operator()(PolygonMesh& pmesh, const bool insert_isolated_vertices = true) { - return operator()(pmesh, get(CGAL::vertex_point, pmesh), insert_isolated_vertices); + return operator()(pmesh, + get(CGAL::vertex_point, pmesh), + CGAL::Emptyset_iterator(), + CGAL::Emptyset_iterator(), + insert_isolated_vertices); } private: From 976ceaf5ea2eaccd46ba1aa0e0257e774a243bee Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 31 May 2021 16:06:21 +0200 Subject: [PATCH 63/79] add missing IO namespace --- MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 155d3307b6b..57362eb900c 100644 --- a/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -734,7 +734,7 @@ public: #endif { // Call global function - CGAL::output_to_medit(os, *this, rebind, show_patches); + CGAL::IO::output_to_medit(os, *this, rebind, show_patches); } /*! @@ -743,7 +743,7 @@ public: void output_to_maya(std::ostream& os, bool surfaceOnly = true) const { // Call global function - CGAL::output_to_maya(os, *this, surfaceOnly); + CGAL::IO::output_to_maya(os, *this, surfaceOnly); } /// @} From f8f01c5e55c1c91618a5e8aef09f20145baa281b Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 31 May 2021 17:35:02 +0200 Subject: [PATCH 64/79] remove unnecessary overload --- .../CGAL/facets_in_complex_3_to_triangle_mesh.h | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/MDS_3/include/CGAL/facets_in_complex_3_to_triangle_mesh.h b/MDS_3/include/CGAL/facets_in_complex_3_to_triangle_mesh.h index a371a49e125..06a3e02dbc7 100644 --- a/MDS_3/include/CGAL/facets_in_complex_3_to_triangle_mesh.h +++ b/MDS_3/include/CGAL/facets_in_complex_3_to_triangle_mesh.h @@ -151,15 +151,7 @@ void facets_in_complex_3_to_triangle_soup(const C3T3& c3t3, template void set_face_patches(const Index2FaceMap&, const SurfacePatchRange&, - internal_np::Param_not_found&) -{ - return; -} - -template -void set_face_patches(const Index2FaceMap&, - const SurfacePatchRange&, - internal_np::No_property&) + const internal_np::Param_not_found&) { return; } @@ -169,7 +161,7 @@ template void set_face_patches(const Index2FaceMap& i2f, const SurfacePatchRange& patches, - FacePatchMap& fpmap) + const FacePatchMap& fpmap) { for (auto index_and_face : i2f) { From 3ba204a5cc69e1f715221499e5eaa6cdbe4db95f Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 1 Jun 2021 12:06:41 +0200 Subject: [PATCH 65/79] fix error made in merging conflicts with master --- .../facets_in_complex_3_to_triangle_mesh.h | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/MDS_3/include/CGAL/facets_in_complex_3_to_triangle_mesh.h b/MDS_3/include/CGAL/facets_in_complex_3_to_triangle_mesh.h index 06a3e02dbc7..052c0585767 100644 --- a/MDS_3/include/CGAL/facets_in_complex_3_to_triangle_mesh.h +++ b/MDS_3/include/CGAL/facets_in_complex_3_to_triangle_mesh.h @@ -115,24 +115,24 @@ void facets_in_complex_3_to_triangle_soup(const C3T3& c3t3, CGAL::to_double(p.z())); points.push_back(bp); ++inum; - - f[i - 1] = map_entry->second; } - if (export_all_facets) - { - if ((cell_sdi > opp_sdi) == (s % 2 == 1)) - std::swap(f[0], f[1]); - } - else - { - if (((cell_sdi == sd_index) == (s % 2 == 1)) == normals_point_outside_of_the_subdomain) - std::swap(f[0], f[1]); - } - - faces.push_back(f); - patches.push_back(spi); + f[i-1] = map_entry->second; } + + if(export_all_facets) + { + if((cell_sdi > opp_sdi) == (s%2 == 1)) + std::swap(f[0], f[1]); + } + else + { + if(((cell_sdi == sd_index) == (s%2 == 1)) == normals_point_outside_of_the_subdomain) + std::swap(f[0], f[1]); + } + + faces.push_back(f); + patches.push_back(spi); } } From c9596995bcff29723ef16668f38b1de486c19171 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 1 Jun 2021 16:18:04 +0200 Subject: [PATCH 66/79] fix the order of includes using forward declarations --- MDS_3/include/CGAL/IO/File_medit.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MDS_3/include/CGAL/IO/File_medit.h b/MDS_3/include/CGAL/IO/File_medit.h index 90071d4811e..2228321115e 100644 --- a/MDS_3/include/CGAL/IO/File_medit.h +++ b/MDS_3/include/CGAL/IO/File_medit.h @@ -16,7 +16,7 @@ #include -#include +#include #include #include @@ -891,16 +891,16 @@ output_to_medit(std::ostream& os, if ( rebind ) { if ( show_patches ) - MDS_3::output_to_medit(os,c3t3); + CGAL::MDS_3::output_to_medit(os,c3t3); else - MDS_3::output_to_medit(os,c3t3); + CGAL::MDS_3::output_to_medit(os,c3t3); } else { if ( show_patches ) - MDS_3::output_to_medit(os,c3t3); + CGAL::MDS_3::output_to_medit(os,c3t3); else - MDS_3::output_to_medit(os,c3t3); + CGAL::MDS_3::output_to_medit(os,c3t3); } } From 570ffb7e1e0398eea9e3794ad8253e48e16c34be Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 3 Jun 2021 13:37:06 +0200 Subject: [PATCH 67/79] cleaning --- .../Mesh_complex_3_in_triangulation_3_fwd.h | 7 ++-- MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h | 35 ++++++++----------- 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/Installation/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h b/Installation/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h index 4d54cfdd8ae..62700e58f45 100644 --- a/Installation/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h +++ b/Installation/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h @@ -27,11 +27,8 @@ namespace MDS_3 { template bool build_triangulation_from_file(std::istream& is, Tr& tr, - bool replace_domain_0); - - template - bool build_triangulation_from_file(std::istream& is, - Tr& tr); + bool verbose = false, + bool replace_domain_0 = false); } // MDS_3 } // CGAL diff --git a/MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h b/MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h index b73fd37c37c..91007cf3170 100644 --- a/MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h +++ b/MDS_3/include/CGAL/MDS_3/tet_soup_to_c3t3.h @@ -346,9 +346,6 @@ bool build_triangulation(Tr& tr, const PointRange& points, const CellRange& finite_cells, const FacetPatchMap& border_facets, -// const std::vector& points, -// const std::vector >& finite_cells, -// const std::map, typename Tr::Cell::Surface_patch_index>& border_facets, std::vector& vertex_handle_vector, const bool verbose = false, bool replace_domain_0 = false) @@ -399,7 +396,8 @@ bool build_triangulation(Tr& tr, if(verbose) std::cout << tr.number_of_vertices() << " vertices" << std::endl; - return tr.tds().is_valid(); + return true;// tr.tds().is_valid(); + //TDS not valid when cells do not cover the convex hull of vertices } template& points, //PointRange -// const std::vector >& finite_cells, //CellRange -// const std::map, typename Tr::Cell::Surface_patch_index>& border_facets,//FacetsMap { BOOST_STATIC_ASSERT(boost::is_same::value); @@ -428,6 +423,7 @@ bool build_triangulation(Tr& tr, template bool build_triangulation_from_file(std::istream& is, Tr& tr, + const bool verbose, bool replace_domain_0) { typedef typename Tr::Point Point_3; @@ -449,7 +445,9 @@ bool build_triangulation_from_file(std::istream& is, CGAL_assertion(dim == 3); - std::cout << "Reading .mesh file..." << std::endl; + if(verbose) + std::cout << "Reading .mesh file..." << std::endl; + while(is >> word && word != "End") { if(word == "Vertices") @@ -508,24 +506,21 @@ bool build_triangulation_from_file(std::istream& is, } } - std::cout << points.size() << " points" << std::endl; - std::cout << border_facets.size() << " border facets" << std::endl; - std::cout << finite_cells.size() << " cells" << std::endl; + if (verbose) + { + std::cout << points.size() << " points" << std::endl; + std::cout << border_facets.size() << " border facets" << std::endl; + std::cout << finite_cells.size() << " cells" << std::endl; + } if(finite_cells.empty()) return false; - bool is_well_built = build_triangulation(tr, - points, finite_cells, border_facets, false, replace_domain_0); - return is_well_built; + return build_triangulation(tr, + points, finite_cells, border_facets, + verbose, replace_domain_0); } -template -bool build_triangulation_from_file(std::istream& is, - Tr& tr) -{ - return build_triangulation_from_file(is, tr, false); -} } // namespace MDS_3 } // namespace CGAL From 942c51d458bab432c0908bc4a88d43133026823f Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 4 Jun 2021 09:30:44 +0200 Subject: [PATCH 68/79] doc --- MDS_3/doc/MDS_3/PackageDescription.txt | 12 +++++++++++- MDS_3/include/CGAL/IO/File_medit.h | 12 ++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/MDS_3/doc/MDS_3/PackageDescription.txt b/MDS_3/doc/MDS_3/PackageDescription.txt index 9fc2a28147d..7afe36645fe 100644 --- a/MDS_3/doc/MDS_3/PackageDescription.txt +++ b/MDS_3/doc/MDS_3/PackageDescription.txt @@ -12,6 +12,10 @@ /// \ingroup PkgMDS3Ref /// The functions to work with the 3D mesh data structures. +/// \defgroup PkgMDS3ExportFunctions Export Functions +/// \ingroup PkgMDS3Ref +/// The free functions that can be used to export meshes to given output file formats. + /// \defgroup PkgMDS3IOFunctions Input/Output Functions /// \ingroup PkgMDS3Ref /// The free functions that can be used to read and write meshes. @@ -54,10 +58,16 @@ Here are the main concepts of this package: - `CGAL::facets_in_complex_3_to_triangle_mesh()` - `CGAL::tetrahedron_soup_to_triangulation_3()` -\cgalCRPSection{Input/Output Functions} +\cgalCRPSection{Export Functions} + - `CGAL::output_to_medit()` - `CGAL::output_to_vtu()` - `CGAL::output_to_tetgen()` - `CGAL::output_to_avizo()` + +\cgalCRPSection{Input/Output Functions} + +- `CGAL::write_MEDIT()` +- `CGAL::read_MEDIT()` */ diff --git a/MDS_3/include/CGAL/IO/File_medit.h b/MDS_3/include/CGAL/IO/File_medit.h index 2228321115e..e31e9630f2d 100644 --- a/MDS_3/include/CGAL/IO/File_medit.h +++ b/MDS_3/include/CGAL/IO/File_medit.h @@ -870,7 +870,7 @@ output_to_medit(std::ostream& os, namespace IO { /** - * @ingroup PkgMDS3IOFunctions + * @ingroup PkgMDS3ExportFunctions * @brief outputs a mesh complex to the medit (`.mesh`) file format. See \cgalCite{frey:inria-00069921} for a comprehensive description of this file format. * @param os the output stream @@ -904,7 +904,15 @@ output_to_medit(std::ostream& os, } } - +/** + * @ingroup PkgMDS3IOFunctions + * @brief outputs a mesh complex to the medit (`.mesh`) file format. + See \cgalCite{frey:inria-00069921} for a comprehensive description of this file format. + * @param os the output stream + * @param c3t3 the mesh complex + * + * \see \ref IOStreamMedit + */ template void write_MEDIT(std::ostream& os, const T3& t3) { From 70d2acb9332ef7ad5871b53cb3917a2538fe4d41 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 4 Jun 2021 09:31:07 +0200 Subject: [PATCH 69/79] add a test for read_MEDIT and write_MEDIT --- MDS_3/test/MDS_3/CMakeLists.txt | 1 + MDS_3/test/MDS_3/test_c3t3_io_MEDIT.cpp | 33 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 MDS_3/test/MDS_3/test_c3t3_io_MEDIT.cpp diff --git a/MDS_3/test/MDS_3/CMakeLists.txt b/MDS_3/test/MDS_3/CMakeLists.txt index 2ac505339a7..25923742e40 100644 --- a/MDS_3/test/MDS_3/CMakeLists.txt +++ b/MDS_3/test/MDS_3/CMakeLists.txt @@ -15,6 +15,7 @@ create_single_source_cgal_program( "test_c3t3_io.cpp" ) create_single_source_cgal_program( "test_c3t3_with_features.cpp" ) create_single_source_cgal_program( "test_c3t3_into_facegraph.cpp" ) create_single_source_cgal_program( "test_c3t3_extract_subdomains_boundaries.cpp" ) +create_single_source_cgal_program( "test_c3t3_io_MEDIT.cpp" ) foreach(target test_c3t3 diff --git a/MDS_3/test/MDS_3/test_c3t3_io_MEDIT.cpp b/MDS_3/test/MDS_3/test_c3t3_io_MEDIT.cpp new file mode 100644 index 00000000000..daac84ca7b0 --- /dev/null +++ b/MDS_3/test/MDS_3/test_c3t3_io_MEDIT.cpp @@ -0,0 +1,33 @@ +#include + +#include +#include + +#include + +#include +#include + +int main (int argc, char** argv) +{ + typedef CGAL::Exact_predicates_inexact_constructions_kernel K; + + typedef CGAL::Tetrahedral_remeshing::Remeshing_triangulation_3 Tr; + typedef CGAL::Mesh_complex_3_in_triangulation_3 C3t3; + + // Open file + std::ifstream in(argc > 1 ? argv[1] : "data/elephant.mesh", + std::ios_base::in); + if(!in) { + std::cerr << "Error! Cannot open file " << argv[1] << std::endl; + return 1; + } + Tr tr; + CGAL::IO::read_MEDIT(in, tr); + + std::ofstream os("elephant_out.mesh"); + CGAL::IO::write_MEDIT(os, tr); + os.close(); + + return EXIT_SUCCESS; +} From 9970ca4415b3bc593bac3c3ed4046f020f939c2b Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 4 Jun 2021 09:31:23 +0200 Subject: [PATCH 70/79] add missing stream close() --- MDS_3/test/MDS_3/test_c3t3_into_facegraph.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/MDS_3/test/MDS_3/test_c3t3_into_facegraph.cpp b/MDS_3/test/MDS_3/test_c3t3_into_facegraph.cpp index 2fccb62b866..7cb5e3e144d 100644 --- a/MDS_3/test/MDS_3/test_c3t3_into_facegraph.cpp +++ b/MDS_3/test/MDS_3/test_c3t3_into_facegraph.cpp @@ -88,6 +88,7 @@ int main (int argc, char** argv){ std::ofstream out("graph.off"); out << poly; + out.close(); CGAL_assertion(is_valid(poly)); return EXIT_SUCCESS; From b4b2d861bc09d70dd05b9870fbfeb78860367e56 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 4 Jun 2021 11:13:53 +0200 Subject: [PATCH 71/79] change include Mesh_complex_3_in_triangulation_3 needs to be defined for write_MEDIT() --- MDS_3/include/CGAL/IO/File_medit.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MDS_3/include/CGAL/IO/File_medit.h b/MDS_3/include/CGAL/IO/File_medit.h index e31e9630f2d..d66f86b23d4 100644 --- a/MDS_3/include/CGAL/IO/File_medit.h +++ b/MDS_3/include/CGAL/IO/File_medit.h @@ -16,7 +16,7 @@ #include -#include +#include #include #include From c390a99b22ba1c7542e9dcec588abceb8ca47660 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 4 Jun 2021 13:11:12 +0200 Subject: [PATCH 72/79] add iterator ranges --- .../CGAL/Mesh_complex_3_in_triangulation_3.h | 60 ++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 57362eb900c..0f4a409f315 100644 --- a/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -899,9 +899,22 @@ public: typedef unspecified_type Facets_in_complex_iterator; /// Iterator type to visit the edges of the 1D complex typedef unspecified_type Edges_in_complex_iterator; - /// Iterator type to visit the edges of the 0D complex + /// Iterator type to visit the vertices of the 0D complex typedef unspecified_type Vertices_in_complex_iterator; + /// Range type for iterating over all cells of the 3D complex, + /// with a nested type iterator that has as value type `Cell_handle`. + typedef Iterator_range Cells_in_complex; + /// Range type for iterating over all facets of the 2D complex, + /// with a nested type iterator that has as value type `Facet`. + typedef Iterator_range Facets_in_complex; + /// Range type for iterating over all cells of the 1D complex, + /// with a nested type iterator that has as value type `Edge`. + typedef Iterator_range Edges_in_complex; + /// Range type for iterating over all vertices of the 0D complex, + /// with a nested type iterator that has as value type `Vertex_handle`. + typedef Iterator_range Vertices_in_complex; + #else typedef Filter_iterator< typename Triangulation::Finite_edges_iterator, @@ -941,6 +954,11 @@ public: operator Cell_handle() const { return Cell_handle(this->base()); } }; // end class Cells_in_complex_iterator + typedef Iterator_range > Vertices_in_complex; + typedef Iterator_range Edges_in_complex; + typedef Iterator_range Facets_in_complex; + typedef Iterator_range > Cells_in_complex; + #endif /// \name Iterators @@ -1041,6 +1059,46 @@ public: Vertex_iterator_not_in_complex(*this)); } + /*! + returns a range of iterators over vertices of the 0D complex + \note The value type of `Vertices_in_complex::iterator` is `Vertex_handle`. + */ + Vertices_in_complex vertices_in_complex() const + { + return make_prevent_deref_range(vertices_in_complex_begin(), + vertices_in_complex_end()); + } + /*! + returns a range of iterators over the edges of the 1D complex, + starting at an arbitrary edge. + Returns an empty range when `t.dimension() < 2`. + */ + Edges_in_complex edges_in_complex() const + { + return make_prevent_deref_range(edges_in_complex_begin(), + edges_in_complex_end()); + } + /*! + returns a range of iterators over the facets of the 2D complex, + starting at an arbitrary facet. + Returns an empty range when `t.dimension() < 2`. + */ + Facets_in_complex facets_in_complex() const + { + return make_prevent_deref_range(facets_in_complex_begin(), + facets_in_complex_end()); + } + /*! + returns a range of iterators over cells of the 3D complex. + Returns an empty range when `triangulation().number_of_cells() == 0` + or complex is empty. + \note The value type of `Cells_in_complex::iterator` is `Cell_handle`. + */ + Cells_in_complex cells_in_complex() const + { + return make_prevent_deref_range(cells_in_complex_begin(), + cells_in_complex_end()); + } /// @} public: From d3662e8d2122335b33371a8d1c5af1facb752632 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 4 Jun 2021 13:29:45 +0200 Subject: [PATCH 73/79] add all_vertices parameter to output_to_medit to decide whether we write all vertices, or only the ones that take part to the complex --- .../CGAL/boost/graph/parameters_interface.h | 1 + MDS_3/include/CGAL/IO/File_medit.h | 130 ++++++++++++++---- MDS_3/test/MDS_3/test_c3t3_io_MEDIT.cpp | 3 +- 3 files changed, 109 insertions(+), 25 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/parameters_interface.h b/BGL/include/CGAL/boost/graph/parameters_interface.h index 03561471e21..ed68546e7c2 100644 --- a/BGL/include/CGAL/boost/graph/parameters_interface.h +++ b/BGL/include/CGAL/boost/graph/parameters_interface.h @@ -202,6 +202,7 @@ CGAL_add_named_parameter(smooth_constrained_edges_t, smooth_constrained_edges, s // MDS_3 parameters CGAL_add_named_parameter(surface_facets_t, surface_facets, surface_facets) +CGAL_add_named_parameter(all_vertices_t, all_vertices, all_vertices) // output parameters CGAL_add_named_parameter(face_proxy_map_t, face_proxy_map, face_proxy_map) diff --git a/MDS_3/include/CGAL/IO/File_medit.h b/MDS_3/include/CGAL/IO/File_medit.h index d66f86b23d4..08331a25ab3 100644 --- a/MDS_3/include/CGAL/IO/File_medit.h +++ b/MDS_3/include/CGAL/IO/File_medit.h @@ -26,6 +26,9 @@ #include #include +#include +#include + #include #include #include @@ -703,7 +706,8 @@ struct Medit_pmap_generator template void output_to_medit(std::ostream& os, - const C3T3& c3t3) + const C3T3& c3t3, + const bool all_vertices) { #ifdef CGAL_MESH_3_IO_VERBOSE std::cerr << "Output to medit:\n"; @@ -726,7 +730,8 @@ output_to_medit(std::ostream& os, facet_pmap, cell_pmap, facet_pmap_twice, - Generator().print_twice()); + Generator().print_twice(), + all_vertices); #ifdef CGAL_MESH_3_IO_VERBOSE std::cerr << "done.\n"; @@ -747,14 +752,15 @@ output_to_medit(std::ostream& os, const Facet_index_property_map& facet_pmap, const Cell_index_property_map& cell_pmap, const Facet_index_property_map_twice& facet_twice_pmap = Facet_index_property_map_twice(), - const bool print_each_facet_twice = false) + const bool print_each_facet_twice = false, + const bool all_vertices = true) { typedef typename C3T3::Triangulation Tr; typedef typename C3T3::Facets_in_complex_iterator Facet_iterator; typedef typename C3T3::Cells_in_complex_iterator Cell_iterator; - typedef typename Tr::Finite_vertices_iterator Finite_vertices_iterator; typedef typename Tr::Vertex_handle Vertex_handle; + typedef typename Tr::Cell_handle Cell_handle; typedef typename Tr::Point Point; //can be weighted or not const Tr& tr = c3t3.triangulation(); @@ -779,17 +785,38 @@ output_to_medit(std::ostream& os, boost::unordered_map V; int inum = 1; - for( Finite_vertices_iterator vit = tr.finite_vertices_begin(); - vit != tr.finite_vertices_end(); - ++vit) + if (all_vertices) { - V[vit] = inum++; - Point p = tr.point(vit); - os << CGAL::to_double(p.x()) << ' ' - << CGAL::to_double(p.y()) << ' ' - << CGAL::to_double(p.z()) << ' ' - << get(vertex_pmap, vit) - << '\n'; + for (Vertex_handle vit : tr.finite_vertex_handles()) + { + V[vit] = inum++; + Point p = tr.point(vit); + os << CGAL::to_double(p.x()) << ' ' + << CGAL::to_double(p.y()) << ' ' + << CGAL::to_double(p.z()) << ' ' + << get(vertex_pmap, vit) + << '\n'; + } + } + else + { + for (Cell_handle c : c3t3.cells_in_complex()) + { + for (int i = 0; i < 4; ++i) + { + Vertex_handle vit = c->vertex(i); + if (V.find(vit) == V.end()) + { + V[vit] = inum++; + Point p = tr.point(vit); + os << CGAL::to_double(p.x()) << ' ' + << CGAL::to_double(p.y()) << ' ' + << CGAL::to_double(p.z()) << ' ' + << get(vertex_pmap, vit) + << '\n'; + } + } + } } //------------------------------------------------------- @@ -886,38 +913,93 @@ void output_to_medit(std::ostream& os, const C3T3& c3t3, bool rebind = false, - bool show_patches = false) + bool show_patches = false +#ifndef DOXYGEN_RUNNING + , bool all_vertices = true +#endif +) { if ( rebind ) { if ( show_patches ) - CGAL::MDS_3::output_to_medit(os,c3t3); + CGAL::MDS_3::output_to_medit(os, c3t3, all_vertices); else - CGAL::MDS_3::output_to_medit(os,c3t3); + CGAL::MDS_3::output_to_medit(os, c3t3, all_vertices); } else { if ( show_patches ) - CGAL::MDS_3::output_to_medit(os,c3t3); + CGAL::MDS_3::output_to_medit(os, c3t3, all_vertices); else - CGAL::MDS_3::output_to_medit(os,c3t3); + CGAL::MDS_3::output_to_medit(os, c3t3, all_vertices); } } /** * @ingroup PkgMDS3IOFunctions * @brief outputs a mesh complex to the medit (`.mesh`) file format. - See \cgalCite{frey:inria-00069921} for a comprehensive description of this file format. + * See \cgalCite{frey:inria-00069921} for a comprehensive description of this file format. + * @tparam T3 can be instantiated with any 3D triangulation of \cgal provided that its + * vertex and cell base class are models of the concepts `MeshVertexBase_3` and `MeshCellBase_3`, respectively. + * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" + * + * @param os the output stream + * @param t3 the triangulation + * @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below + * + * \cgalNamedParamsBegin + * \cgalParamNBegin{all_vertices} + * \cgalParamDescription{If `true`, all the vertices in `t3` are written in `os`. + * Otherwise, only the vertices that belong to a cell `c` for which + * `c->subdomain_index() != Subdomain_index()` are written} + * \cgalParamType{Boolean} + * \cgalParamDefault{`true`} + * \cgalParamExtra{This parameter should be set to `false` for the file to be readable by `read_MEDIT()`.} + * \cgalParamNEnd + * + * \see \ref IOStreamMedit + */ +template +void write_MEDIT(std::ostream& os, + const T3& t3, + const NamedParameters& np) +{ + CGAL::Mesh_complex_3_in_triangulation_3 c3t3; + c3t3.triangulation() = t3; + c3t3.rescan_after_load_of_triangulation(); + + using parameters::get_parameter; + using parameters::choose_parameter; + + bool all_v = choose_parameter(get_parameter(np, internal_np::all_vertices), true); + bool rebind = false; + bool show_patches = false; + + output_to_medit(os, c3t3, rebind, show_patches, all_v); +} + +template +void write_MEDIT(std::ostream& os, + const T3& t3) +{ + write_MEDIT(os, t3, parameters::all_default()); +} + +/** + * @ingroup PkgMDS3IOFunctions + * @brief outputs a mesh complex to the medit (`.mesh`) file format. + * See \cgalCite{frey:inria-00069921} for a comprehensive description of this file format. + * @tparam T3 can be instantiated with any 3D triangulation of \cgal provided that its + * vertex and cell base class are models of the concepts `MeshVertexBase_3` and `MeshCellBase_3`, respectively. * @param os the output stream * @param c3t3 the mesh complex * * \see \ref IOStreamMedit */ -template -void write_MEDIT(std::ostream& os, const T3& t3) +template +void write_MEDIT(std::ostream& os, + const CGAL::Mesh_complex_3_in_triangulation_3& c3t3) { - CGAL::Mesh_complex_3_in_triangulation_3 c3t3; - c3t3.triangulation() = t3; c3t3.rescan_after_load_of_triangulation(); output_to_medit(os, c3t3); } diff --git a/MDS_3/test/MDS_3/test_c3t3_io_MEDIT.cpp b/MDS_3/test/MDS_3/test_c3t3_io_MEDIT.cpp index daac84ca7b0..55f9a0e9c5f 100644 --- a/MDS_3/test/MDS_3/test_c3t3_io_MEDIT.cpp +++ b/MDS_3/test/MDS_3/test_c3t3_io_MEDIT.cpp @@ -26,7 +26,8 @@ int main (int argc, char** argv) CGAL::IO::read_MEDIT(in, tr); std::ofstream os("elephant_out.mesh"); - CGAL::IO::write_MEDIT(os, tr); + CGAL::IO::write_MEDIT(os, tr, + CGAL::parameters::all_vertices(true)); os.close(); return EXIT_SUCCESS; From 55f9f1008bc24bfedac0c27bdb1bcd3f601c5f12 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 4 Jun 2021 14:40:05 +0200 Subject: [PATCH 74/79] add parameter all_cells to write all finite cells VS cells of the complex --- .../CGAL/boost/graph/parameters_interface.h | 1 + MDS_3/include/CGAL/IO/File_medit.h | 60 ++++++++++++++----- 2 files changed, 45 insertions(+), 16 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/parameters_interface.h b/BGL/include/CGAL/boost/graph/parameters_interface.h index ed68546e7c2..c1f07f31606 100644 --- a/BGL/include/CGAL/boost/graph/parameters_interface.h +++ b/BGL/include/CGAL/boost/graph/parameters_interface.h @@ -203,6 +203,7 @@ CGAL_add_named_parameter(smooth_constrained_edges_t, smooth_constrained_edges, s // MDS_3 parameters CGAL_add_named_parameter(surface_facets_t, surface_facets, surface_facets) CGAL_add_named_parameter(all_vertices_t, all_vertices, all_vertices) +CGAL_add_named_parameter(all_cells_t, all_cells, all_cells) // output parameters CGAL_add_named_parameter(face_proxy_map_t, face_proxy_map, face_proxy_map) diff --git a/MDS_3/include/CGAL/IO/File_medit.h b/MDS_3/include/CGAL/IO/File_medit.h index 08331a25ab3..d218bfd802a 100644 --- a/MDS_3/include/CGAL/IO/File_medit.h +++ b/MDS_3/include/CGAL/IO/File_medit.h @@ -707,7 +707,8 @@ template void output_to_medit(std::ostream& os, const C3T3& c3t3, - const bool all_vertices) + const bool all_vertices, + const bool all_cells) { #ifdef CGAL_MESH_3_IO_VERBOSE std::cerr << "Output to medit:\n"; @@ -731,7 +732,8 @@ output_to_medit(std::ostream& os, cell_pmap, facet_pmap_twice, Generator().print_twice(), - all_vertices); + all_vertices, + all_cells); #ifdef CGAL_MESH_3_IO_VERBOSE std::cerr << "done.\n"; @@ -753,11 +755,11 @@ output_to_medit(std::ostream& os, const Cell_index_property_map& cell_pmap, const Facet_index_property_map_twice& facet_twice_pmap = Facet_index_property_map_twice(), const bool print_each_facet_twice = false, - const bool all_vertices = true) + const bool all_vertices = true, + const bool all_cells = true) { typedef typename C3T3::Triangulation Tr; typedef typename C3T3::Facets_in_complex_iterator Facet_iterator; - typedef typename C3T3::Cells_in_complex_iterator Cell_iterator; typedef typename Tr::Vertex_handle Vertex_handle; typedef typename Tr::Cell_handle Cell_handle; @@ -875,14 +877,25 @@ output_to_medit(std::ostream& os, os << "Tetrahedra\n" << number_of_cells << '\n'; - for( Cell_iterator cit = c3t3.cells_in_complex_begin() ; - cit != c3t3.cells_in_complex_end() ; - ++cit ) + if (all_cells) { - for (int i=0; i<4; i++) - os << V[cit->vertex(i)] << ' '; + for (Cell_handle cit : c3t3.triangulation().finite_cell_handles()) + { + for (int i = 0; i < 4; i++) + os << V[cit->vertex(i)] << ' '; - os << get(cell_pmap, cit) << '\n'; + os << get(cell_pmap, cit) << '\n'; + } + } + else + { + for (Cell_handle cit : c3t3.cells_in_complex()) + { + for (int i = 0; i < 4; i++) + os << V[cit->vertex(i)] << ' '; + + os << get(cell_pmap, cit) << '\n'; + } } //------------------------------------------------------- @@ -916,22 +929,27 @@ output_to_medit(std::ostream& os, bool show_patches = false #ifndef DOXYGEN_RUNNING , bool all_vertices = true + , bool all_cells = false #endif ) { if ( rebind ) { if ( show_patches ) - CGAL::MDS_3::output_to_medit(os, c3t3, all_vertices); + CGAL::MDS_3::output_to_medit(os, c3t3, + all_vertices, all_cells); else - CGAL::MDS_3::output_to_medit(os, c3t3, all_vertices); + CGAL::MDS_3::output_to_medit(os, c3t3, + all_vertices, all_cells); } else { if ( show_patches ) - CGAL::MDS_3::output_to_medit(os, c3t3, all_vertices); + CGAL::MDS_3::output_to_medit(os, c3t3, + all_vertices, all_cells); else - CGAL::MDS_3::output_to_medit(os, c3t3, all_vertices); + CGAL::MDS_3::output_to_medit(os, c3t3, + all_vertices, all_cells); } } @@ -956,7 +974,15 @@ output_to_medit(std::ostream& os, * \cgalParamDefault{`true`} * \cgalParamExtra{This parameter should be set to `false` for the file to be readable by `read_MEDIT()`.} * \cgalParamNEnd - * + * \cgalParamNBegin{all_cells} + * \cgalParamDescription{If `true`, all the cells in `t3` are written in `os`, + * however they belong to the complex or not. + * Otherwise, only the cells `c` for which + * `c->subdomain_index() != Subdomain_index()` are written} + * \cgalParamType{Boolean} + * \cgalParamDefault{`true`} + * \cgalParamExtra{If `all_vertices` is `true`, this parameter is ignored.} + * \cgalParamNEnd * \see \ref IOStreamMedit */ template @@ -974,8 +1000,10 @@ void write_MEDIT(std::ostream& os, bool all_v = choose_parameter(get_parameter(np, internal_np::all_vertices), true); bool rebind = false; bool show_patches = false; + bool all_c = all_v || + choose_parameter(get_parameter(np, internal_np::all_cells), true); - output_to_medit(os, c3t3, rebind, show_patches, all_v); + output_to_medit(os, c3t3, rebind, show_patches, all_v, all_c); } template From 8ccfff1f1d72d7719ceba841602da70755ef3dbd Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 4 Jun 2021 15:03:38 +0200 Subject: [PATCH 75/79] fix namespace, and make parameters list for clear this list of parameters implements previous and documented version of output_to_medit() --- MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h | 5 ++++- MDS_3/test/MDS_3/test_c3t3_io_MEDIT.cpp | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 0f4a409f315..34fc8fbd176 100644 --- a/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -734,7 +734,10 @@ public: #endif { // Call global function - CGAL::IO::output_to_medit(os, *this, rebind, show_patches); + bool all_vertices = true; + bool all_cells = false; + CGAL::MDS_3::output_to_medit(os, *this, rebind, show_patches, + all_vertices, all_cells); } /*! diff --git a/MDS_3/test/MDS_3/test_c3t3_io_MEDIT.cpp b/MDS_3/test/MDS_3/test_c3t3_io_MEDIT.cpp index 55f9a0e9c5f..1e697632c63 100644 --- a/MDS_3/test/MDS_3/test_c3t3_io_MEDIT.cpp +++ b/MDS_3/test/MDS_3/test_c3t3_io_MEDIT.cpp @@ -27,7 +27,7 @@ int main (int argc, char** argv) std::ofstream os("elephant_out.mesh"); CGAL::IO::write_MEDIT(os, tr, - CGAL::parameters::all_vertices(true)); + CGAL::parameters::all_vertices(false)); os.close(); return EXIT_SUCCESS; From 80803403bcf5845d77c56dfb16d67e4655515cde Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 7 Jun 2021 11:39:04 +0200 Subject: [PATCH 76/79] fix namespace --- MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 34fc8fbd176..84434a57714 100644 --- a/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/MDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -736,7 +736,7 @@ public: // Call global function bool all_vertices = true; bool all_cells = false; - CGAL::MDS_3::output_to_medit(os, *this, rebind, show_patches, + CGAL::IO::output_to_medit(os, *this, rebind, show_patches, all_vertices, all_cells); } From 847f9f127e684cc37d2407749c0343b823869999 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 7 Jun 2021 14:54:11 +0200 Subject: [PATCH 77/79] fix the use of face_patch_map for export_facets_in_complex() in the demo --- Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp b/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp index 04fc37c70f9..8dda4174ed8 100644 --- a/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_c3t3_item.cpp @@ -1168,16 +1168,20 @@ double Scene_c3t3_item_priv::complex_diag() const { void Scene_c3t3_item::export_facets_in_complex() { SMesh outmesh; + Scene_surface_mesh_item* item = new Scene_surface_mesh_item(outmesh); + item->setItemIsMulticolor(true); boost::property_map >::type - fpmap = get(CGAL::face_patch_id_t(), outmesh); + fpmap = get(CGAL::face_patch_id_t(), *item->face_graph()); - CGAL::facets_in_complex_3_to_triangle_mesh(c3t3(), outmesh, + CGAL::facets_in_complex_3_to_triangle_mesh(c3t3(), + *item->face_graph(), CGAL::parameters::face_patch_map(fpmap)); - Scene_surface_mesh_item* item = new Scene_surface_mesh_item(std::move(outmesh)); + item->computeItemColorVectorAutomatically(true); + item->invalidateOpenGLBuffers(); item->setName(QString("%1_%2").arg(this->name()).arg("facets")); - item->setItemIsMulticolor(true); + scene->addItem(item); this->setVisible(false); } From 6253ef448de04fb4ea5cfdaa53e3e999ee06b2c0 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 7 Jun 2021 15:14:37 +0200 Subject: [PATCH 78/79] add missing include --- MDS_3/include/CGAL/IO/File_medit.h | 1 + 1 file changed, 1 insertion(+) diff --git a/MDS_3/include/CGAL/IO/File_medit.h b/MDS_3/include/CGAL/IO/File_medit.h index d218bfd802a..bb9b34862c1 100644 --- a/MDS_3/include/CGAL/IO/File_medit.h +++ b/MDS_3/include/CGAL/IO/File_medit.h @@ -16,6 +16,7 @@ #include +#include #include #include From 4238d47c11d373b4db42c48a7db3fd8eb0a68c5f Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 7 Jun 2021 16:18:04 +0200 Subject: [PATCH 79/79] add missing forward declaration --- .../MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h | 13 +++++++++++++ MDS_3/include/CGAL/IO/File_medit.h | 8 ++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Installation/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h b/Installation/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h index 62700e58f45..f21ddcb751b 100644 --- a/Installation/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h +++ b/Installation/include/CGAL/MDS_3/Mesh_complex_3_in_triangulation_3_fwd.h @@ -22,6 +22,19 @@ template class Mesh_complex_3_in_triangulation_3; +namespace IO { + template + void output_to_medit(std::ostream& os, + const C3T3& c3t3, + bool rebind = false, + bool show_patches = false +#ifndef DOXYGEN_RUNNING + , bool all_vertices = true + , bool all_cells = false +#endif + ); +} + namespace MDS_3 { template diff --git a/MDS_3/include/CGAL/IO/File_medit.h b/MDS_3/include/CGAL/IO/File_medit.h index bb9b34862c1..019a381652a 100644 --- a/MDS_3/include/CGAL/IO/File_medit.h +++ b/MDS_3/include/CGAL/IO/File_medit.h @@ -926,11 +926,11 @@ template void output_to_medit(std::ostream& os, const C3T3& c3t3, - bool rebind = false, - bool show_patches = false + bool rebind, // = false, + bool show_patches // = false #ifndef DOXYGEN_RUNNING - , bool all_vertices = true - , bool all_cells = false + , bool all_vertices // = true + , bool all_cells // = false #endif ) {