16#ifndef dealii_cgal_triangulation_h
17#define dealii_cgal_triangulation_h
28#ifdef DEAL_II_WITH_CGAL
30# include <boost/hana.hpp>
32# include <CGAL/Complex_2_in_triangulation_3.h>
33# include <CGAL/IO/facets_in_complex_2_to_triangle_mesh.h>
34# include <CGAL/Implicit_surface_3.h>
35# include <CGAL/Labeled_mesh_domain_3.h>
36# include <CGAL/Mesh_complex_3_in_triangulation_3.h>
37# include <CGAL/Mesh_criteria_3.h>
38# include <CGAL/Mesh_triangulation_3.h>
39# include <CGAL/Polyhedron_3.h>
40# include <CGAL/Surface_mesh.h>
41# include <CGAL/Surface_mesh_default_triangulation_3.h>
42# include <CGAL/Triangulation_2.h>
43# include <CGAL/Triangulation_3.h>
44# include <CGAL/make_mesh_3.h>
45# include <CGAL/make_surface_mesh.h>
82 template <
int spacedim,
typename CGALTriangulation>
118 template <
typename CGALTriangulation,
int dim,
int spacedim>
179 template <
typename CGAL_MeshType>
188 template <
int spacedim,
typename CGALTriangulation>
195 "The triangulation you pass to this function should be a valid "
196 "CGAL triangulation."));
198 std::vector<typename CGALTriangulation::Point>
cgal_points(points.size());
199 std::transform(points.begin(),
203 return CGALWrappers::dealii_point_to_cgal_point<
204 typename CGALTriangulation::Point>(p);
210 "The Triangulation is no longer valid after inserting the points. "
233 std::map<typename C3T3::Vertex_handle, unsigned int>
236 std::size_t
inum = 0;
241 if (
vit->in_dimension() <= -1)
245 CGALWrappers::cgal_point_to_dealii_point<3>(
vit->point()));
249 std::vector<CellData<3>> cells;
255 for (
unsigned int i = 0; i < 4; ++i)
258 cells.push_back(cell);
263 if constexpr (std::is_integral<typename C3T3::Surface_patch_index>::value)
275 for (
int i = 0; i < 4; ++i)
286 if constexpr (std::is_integral<typename C3T3::Curve_index>::value)
312 template <
typename CGALTriangulation,
int dim,
int spacedim>
319 ExcMessage(
"The dimension of the input CGAL triangulation (" +
321 ") does not match the dimension of the output "
322 "deal.II triangulation (" +
323 std::to_string(dim) +
")."));
326 ExcMessage(
"The output triangulation object needs to be empty."));
329 std::vector<Point<spacedim>>
vertices(
331 std::vector<CellData<dim>> cells;
335 std::map<typename CGALTriangulation::Vertex_handle, unsigned int>
342 CGALWrappers::cgal_point_to_dealii_point<spacedim>(v->point());
347 const auto has_faces = boost::hana::is_valid(
348 [](
auto &&
obj) ->
decltype(
obj.finite_face_handles()) {});
350 const auto has_cells = boost::hana::is_valid(
351 [](
auto &&
obj) ->
decltype(
obj.finite_cell_handles()) {});
361 for (
unsigned int i = 0;
365 cells.push_back(cell);
373 const auto & f =
e.first;
374 const auto & i =
e.second;
382 for (
unsigned int j = 0;
387 cells.push_back(cell);
401 for (
unsigned int i = 0;
405 cells.push_back(cell);
413 const auto & c =
facet.first;
414 const auto & i =
facet.second;
422 for (
unsigned int j = 0;
427 cells.push_back(cell);
434 const auto &[c, i,
j] =
edge;
438 cells.push_back(cell);
450 template <
typename CGAL_MeshType>
457 "Triangulation must be empty upon calling this function."));
460 boost::hana::is_valid([](
auto &&
obj) ->
decltype(
obj.faces()) {});
463 boost::hana::is_valid([](
auto &&
obj) ->
decltype(
obj.facets_begin()) {});
467 std::vector<CellData<2>> cells;
476 std::map<typename CGAL_MeshType::Vertex_index, unsigned int>
vertex_map;
481 vertices.emplace_back(CGALWrappers::cgal_point_to_dealii_point<3>(
488 for (
const auto &face :
cgal_mesh.faces())
494 ExcMessage(
"Only triangle or quadrilateral surface "
495 "meshes are supported in deal.II"));
504 std::swap(c.vertices[3], c.vertices[2]);
506 cells.emplace_back(c);
522 CGALWrappers::cgal_point_to_dealii_point<3>(
it->point()));
528 for (
auto face =
cgal_mesh.facets_begin();
532 auto j = face->facet_begin();
534 AssertThrow(vertices_per_face == 3 || vertices_per_face == 4,
535 ExcMessage(
"Only triangle or quadrilateral surface "
536 "meshes are supported in deal.II. You "
537 "tried to read a mesh where a face has " +
538 std::to_string(vertices_per_face) +
539 " vertices per face."));
543 for (
unsigned int i = 0; i < vertices_per_face; ++i)
549 if (vertices_per_face == 4)
550 std::swap(c.vertices[3], c.vertices[2]);
552 cells.emplace_back(c);
559 "Unsupported CGAL surface triangulation type."));
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
constexpr const ReferenceCell Tetrahedron
constexpr const ReferenceCell Triangle
constexpr const ReferenceCell Line
const ::parallel::distributed::Triangulation< dim, spacedim > * triangulation