20#ifdef DEAL_II_WITH_CGAL
26 template <
typename dealiiFace,
typename CGAL_Mesh>
29 const dealiiFace & face,
30 const std::map<unsigned int, typename CGAL_Mesh::Vertex_index> &deal2cgal,
32 const bool clockwise_ordering =
true)
34 const auto reference_cell_type = face->reference_cell();
35 std::vector<typename CGAL_Mesh::Vertex_index> indices;
39 mesh.add_edge(deal2cgal.at(face->vertex_index(0)),
40 deal2cgal.at(face->vertex_index(1)));
44 indices = {deal2cgal.at(face->vertex_index(0)),
45 deal2cgal.at(face->vertex_index(1)),
46 deal2cgal.at(face->vertex_index(2))};
51 indices = {deal2cgal.at(face->vertex_index(0)),
52 deal2cgal.at(face->vertex_index(1)),
53 deal2cgal.at(face->vertex_index(3)),
54 deal2cgal.at(face->vertex_index(2))};
59 if (clockwise_ordering ==
true)
60 std::reverse(indices.begin(), indices.end());
62 [[maybe_unused]]
const auto new_face = mesh.add_face(indices);
63 Assert(new_face != mesh.null_face(),
65 "CGAL encountered a orientation problem that it "
66 "was not able to solve."));
71 template <
typename dealiiFace,
typename CGAL_Mesh>
74 const dealiiFace & cell,
75 std::map<unsigned int, typename CGAL_Mesh::Vertex_index> &deal2cgal,
78 for (
const auto i : cell->vertex_indices())
80 deal2cgal[cell->vertex_index(i)] = mesh.add_vertex(
81 CGALWrappers::dealii_point_to_cgal_point<typename CGAL_Mesh::Point>(
93 template <
typename CGALPo
intType,
int dim,
int spacedim>
98 CGAL::Surface_mesh<CGALPointType> & mesh)
101 using Mesh = CGAL::Surface_mesh<CGALPointType>;
103 std::map<unsigned int, typename Mesh::Vertex_index> deal2cgal;
107 for (
const auto &i : cell->vertex_indices())
108 deal2cgal[cell->vertex_index(i)] = mesh.add_vertex(
109 CGALWrappers::dealii_point_to_cgal_point<CGALPointType>(
vertices[i]));
114 add_facet(cell, deal2cgal, mesh);
131 for (
const auto &f : cell->face_indices())
134 bool face_is_clockwise_oriented =
138 if (cell->face_orientation(f) ==
false)
139 face_is_clockwise_oriented = !face_is_clockwise_oriented;
140 add_facet(cell->face(f), deal2cgal, mesh, face_is_clockwise_oriented);
146 template <
typename CGALPo
intType,
int dim,
int spacedim>
149 const ::Triangulation<dim, spacedim> &
tria,
150 CGAL::Surface_mesh<CGALPointType> & mesh)
154 "Triangulation cannot be empty upon calling this function."));
157 "The surface mesh must be empty upon calling this function."));
160 using Mesh = CGAL::Surface_mesh<CGALPointType>;
161 using Vertex_index =
typename Mesh::Vertex_index;
163 std::map<unsigned int, Vertex_index> deal2cgal;
164 if constexpr (dim == 2)
168 map_vertices(cell, deal2cgal, mesh);
169 add_facet(cell, deal2cgal, mesh);
172 else if constexpr (dim == 3 && spacedim == 3)
176 for (
const auto &f : cell->face_indices())
178 if (cell->face(f)->at_boundary())
180 map_vertices(cell->face(f), deal2cgal, mesh);
181 add_facet(cell->face(f),
184 (f % 2 == 0 || cell->n_vertices() != 8));
193# include "surface_mesh.inst"
Abstract base class for mapping classes.
virtual boost::container::small_vector< Point< spacedim >, GeometryInfo< dim >::vertices_per_cell > get_vertices(const typename Triangulation< dim, spacedim >::cell_iterator &cell) const
unsigned int n_cells() const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
IteratorRange< active_cell_iterator > active_cell_iterators() const
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 const ReferenceCell Quadrilateral
constexpr const ReferenceCell Triangle
constexpr const ReferenceCell Hexahedron
constexpr const ReferenceCell Line
const ::Triangulation< dim, spacedim > & tria