From 54d50ef1d45d7f0db588b2246b803e50de86b762 Mon Sep 17 00:00:00 2001 From: Marco Feder Date: Sat, 30 Apr 2022 00:58:03 +0200 Subject: [PATCH] Address some comments --- .../minor/20220428MarcoFederLucaHeltai | 4 ---- include/deal.II/cgal/surface_mesh.h | 4 ++-- source/cgal/surface_mesh.cc | 13 ++++++++---- source/cgal/surface_mesh.inst.in | 3 ++- tests/cgal/cgal_surface_mesh_01.cc | 21 ++++++++++++------- 5 files changed, 26 insertions(+), 19 deletions(-) delete mode 100644 doc/news/changes/minor/20220428MarcoFederLucaHeltai diff --git a/doc/news/changes/minor/20220428MarcoFederLucaHeltai b/doc/news/changes/minor/20220428MarcoFederLucaHeltai deleted file mode 100644 index 1b6bdd0242..0000000000 --- a/doc/news/changes/minor/20220428MarcoFederLucaHeltai +++ /dev/null @@ -1,4 +0,0 @@ -New: Added function CGALWrappers::to_cgal_mesh() to convert a deal.II cell -into a CGAL::Surface_mesh. -
-(Marco Feder, Luca Heltai, 2022/04/28) diff --git a/include/deal.II/cgal/surface_mesh.h b/include/deal.II/cgal/surface_mesh.h index c4752ac2b6..bdafe40bc5 100644 --- a/include/deal.II/cgal/surface_mesh.h +++ b/include/deal.II/cgal/surface_mesh.h @@ -44,7 +44,7 @@ namespace CGALWrappers * More information on this class is available at * https://doc.cgal.org/latest/Surface_mesh/index.html * - * The function will throw an exception in dimension one. In dimension two it + * The function will throw an exception in dimension one. In dimension two, it * generates a surface mesh of the quadrilateral cell or of the triangle cell, * while in dimension three it will generate the surface mesh of the cell, * i.e., a polyhedral mesh containing the faces of the input cell. @@ -62,7 +62,7 @@ namespace CGALWrappers */ template void - to_cgal_mesh( + convert_to_cgal_surface_mesh( const typename dealii::Triangulation::cell_iterator &cell, const dealii::Mapping & mapping, CGAL::Surface_mesh & mesh); diff --git a/source/cgal/surface_mesh.cc b/source/cgal/surface_mesh.cc index 8a47384b37..5ec2681d3c 100644 --- a/source/cgal/surface_mesh.cc +++ b/source/cgal/surface_mesh.cc @@ -35,7 +35,6 @@ namespace const unsigned nv = face->n_vertices(); std::vector indices; - switch (nv) { case 2: @@ -80,11 +79,16 @@ namespace CGALWrappers { template void - to_cgal_mesh(const typename Triangulation::cell_iterator &cell, - const Mapping & mapping, - CGAL::Surface_mesh &mesh) + convert_to_cgal_surface_mesh( + const typename Triangulation::cell_iterator &cell, + const Mapping & mapping, + CGAL::Surface_mesh & mesh) { Assert(dim > 1, ExcImpossibleInDim(dim)); + Assert( + mesh.is_empty(), + ExcMessage( + "The CGAL::Surface_mesh object must be empty upon calling this function.")); using Mesh = CGAL::Surface_mesh; using Vertex_index = typename Mesh::Vertex_index; const auto &vertices = mapping.get_vertices(cell); @@ -108,6 +112,7 @@ namespace CGALWrappers mesh, (f % 2 == 0 || cell->n_vertices() != 8)); } + // explicit instantiations # include "surface_mesh.inst" diff --git a/source/cgal/surface_mesh.inst.in b/source/cgal/surface_mesh.inst.in index 9910460881..3fe79dc6d4 100644 --- a/source/cgal/surface_mesh.inst.in +++ b/source/cgal/surface_mesh.inst.in @@ -18,7 +18,8 @@ for (dim : DIMENSIONS; spacedim : SPACE_DIMENSIONS; cgal_kernel : CGAL_KERNELS) { #if dim <= spacedim - template void to_cgal_mesh( + template void + convert_to_cgal_surface_mesh( const typename Triangulation::cell_iterator &cell, const Mapping & mapping, CGAL::Surface_mesh & mesh); diff --git a/tests/cgal/cgal_surface_mesh_01.cc b/tests/cgal/cgal_surface_mesh_01.cc index 267945ff85..5ce3152b66 100644 --- a/tests/cgal/cgal_surface_mesh_01.cc +++ b/tests/cgal/cgal_surface_mesh_01.cc @@ -13,7 +13,7 @@ // // --------------------------------------------------------------------- -// Convert a deal.II cell to a cgal Surface_mesh +// Convert a deal.II cell to a cgal Surface_mesh. #include @@ -38,21 +38,26 @@ void test() { deallog << "dim= " << dim << ",\t spacedim= " << spacedim << std::endl; - std::vector> d2t = {{}, {2}, {3, 4}, {4, 5, 6, 8}}; - for (const auto nv : d2t[dim]) + using namespace ReferenceCells; + std::vector> ref_cells = { + {}, + {Line}, + {Triangle, Quadrilateral}, + {Tetrahedron, Pyramid, Wedge, Hexahedron}}; + for (const auto r_cell : ref_cells[dim]) { Triangulation tria; CGAL::Surface_mesh mesh; - const auto ref = ReferenceCell::n_vertices_to_type(dim, nv); - const auto mapping = ref.template get_default_mapping(1); - GridGenerator::reference_cell(tria, ref); + const auto mapping = + r_cell.template get_default_mapping(1); + GridGenerator::reference_cell(tria, r_cell); const auto cell = tria.begin_active(); - to_cgal_mesh(cell, *mapping, mesh); + convert_to_cgal_surface_mesh(cell, *mapping, mesh); Assert(mesh.is_valid(), dealii::ExcMessage("The CGAL mesh is not valid")); - deallog << "deal vertices: " << nv << ", cgal vertices " + deallog << "deal vertices: " << cell->n_vertices() << ", cgal vertices " << mesh.num_vertices() << std::endl; deallog << "deal faces: " << cell->n_faces() << ", cgal faces " << mesh.num_faces() << std::endl; -- 2.39.5