19#ifdef DEAL_II_WITH_CGAL
25 template <
typename dealiiFace,
typename CGAL_Mesh>
28 const dealiiFace &face,
29 const std::map<unsigned int, typename CGAL_Mesh::Vertex_index> &deal2cgal,
31 const bool clockwise_ordering =
true)
33 const auto reference_cell_type = face->reference_cell();
34 std::vector<typename CGAL_Mesh::Vertex_index> indices;
38 mesh.add_edge(deal2cgal.at(face->vertex_index(0)),
39 deal2cgal.at(face->vertex_index(1)));
43 indices = {deal2cgal.at(face->vertex_index(0)),
44 deal2cgal.at(face->vertex_index(1)),
45 deal2cgal.at(face->vertex_index(2))};
50 indices = {deal2cgal.at(face->vertex_index(0)),
51 deal2cgal.at(face->vertex_index(1)),
52 deal2cgal.at(face->vertex_index(3)),
53 deal2cgal.at(face->vertex_index(2))};
58 if (clockwise_ordering ==
true)
59 std::reverse(indices.begin(), indices.end());
61 [[maybe_unused]]
const auto new_face = mesh.add_face(indices);
62 Assert(new_face != mesh.null_face(),
64 "CGAL encountered a orientation problem that it "
65 "was not able to solve."));
70 template <
typename dealiiFace,
typename CGAL_Mesh>
73 const dealiiFace &cell,
74 std::map<unsigned int, typename CGAL_Mesh::Vertex_index> &deal2cgal,
79 deal2cgal[cell->vertex_index(i)] = mesh.add_vertex(
80 CGALWrappers::dealii_point_to_cgal_point<typename CGAL_Mesh::Point>(
92 template <
typename CGALPo
intType,
int dim,
int spacedim>
97 CGAL::Surface_mesh<CGALPointType> &mesh)
100 using Mesh = CGAL::Surface_mesh<CGALPointType>;
102 std::map<unsigned int, typename Mesh::Vertex_index> deal2cgal;
107 deal2cgal[cell->vertex_index(i)] = mesh.add_vertex(
108 CGALWrappers::dealii_point_to_cgal_point<CGALPointType>(vertices[i]));
113 add_facet(cell, deal2cgal, mesh);
130 for (
const auto &f : cell->face_indices())
133 bool face_is_clockwise_oriented =
137 if (cell->face_orientation(f) ==
false)
138 face_is_clockwise_oriented = !face_is_clockwise_oriented;
139 add_facet(cell->face(f), deal2cgal, mesh, face_is_clockwise_oriented);
145 template <
typename CGALPo
intType,
int dim,
int spacedim>
148 const ::Triangulation<dim, spacedim> &tria,
149 CGAL::Surface_mesh<CGALPointType> &mesh)
151 Assert(tria.n_cells() > 0,
153 "Triangulation cannot be empty upon calling this function."));
156 "The surface mesh must be empty upon calling this function."));
159 using Mesh = CGAL::Surface_mesh<CGALPointType>;
160 using Vertex_index =
typename Mesh::Vertex_index;
162 std::map<unsigned int, Vertex_index> deal2cgal;
163 if constexpr (dim == 2)
165 for (
const auto &cell : tria.active_cell_iterators())
167 map_vertices(cell, deal2cgal, mesh);
168 add_facet(cell, deal2cgal, mesh);
171 else if constexpr (dim == 3 && spacedim == 3)
173 for (
const auto &cell : tria.active_cell_iterators())
175 for (
const auto &f : cell->face_indices())
177 if (cell->face(f)->at_boundary())
179 map_vertices(cell->face(f), deal2cgal, mesh);
180 add_facet(cell->face(f),
183 (f % 2 == 0 || cell->n_vertices() != 8));
192# 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
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
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)
#define DEAL_II_ASSERT_UNREACHABLE()
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