Reference documentation for deal.II version 9.5.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// Copyright (C) 2022 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.md at
12// the top level directory of deal.II.
13//
14// ---------------------------------------------------------------------
15
16#ifndef dealii_cgal_point_conversion_h
17#define dealii_cgal_point_conversion_h
18
19#include <deal.II/base/config.h>
20
21#include <deal.II/base/point.h>
22
23#ifdef DEAL_II_WITH_CGAL
24
25# include <CGAL/Cartesian.h>
26# include <CGAL/Exact_predicates_exact_constructions_kernel.h>
27# include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
28# include <CGAL/Simple_cartesian.h>
29
30
32namespace CGALWrappers
33{
42 template <typename CGALPointType, int dim>
43 inline CGALPointType
44 dealii_point_to_cgal_point(const ::Point<dim> &p);
45
54 template <int dim, typename CGALPointType>
55 inline ::Point<dim>
56 cgal_point_to_dealii_point(const CGALPointType &p);
57
58
59# ifndef DOXYGEN
60 // Template implementations
61
62 template <typename CGALPointType, int dim>
63 inline CGALPointType
64 dealii_point_to_cgal_point(const ::Point<dim> &p)
65 {
66 constexpr int cdim = CGALPointType::Ambient_dimension::value;
67 static_assert(dim <= cdim, "Only dim <= cdim supported");
68 if constexpr (cdim == 1)
69 return CGALPointType(p[0]);
70 else if constexpr (cdim == 2)
71 return CGALPointType(p[0], dim > 1 ? p[1] : 0);
72 else if constexpr (cdim == 3)
73 return CGALPointType(p[0], dim > 1 ? p[1] : 0, dim > 2 ? p[2] : 0);
74 else
76 return CGALPointType();
77 }
78
79
80
81 template <int dim, typename CGALPointType>
82 inline ::Point<dim>
83 cgal_point_to_dealii_point(const CGALPointType &p)
84 {
85 constexpr int cdim = CGALPointType::Ambient_dimension::value;
86 if constexpr (dim == 1)
87 return ::Point<dim>(CGAL::to_double(p.x()));
88 else if constexpr (dim == 2)
89 return ::Point<dim>(CGAL::to_double(p.x()),
90 cdim > 1 ? CGAL::to_double(p.y()) : 0);
91 else if constexpr (dim == 3)
92 return ::Point<dim>(CGAL::to_double(p.x()),
93 cdim > 1 ? CGAL::to_double(p.y()) : 0,
94 cdim > 2 ? CGAL::to_double(p.z()) : 0);
95 else
97 }
98} // namespace CGALWrappers
99
100# endif
101
103
104#endif
105#endif
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:472
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:473
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)