22#ifdef DEAL_II_WITH_CGAL
33# include <CGAL/Boolean_set_operations_2.h>
34# include <CGAL/Cartesian.h>
35# include <CGAL/Circular_kernel_intersections.h>
36# include <CGAL/Constrained_Delaunay_triangulation_2.h>
37# include <CGAL/Delaunay_mesh_face_base_2.h>
38# include <CGAL/Delaunay_mesh_size_criteria_2.h>
39# include <CGAL/Delaunay_mesher_2.h>
40# include <CGAL/Delaunay_triangulation_2.h>
41# include <CGAL/Exact_predicates_exact_constructions_kernel_with_sqrt.h>
42# include <CGAL/Kernel_traits.h>
43# include <CGAL/Polygon_2.h>
44# include <CGAL/Polygon_with_holes_2.h>
45# include <CGAL/Projection_traits_xy_3.h>
46# include <CGAL/Segment_3.h>
47# include <CGAL/Simple_cartesian.h>
48# include <CGAL/Tetrahedron_3.h>
49# include <CGAL/Triangle_2.h>
50# include <CGAL/Triangle_3.h>
51# include <CGAL/Triangulation_2.h>
52# include <CGAL/Triangulation_3.h>
53# include <CGAL/Triangulation_face_base_with_id_2.h>
54# include <CGAL/Triangulation_face_base_with_info_2.h>
58# include <type_traits>
115 template <
typename TargetVariant>
116 struct Repackage : boost::static_visitor<TargetVariant>
118 template <
typename T>
120 operator()(
const T &t)
const
132 template <
typename... Types>
133 std_cxx17::optional<std_cxx17::variant<Types...>>
161 std::list<CDT::Edge> &
border)
163 if (start->info().nesting_level != -1)
167 std::list<Face_handle> queue;
168 queue.push_back(start);
169 while (!queue.empty())
173 if (
fh->info().nesting_level == -1)
175 fh->info().nesting_level = index;
176 for (
int i = 0; i < 3; i++)
180 if (n->info().nesting_level == -1)
182 if (
ct.is_constrained(e))
197 for (CDT::Face_handle f :
cdt.all_face_handles())
199 f->info().nesting_level = -1;
201 std::list<CDT::Edge>
border;
205 CDT::Edge e =
border.front();
208 if (n->info().nesting_level == -1)
224 std_cxx17::optional<std_cxx17::variant<
CGALPoint2,
227 std::vector<CGALPoint2>>>
235 std::array<CGALPoint2, 3>
pts0,
pts1;
240 &CGALWrappers::dealii_point_to_cgal_point<CGALPoint2, 2>);
245 &CGALWrappers::dealii_point_to_cgal_point<CGALPoint2, 2>);
254 std_cxx17::optional<std_cxx17::variant<CGALPoint2, CGALSegment2>>
262 std::array<CGALPoint2, 3>
pts0;
263 std::array<CGALPoint2, 2>
pts1;
268 &CGALWrappers::dealii_point_to_cgal_point<CGALPoint2, 2>);
273 &CGALWrappers::dealii_point_to_cgal_point<CGALPoint2, 2>);
284 std::vector<Polygon_with_holes_2>
291 std::array<CGALPoint2, 4>
pts0,
pts1;
296 &CGALWrappers::dealii_point_to_cgal_point<CGALPoint2, 2>);
301 &CGALWrappers::dealii_point_to_cgal_point<CGALPoint2, 2>);
306 std::vector<Polygon_with_holes_2>
poly_list;
315 std_cxx17::optional<std_cxx17::variant<CGALPoint3, CGALSegment3>>
320# if DEAL_II_CGAL_VERSION_GTE(5, 5, 0)
325 std::array<CGALPoint3, 4>
pts0;
326 std::array<CGALPoint3, 2>
pts1;
331 &CGALWrappers::dealii_point_to_cgal_point<CGALPoint3, 3>);
336 &CGALWrappers::dealii_point_to_cgal_point<CGALPoint3, 3>);
346 "This function requires a version of CGAL greater or equal than 5.5."));
355 std_cxx17::optional<std_cxx17::variant<
CGALPoint3,
358 std::vector<CGALPoint3>>>
363# if DEAL_II_CGAL_VERSION_GTE(5, 5, 0)
368 std::array<CGALPoint3, 4>
pts0;
369 std::array<CGALPoint3, 3>
pts1;
374 &CGALWrappers::dealii_point_to_cgal_point<CGALPoint3, 3>);
379 &CGALWrappers::dealii_point_to_cgal_point<CGALPoint3, 3>);
390 "This function requires a version of CGAL greater or equal than 5.5."));
398 std::vector<std::array<Point<2>, 3>>
418 {{CGALWrappers::cgal_point_to_dealii_point<2>(poly.vertex(0)),
419 CGALWrappers::cgal_point_to_dealii_point<2>(poly.vertex(1)),
420 CGALWrappers::cgal_point_to_dealii_point<2>(
426 std::vector<std::array<Point<2>, 3>>
collection;
429 cdt.insert_constraint(poly.vertices_begin(),
438 if (f->info().in_domain() &&
442 {{CGALWrappers::cgal_point_to_dealii_point<2>(
443 cdt.triangle(f).vertex(0)),
444 CGALWrappers::cgal_point_to_dealii_point<2>(
445 cdt.triangle(f).vertex(1)),
446 CGALWrappers::cgal_point_to_dealii_point<2>(
447 cdt.triangle(f).vertex(2))}});
465 std::vector<std::array<Point<2>, 2>>
473 std::array<CGALPoint2, 4>
pts;
475 std::transform(quad.begin(),
478 &CGALWrappers::dealii_point_to_cgal_point<CGALPoint2, 2>);
483 CGALWrappers::dealii_point_to_cgal_point<CGALPoint2>(line[0]),
484 CGALWrappers::dealii_point_to_cgal_point<CGALPoint2>(line[1]));
486 cdt.insert_constraint(poly.vertices_begin(), poly.vertices_end(),
true);
487 std::vector<std::array<Point<2>, 2>>
vertices;
491 if (f->info().in_domain() &&
501 {{CGALWrappers::cgal_point_to_dealii_point<2>((*s)[0]),
502 CGALWrappers::cgal_point_to_dealii_point<2>((*s)[1])}});
511 std::vector<std::array<Point<3>, 2>>
516# if DEAL_II_CGAL_VERSION_GTE(5, 5, 0)
521 std::array<CGALPoint3_exact, 8>
pts;
527 &CGALWrappers::dealii_point_to_cgal_point<CGALPoint3_exact, 3>);
530 CGALWrappers::dealii_point_to_cgal_point<CGALPoint3_exact>(line[0]),
531 CGALWrappers::dealii_point_to_cgal_point<CGALPoint3_exact>(line[1]));
535 std::vector<std::array<Point<3>, 2>>
vertices;
548 if (s->squared_length() > tol * tol)
551 {{CGALWrappers::cgal_point_to_dealii_point<3>(
553 CGALWrappers::cgal_point_to_dealii_point<3>(
564 "This function requires a version of CGAL greater or equal than 5.5."));
572 std::vector<std::array<Point<3>, 3>>
577# if DEAL_II_CGAL_VERSION_GTE(5, 5, 0)
582 std::array<CGALPoint3_exact, 8>
pts_hex;
583 std::array<CGALPoint3_exact, 4>
pts_quad;
589 &CGALWrappers::dealii_point_to_cgal_point<CGALPoint3_exact, 3>);
595 &CGALWrappers::dealii_point_to_cgal_point<CGALPoint3_exact, 3>);
598 std::vector<std::array<Point<3>, 3>>
vertices;
629 if (
const std::vector<CGALPoint3_exact> *
vps =
630 boost::get<std::vector<CGALPoint3_exact>>(
644 std::array<Point<3>, 3>
verts = {
645 {CGALWrappers::cgal_point_to_dealii_point<3>(
647 CGALWrappers::cgal_point_to_dealii_point<3>(
649 CGALWrappers::cgal_point_to_dealii_point<3>(
665 "This function requires a version of CGAL greater or equal than 5.5."));
673 std::vector<std::array<Point<3>, 4>>
681 std::array<CGALPoint3_exact, 8>
pts_hex0;
682 std::array<CGALPoint3_exact, 8>
pts_hex1;
688 &CGALWrappers::dealii_point_to_cgal_point<CGALPoint3_exact, 3>);
694 &CGALWrappers::dealii_point_to_cgal_point<CGALPoint3_exact, 3>);
698 std::vector<std::array<Point<3>, 4>>
vertices;
704 for (
const auto &
c0 :
tria0.finite_cell_handles())
713 for (
const auto &
c1 :
tria1.finite_cell_handles())
735 {{CGALWrappers::cgal_point_to_dealii_point<3>(
737 CGALWrappers::cgal_point_to_dealii_point<3>(
739 CGALWrappers::cgal_point_to_dealii_point<3>(
741 CGALWrappers::cgal_point_to_dealii_point<3>(
756 template <
int dim0,
int dim1,
int spacedim>
757 std::vector<std::array<Point<spacedim>,
dim1 + 1>>
769 "The intersection cannot be computed as at least one of the two cells has no vertices."));
771 if constexpr (
dim0 == 2 &&
dim1 == 2 && spacedim == 2)
780 else if constexpr (
dim0 == 2 &&
dim1 == 1 && spacedim == 2)
789 else if constexpr (
dim0 == 3 &&
dim1 == 1 && spacedim == 3)
798 else if constexpr (
dim0 == 3 &&
dim1 == 2 && spacedim == 3)
807 else if constexpr (
dim0 == 3 &&
dim1 == 3 && spacedim == 3)
826 template <
int dim0,
int dim1,
int spacedim>
827 std::vector<std::array<Point<spacedim>,
dim1 + 1>>
836 ReferenceCells::get_hypercube<dim0>().n_vertices(),
839 ReferenceCells::get_hypercube<dim1>().n_vertices(),
852# include "intersections.inst"
867std::vector<std::array<Point<spacedim>,
dim1 + 1>>
879template <
int dim0,
int dim1,
int spacedim>
880std::vector<std::array<Point<spacedim>,
dim1 + 1>>
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcNeedsCGAL()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
std_cxx17::optional< std_cxx17::variant< CGALPoint2, CGALSegment2, CGALTriangle2, std::vector< CGALPoint2 > > > compute_intersection_triangle_triangle(const ArrayView< const Point< 2 > > &triangle0, const ArrayView< const Point< 2 > > &triangle1)
std::vector< std::array< Point< 2 >, 2 > > compute_intersection_quad_line(const ArrayView< const Point< 2 > > &quad, const ArrayView< const Point< 2 > > &line, const double tol)
std::vector< std::array< Point< 3 >, 3 > > compute_intersection_hexa_quad(const ArrayView< const Point< 3 > > &hexa, const ArrayView< const Point< 3 > > &quad, const double tol)
void mark_domains(CDT &ct, Face_handle start, int index, std::list< CDT::Edge > &border)
std_cxx17::optional< std_cxx17::variant< CGALPoint3, CGALSegment3, CGALTriangle3, std::vector< CGALPoint3 > > > compute_intersection_tetra_triangle(const ArrayView< const Point< 3 > > &tetrahedron, const ArrayView< const Point< 3 > > &triangle)
std_cxx17::optional< std_cxx17::variant< CGALPoint2, CGALSegment2 > > compute_intersection_triangle_segment(const ArrayView< const Point< 2 > > &triangle, const ArrayView< const Point< 2 > > &segment)
std::vector< Polygon_with_holes_2 > compute_intersection_rect_rect(const ArrayView< const Point< 2 > > &rectangle0, const ArrayView< const Point< 2 > > &rectangle1)
std::vector< std::array< Point< 3 >, 4 > > compute_intersection_hexa_hexa(const ArrayView< const Point< 3 > > &hexa0, const ArrayView< const Point< 3 > > &hexa1, const double tol)
std::vector< std::array< Point< 3 >, 2 > > compute_intersection_hexa_line(const ArrayView< const Point< 3 > > &hexa, const ArrayView< const Point< 3 > > &line, const double tol)
std_cxx17::optional< std_cxx17::variant< CGALPoint3, CGALSegment3 > > compute_intersection_tetra_segment(const ArrayView< const Point< 3 > > &tetrahedron, const ArrayView< const Point< 3 > > &segment)
std::vector< std::array< Point< 2 >, 3 > > compute_intersection_quad_quad(const ArrayView< const Point< 2 > > &quad0, const ArrayView< const Point< 2 > > &quad1, const double tol)
K::Tetrahedron_3 CGALTetra
CGAL::Surface_mesh< K_exact::Point_3 > Surface_mesh
K::Segment_2 CGALSegment2
CGAL::Exact_predicates_tag Itag
K_exact::Tetrahedron_3 CGALTetra_exact
K_exact::Triangle_3 CGALTriangle3_exact
CDT::Vertex_handle Vertex_handle
K::Triangle_3 CGALTriangle3
K::Segment_3 CGALSegment3
CDT::Face_handle Face_handle
CGAL::Triangulation_3< K_exact > Triangulation3_exact
CGAL::Constrained_Delaunay_triangulation_2< K, Tds, Itag > CDT
CGAL::Delaunay_mesh_size_criteria_2< CDT > Criteria
CGAL::Triangulation_vertex_base_2< K > Vb
CGAL::Polygon_with_holes_2< K > Polygon_with_holes_2
CGAL::Triangulation_data_structure_2< Vb, Fb > Tds
std::vector< std::array< Point< spacedim >, dim1+1 > > compute_intersection_of_cells(const typename Triangulation< dim0, spacedim >::cell_iterator &cell0, const typename Triangulation< dim1, spacedim >::cell_iterator &cell1, const Mapping< dim0, spacedim > &mapping0, const Mapping< dim1, spacedim > &mapping1, const double tol=1e-9)
CGAL::Polygon_2< K > CGALPolygon
CGAL::Triangulation_2< K > Triangulation2
CGAL::Exact_predicates_exact_constructions_kernel K_exact
CGAL::Triangulation_3< K > Triangulation3
CGAL::Constrained_triangulation_face_base_2< K, Fbb > CFb
CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt K
K::Triangle_2 CGALTriangle2
CGAL::Delaunay_mesh_face_base_2< K, CFb > Fb
K_exact::Segment_3 CGALSegment3_exact
K_exact::Point_3 CGALPoint3_exact
CGAL::Triangulation_face_base_with_info_2< FaceInfo2, K > Fbb