All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
pointConversion.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::pointConversion
26 
27 Description
28  Conversion functions between point (Foam::) and Point (CGAL::)
29 
30 \*---------------------------------------------------------------------------*/
31 
32 #ifndef pointConversion_H
33 #define pointConversion_H
34 
35 #include "point.H"
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
39 #ifdef CGAL_INEXACT
40 
41  // Define Point to be contiguous for inexact (double storage) kernel
42  typedef const Foam::point& pointFromPoint;
43  typedef const CGAL::Triangulation_vertex_base_3<K>::Point& PointFrompoint;
44 
45 #else
46 
48  typedef CGAL::Triangulation_vertex_base_3<K>::Point PointFrompoint;
49 
50 #endif
51 
52 namespace Foam
53 {
54 
55 #ifdef CGAL_INEXACT
56 
57  template<class Point>
58  inline pointFromPoint topoint(const Point& P)
59  {
60  return reinterpret_cast<pointFromPoint>(P);
61  }
62 
63  inline PointFrompoint toPoint(const Foam::point& p)
64  {
65  return reinterpret_cast<PointFrompoint>(p);
66  }
67 
68 #else
69 
70  template<class Point>
71  inline pointFromPoint topoint(const Point& P)
72  {
73  return Foam::point
74  (
75  CGAL::to_double(P.x()),
76  CGAL::to_double(P.y()),
77  CGAL::to_double(P.z())
78  );
79  }
80 
81  inline PointFrompoint toPoint(const Foam::point& p)
82  {
83  return PointFrompoint(p.x(), p.y(), p.z());
84  }
85 
86 #endif
87 
88  //- Specialisation for indexedVertex.
89  template<>
90  inline pointFromPoint topoint<CGAL::indexedVertex<K>>
91  (
92  const CGAL::indexedVertex<K>& P
93  )
94  {
95  return topoint(P.point());
96  }
97 
98  //- Specialisation for Foam::point. Used only as a dummy.
99  template<>
100  inline pointFromPoint topoint<Foam::point>
101  (
102  const Foam::point& P
103  )
104  {
105  return P;
106  }
107 
108 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
109 
110 } // End namespace Foam
111 
112 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
113 
114 #endif
115 
116 // ************************************************************************* //
Foam::point pointFromPoint
CGAL::Triangulation_vertex_base_3< K >::Point PointFrompoint
pointFromPoint topoint(const Point &P)
const Cmpt & z() const
Definition: VectorI.H:87
const Cmpt & y() const
Definition: VectorI.H:81
An indexed form of CGAL::Triangulation_vertex_base_3<K> used to keep track of the Delaunay vertices i...
Definition: indexedVertex.H:51
PointFrompoint toPoint(const Foam::point &p)
const Cmpt & x() const
Definition: VectorI.H:75
vector point
Point is a vector.
Definition: point.H:41
volScalarField & p
Namespace for OpenFOAM.