deal.II version 9.8.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
point_conversion.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2022 - 2026 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13#ifndef dealii_cgal_point_conversion_h
14#define dealii_cgal_point_conversion_h
15
16#include <deal.II/base/config.h>
17
18#include <deal.II/base/point.h>
19
20#ifdef DEAL_II_WITH_CGAL
21
22# include <CGAL/version.h>
23# if CGAL_VERSION_MAJOR >= 6
24# include <CGAL/Installation/internal/disable_deprecation_warnings_and_errors.h>
25# endif
26# include <CGAL/Cartesian.h>
27# include <CGAL/Exact_predicates_exact_constructions_kernel.h>
28# include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
29# include <CGAL/Simple_cartesian.h>
30
31#endif
32
34
35#ifdef DEAL_II_WITH_CGAL
36namespace CGALWrappers
37{
46 template <typename CGALPointType, int dim>
47 inline CGALPointType
48 dealii_point_to_cgal_point(const ::Point<dim> &p);
49
58 template <int dim, typename CGALPointType>
59 inline ::Point<dim>
60 cgal_point_to_dealii_point(const CGALPointType &p);
61
62
63# ifndef DOXYGEN
64 // Template implementations
65
66 template <typename CGALPointType, int dim>
67 inline CGALPointType
68 dealii_point_to_cgal_point(const ::Point<dim> &p)
69 {
70 constexpr int cdim = CGALPointType::Ambient_dimension::value;
71 static_assert(dim <= cdim, "Only dim <= cdim supported");
72 if constexpr (cdim == 1)
73 return CGALPointType(p[0]);
74 else if constexpr (cdim == 2)
75 return CGALPointType(p[0], dim > 1 ? p[1] : 0);
76 else if constexpr (cdim == 3)
77 return CGALPointType(p[0], dim > 1 ? p[1] : 0, dim > 2 ? p[2] : 0);
78 else
80 return CGALPointType();
81 }
82
83
84
85 template <int dim, typename CGALPointType>
86 inline ::Point<dim>
87 cgal_point_to_dealii_point(const CGALPointType &p)
88 {
89 constexpr int cdim = CGALPointType::Ambient_dimension::value;
90 if constexpr (dim == 1)
91 return ::Point<dim>(CGAL::to_double(p.x()));
92 else if constexpr (dim == 2)
93 return ::Point<dim>(CGAL::to_double(p.x()),
94 cdim > 1 ? CGAL::to_double(p.y()) : 0);
95 else if constexpr (dim == 3)
96 return ::Point<dim>(CGAL::to_double(p.x()),
97 cdim > 1 ? CGAL::to_double(p.y()) : 0,
98 cdim > 2 ? CGAL::to_double(p.z()) : 0);
99 else
101 }
102} // namespace CGALWrappers
103
104# endif
105
106#endif
107
109#endif
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
#define DEAL_II_NOT_IMPLEMENTED()