deal.II version GIT relicensing-2169-gec1b43f35b 2024-11-22 07:10:00+00:00
\(\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: LGPL-2.1-or-later
4// Copyright (C) 2022 - 2024 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_cgal_point_conversion_h
16#define dealii_cgal_point_conversion_h
17
18#include <deal.II/base/config.h>
19
20#include <deal.II/base/point.h>
21
22#ifdef DEAL_II_WITH_CGAL
23
24# include <CGAL/Cartesian.h>
25# include <CGAL/Exact_predicates_exact_constructions_kernel.h>
26# include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
27# include <CGAL/Simple_cartesian.h>
28
29
31namespace CGALWrappers
32{
41 template <typename CGALPointType, int dim>
42 inline CGALPointType
43 dealii_point_to_cgal_point(const ::Point<dim> &p);
44
53 template <int dim, typename CGALPointType>
54 inline ::Point<dim>
55 cgal_point_to_dealii_point(const CGALPointType &p);
56
57
58# ifndef DOXYGEN
59 // Template implementations
60
61 template <typename CGALPointType, int dim>
62 inline CGALPointType
63 dealii_point_to_cgal_point(const ::Point<dim> &p)
64 {
65 constexpr int cdim = CGALPointType::Ambient_dimension::value;
66 static_assert(dim <= cdim, "Only dim <= cdim supported");
67 if constexpr (cdim == 1)
68 return CGALPointType(p[0]);
69 else if constexpr (cdim == 2)
70 return CGALPointType(p[0], dim > 1 ? p[1] : 0);
71 else if constexpr (cdim == 3)
72 return CGALPointType(p[0], dim > 1 ? p[1] : 0, dim > 2 ? p[2] : 0);
73 else
75 return CGALPointType();
76 }
77
78
79
80 template <int dim, typename CGALPointType>
81 inline ::Point<dim>
82 cgal_point_to_dealii_point(const CGALPointType &p)
83 {
84 constexpr int cdim = CGALPointType::Ambient_dimension::value;
85 if constexpr (dim == 1)
86 return ::Point<dim>(CGAL::to_double(p.x()));
87 else if constexpr (dim == 2)
88 return ::Point<dim>(CGAL::to_double(p.x()),
89 cdim > 1 ? CGAL::to_double(p.y()) : 0);
90 else if constexpr (dim == 3)
91 return ::Point<dim>(CGAL::to_double(p.x()),
92 cdim > 1 ? CGAL::to_double(p.y()) : 0,
93 cdim > 2 ? CGAL::to_double(p.z()) : 0);
94 else
96 }
97} // namespace CGALWrappers
98
99# endif
100
102
103#endif
104#endif
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:498
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:499
#define DEAL_II_NOT_IMPLEMENTED()