16#ifndef dealii_cgal_utilities_h
17#define dealii_cgal_utilities_h
25#ifdef DEAL_II_WITH_CGAL
30# include <boost/hana.hpp>
32# include <CGAL/Cartesian.h>
33# include <CGAL/Complex_2_in_triangulation_3.h>
34# include <CGAL/Exact_predicates_exact_constructions_kernel.h>
35# include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
36# include <CGAL/Kernel_traits.h>
37# include <CGAL/Mesh_complex_3_in_triangulation_3.h>
38# include <CGAL/Mesh_criteria_3.h>
39# include <CGAL/Mesh_triangulation_3.h>
43# include <CGAL/Polygon_mesh_processing/corefinement.h>
45# include <CGAL/Polygon_mesh_processing/measure.h>
46# include <CGAL/Polygon_mesh_processing/remesh.h>
47# include <CGAL/Polygon_mesh_processing/triangulate_faces.h>
48# include <CGAL/Polyhedral_mesh_domain_with_features_3.h>
49# include <CGAL/Simple_cartesian.h>
50# include <CGAL/Surface_mesh.h>
51# include <CGAL/Triangulation_3.h>
52# include <CGAL/boost/graph/copy_face_graph.h>
53# include <CGAL/boost/graph/selection.h>
54# include <CGAL/convex_hull_3.h>
55# include <CGAL/make_mesh_3.h>
56# include <CGAL/make_surface_mesh.h>
61# include <type_traits>
80# ifdef CGAL_CONCURRENT_MESH_3
141 template <
typename C3t3>
191 template <
typename CGALPo
intType>
210 template <
typename CGALTriangulationType>
213 const unsigned int degree);
230 template <
int dim0,
int dim1,
int spacedim>
233 const typename ::Triangulation<dim0, spacedim>::cell_iterator &
cell0,
234 const typename ::Triangulation<dim1, spacedim>::cell_iterator &
cell1,
235 const unsigned int degree,
238 (ReferenceCells::get_hypercube<dim0>()
241 (ReferenceCells::get_hypercube<dim1>()
259 template <
int dim0,
int dim1,
int spacedim>
262 const typename ::Triangulation<dim0, spacedim>::cell_iterator &
cell0,
263 const typename ::Triangulation<dim1, spacedim>::cell_iterator &
cell1,
264 const unsigned int degree,
296 template <
typename CGALPo
intType>
306 template <
typename C3t3>
315 ExcMessage(
"The surface mesh must be closed."));
317 using K =
typename CGAL::Kernel_traits<CGALPointType>::Kernel;
321 using Tr =
typename CGAL::
322 Mesh_triangulation_3<Mesh_domain, CGAL::Default, ConcurrencyTag>::type;
325 CGAL::Polygon_mesh_processing::triangulate_faces(
surface_mesh);
329 CGAL::parameters::facet_angle = data.facet_angle,
330 CGAL::parameters::facet_distance =
332 CGAL::parameters::cell_radius_edge_ratio =
333 data.cell_radius_edge_ratio,
334 CGAL::parameters::cell_size = data.cell_size);
338 CGAL::parameters::no_perturb(),
339 CGAL::parameters::no_exude());
344 template <
typename CGALPo
intType>
354 "output_surface_mesh must be empty upon calling this function"));
357 "The input surface_mesh_1 must be a closed surface mesh."));
360 "The input surface_mesh_2 must be a closed surface mesh."));
362 ExcMessage(
"The first CGAL mesh must be triangulated."));
364 ExcMessage(
"The second CGAL mesh must be triangulated."));
399 ExcMessage(
"The boolean operation was not successfully computed."));
404 template <
typename CGALTriangulationType>
407 const unsigned int degree)
410 Assert(CGALTriangulationType::Point::Ambient_dimension::value == 3,
413 ExcMessage(
"The degree of the Quadrature formula is not positive."));
415 constexpr int spacedim =
416 CGALTriangulationType::Point::Ambient_dimension::value;
417 std::vector<std::array<::Point<spacedim>, spacedim + 1>>
420 std::array<::Point<spacedim>, spacedim + 1>
simplex;
423 for (
unsigned int i = 0; i < (spacedim + 1); ++i)
437 template <
int dim0,
int dim1,
int spacedim>
440 const typename ::Triangulation<dim0, spacedim>::cell_iterator &
cell0,
441 const typename ::Triangulation<dim1, spacedim>::cell_iterator &
cell1,
442 const unsigned int degree,
474 CGAL::Polygon_mesh_processing::triangulate_faces(
surface_1);
475 CGAL::Polygon_mesh_processing::triangulate_faces(
surface_2);
478 ExcMessage(
"The surface must be a triangle mesh."));
489 template <
int dim0,
int dim1,
int spacedim>
492 const typename ::Triangulation<dim0, spacedim>::cell_iterator &
cell0,
493 const typename ::Triangulation<dim1, spacedim>::cell_iterator &
cell1,
494 const unsigned int degree,
508 CGAL::Polygon_mesh_processing::triangulate_faces(
surface_1);
509 CGAL::Polygon_mesh_processing::triangulate_faces(
surface_2);
526 template <
typename CGALPo
intType>
534 using Polyhedron = CGAL::Mesh_polyhedron_3<K>::type;
536 using Tr = CGAL::Mesh_triangulation_3<Mesh_domain>::type;
558 if (data.edge_size > 0 &&
562 CGAL::parameters::facet_size = data.facet_size,
563 CGAL::parameters::facet_angle = data.facet_angle,
564 CGAL::parameters::facet_distance =
566 CGAL::parameters::cell_radius_edge_ratio =
567 data.cell_radius_edge_ratio,
568 CGAL::parameters::cell_size = data.cell_size);
572 CGAL::parameters::no_perturb(),
573 CGAL::parameters::no_exude());
580 CGAL::parameters::facet_angle = data.facet_angle,
581 CGAL::parameters::facet_distance =
583 CGAL::parameters::cell_radius_edge_ratio =
584 data.cell_radius_edge_ratio,
585 CGAL::parameters::cell_size = data.cell_size);
589 CGAL::parameters::no_perturb(),
590 CGAL::parameters::no_exude());
608 template <
int spacedim>
627 template <
int dim,
int spacedim>
628 std::vector<Point<spacedim>>
630 const typename ::Triangulation<dim, spacedim>::cell_iterator &cell,
634 const unsigned int n_vertices = cell->n_vertices();
635 Assert((n_vertices == ReferenceCells::get_hypercube<dim>().n_vertices()) ||
636 (n_vertices == ReferenceCells::get_simplex<dim>().n_vertices()),
640 std::copy_n(mapping.get_vertices(cell).
begin(),
659 template <
int dim,
int spacedim>
660 std::vector<Point<spacedim>>
662 const typename ::Triangulation<dim, spacedim>::cell_iterator &cell,
667 const unsigned int n_vertices = cell->face(
face_no)->n_vertices();
669 (n_vertices == ReferenceCells::get_hypercube<dim - 1>().n_vertices()) ||
670 (n_vertices == ReferenceCells::get_simplex<dim - 1>().n_vertices()),
674 std::copy_n(mapping.get_vertices(cell,
face_no).
begin(),
static ReferenceCell n_vertices_to_type(const int dim, const unsigned int n_vertices)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
#define DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcMessage(std::string arg1)
void remesh_surface(CGAL::Surface_mesh< CGALPointType > &surface_mesh, const AdditionalData< 3 > &data=AdditionalData< 3 >{})
::Quadrature< CGALTriangulationType::Point::Ambient_dimension::value > compute_quadrature(const CGALTriangulationType &tria, const unsigned int degree)
CGAL::Sequential_tag ConcurrencyTag
::Quadrature< spacedim > compute_quadrature_on_boolean_operation(const typename ::Triangulation< dim0, spacedim >::cell_iterator &cell0, const typename ::Triangulation< dim1, spacedim >::cell_iterator &cell1, const unsigned int degree, const BooleanOperation &bool_op, const Mapping< dim0, spacedim > &mapping0=(ReferenceCells::get_hypercube< dim0 >() .template get_default_linear_mapping< dim0, spacedim >()), const Mapping< dim1, spacedim > &mapping1=(ReferenceCells::get_hypercube< dim1 >() .template get_default_linear_mapping< dim1, spacedim >()))
void cgal_surface_mesh_to_cgal_triangulation(CGAL::Surface_mesh< typename C3t3::Point::Point > &surface_mesh, C3t3 &triangulation, const AdditionalData< 3 > &data=AdditionalData< 3 >{})
CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt K
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)
void compute_boolean_operation(const CGAL::Surface_mesh< CGALPointType > &surface_mesh_1, const CGAL::Surface_mesh< CGALPointType > &surface_mesh_2, const BooleanOperation &boolean_operation, CGAL::Surface_mesh< CGALPointType > &output_surface_mesh)
::Quadrature< spacedim > compute_quadrature_on_intersection(const typename ::Triangulation< dim0, spacedim >::cell_iterator &cell0, const typename ::Triangulation< dim1, spacedim >::cell_iterator &cell1, const unsigned int degree, const Mapping< dim0, spacedim > &mapping0, const Mapping< dim1, spacedim > &mapping1)
void simplex(Triangulation< dim, dim > &tria, const std::vector< Point< dim > > &vertices)
constexpr const ReferenceCell Quadrilateral
::VectorizedArray< Number, width > abs(const ::VectorizedArray< Number, width > &)
const ::parallel::distributed::Triangulation< dim, spacedim > * triangulation
const ::Triangulation< dim, spacedim > & tria