19#ifdef DEAL_II_WITH_CGAL
21# include <CGAL/Exact_predicates_exact_constructions_kernel.h>
22# include <CGAL/Simple_cartesian.h>
23# include <CGAL/Surface_mesh/Surface_mesh.h>
30 template <
typename dealiiFace,
typename CGAL_Mesh>
33 const dealiiFace &face,
34 const std::map<unsigned int, typename CGAL_Mesh::Vertex_index> &deal2cgal,
36 const bool clockwise_ordering =
true)
38 const auto reference_cell_type = face->reference_cell();
39 std::vector<typename CGAL_Mesh::Vertex_index> indices;
43 mesh.add_edge(deal2cgal.at(face->vertex_index(0)),
44 deal2cgal.at(face->vertex_index(1)));
48 indices = {deal2cgal.at(face->vertex_index(0)),
49 deal2cgal.at(face->vertex_index(1)),
50 deal2cgal.at(face->vertex_index(2))};
55 indices = {deal2cgal.at(face->vertex_index(0)),
56 deal2cgal.at(face->vertex_index(1)),
57 deal2cgal.at(face->vertex_index(3)),
58 deal2cgal.at(face->vertex_index(2))};
63 if (clockwise_ordering ==
true)
64 std::reverse(indices.begin(), indices.end());
66 [[maybe_unused]]
const auto new_face = mesh.add_face(indices);
67 Assert(new_face != mesh.null_face(),
69 "CGAL encountered a orientation problem that it "
70 "was not able to solve."));
75 template <
typename dealiiFace,
typename CGAL_Mesh>
78 const dealiiFace &cell,
79 std::map<unsigned int, typename CGAL_Mesh::Vertex_index> &deal2cgal,
84 deal2cgal[cell->vertex_index(i)] = mesh.add_vertex(
85 CGALWrappers::dealii_point_to_cgal_point<typename CGAL_Mesh::Point>(
97 template <
typename CGALPo
intType,
int dim,
int spacedim>
102 CGAL::Surface_mesh<CGALPointType> &mesh)
105 using Mesh = CGAL::Surface_mesh<CGALPointType>;
107 std::map<unsigned int, typename Mesh::Vertex_index> deal2cgal;
112 deal2cgal[cell->vertex_index(i)] = mesh.add_vertex(
113 CGALWrappers::dealii_point_to_cgal_point<CGALPointType>(vertices[i]));
118 add_facet(cell, deal2cgal, mesh);
135 for (
const auto &f : cell->face_indices())
138 bool face_is_clockwise_oriented =
142 if (cell->face_orientation(f) ==
false)
143 face_is_clockwise_oriented = !face_is_clockwise_oriented;
144 add_facet(cell->face(f), deal2cgal, mesh, face_is_clockwise_oriented);
150 template <
typename CGALPo
intType,
int dim,
int spacedim>
153 const ::Triangulation<dim, spacedim> &tria,
154 CGAL::Surface_mesh<CGALPointType> &mesh)
156 Assert(tria.n_cells() > 0,
158 "Triangulation cannot be empty upon calling this function."));
161 "The surface mesh must be empty upon calling this function."));
164 using Mesh = CGAL::Surface_mesh<CGALPointType>;
165 using Vertex_index =
typename Mesh::Vertex_index;
167 std::map<unsigned int, Vertex_index> deal2cgal;
168 if constexpr (dim == 2)
170 for (
const auto &cell : tria.active_cell_iterators())
172 map_vertices(cell, deal2cgal, mesh);
173 add_facet(cell, deal2cgal, mesh);
176 else if constexpr (dim == 3 && spacedim == 3)
178 for (
const auto &cell : tria.active_cell_iterators())
180 for (
const auto &f : cell->face_indices())
182 if (cell->face(f)->at_boundary())
184 map_vertices(cell->face(f), deal2cgal, mesh);
185 add_facet(cell->face(f),
188 (f % 2 == 0 || cell->n_vertices() != 8));
205# include "cgal/surface_mesh.inst"
Abstract base class for mapping classes.
virtual boost::container::small_vector< Point< spacedim >, ReferenceCells::max_n_vertices< dim >() > get_vertices(const typename Triangulation< dim, spacedim >::cell_iterator &cell) const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_ASSERT_UNREACHABLE()
static ::ExceptionBase & ExcImpossibleInDimSpacedim(int arg1, int arg2)
#define Assert(cond, exc)
static ::ExceptionBase & ExcImpossibleInDim(int arg1)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcMessage(std::string arg1)
void dealii_tria_to_cgal_surface_mesh(const ::Triangulation< dim, spacedim > &triangulation, CGAL::Surface_mesh< CGALPointType > &mesh)
void dealii_cell_to_cgal_surface_mesh(const typename ::Triangulation< dim, spacedim >::cell_iterator &cell, const ::Mapping< dim, spacedim > &mapping, CGAL::Surface_mesh< CGALPointType > &mesh)
constexpr ReferenceCell Triangle
constexpr ReferenceCell Hexahedron
constexpr ReferenceCell Quadrilateral
constexpr ReferenceCell Line