1 // Copyright (c) 2000
2 // Utrecht University (The Netherlands),
3 // ETH Zurich (Switzerland),
4 // INRIA Sophia-Antipolis (France),
5 // Max-Planck-Institute Saarbruecken (Germany),
6 // and Tel-Aviv University (Israel).  All rights reserved.
7 //
8 // This file is part of CGAL (www.cgal.org)
9 //
10 // $URL: https://github.com/CGAL/cgal/blob/v5.3/Cartesian_kernel/include/CGAL/Cartesian/Point_3.h $
11 // $Id: Point_3.h 8bb22d5 2020-03-26T14:23:37+01:00 Sébastien Loriot
12 // SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
13 //
14 //
15 // Author(s)     : Andreas Fabri and Herve Bronnimann
16 
17 #ifndef CGAL_CARTESIAN_POINT_3_H
18 #define CGAL_CARTESIAN_POINT_3_H
19 
20 #include <CGAL/Origin.h>
21 
22 namespace CGAL {
23 
24 template < class R_ >
25 class PointC3
26 {
27   typedef PointC3<R_>                       Self;
28   typedef typename R_::Vector_3             Vector_3;
29   typedef typename R_::Point_3              Point_3;
30   typedef typename R_::Aff_transformation_3 Aff_transformation_3;
31 
32   // We do not use reference counting here as it is done at the Vector_3 level.
33   Vector_3 base;
34 
35 public:
36   typedef typename Vector_3::Cartesian_const_iterator Cartesian_const_iterator;
37   typedef R_                                R;
38   typedef typename R_::FT                   FT;
39 
PointC3()40   PointC3() {}
41 
PointC3(const Origin &)42   PointC3(const Origin &)
43     : base(NULL_VECTOR) {}
44 
PointC3(const FT & x,const FT & y,const FT & z)45   PointC3(const FT &x, const FT &y, const FT &z)
46     : base(x, y, z) {}
47 
PointC3(const FT & x,const FT & y,const FT & z,const FT & w)48   PointC3(const FT &x, const FT &y, const FT &z, const FT &w)
49     : base(x, y, z, w) {}
50 
swap(Self & a,Self & b)51   friend void swap(Self& a, Self& b)
52 #ifdef __cpp_lib_is_swappable
53     noexcept(std::is_nothrow_swappable_v<Vector_3>)
54 #endif
55   {
56     using std::swap;
57     swap(a.base, b.base);
58   }
59 
x()60   const FT & x() const
61   {
62       return base.x();
63   }
y()64   const FT & y() const
65   {
66       return base.y();
67   }
z()68   const FT & z() const
69   {
70       return base.z();
71   }
72 
hx()73   const FT & hx() const
74   {
75       return base.hx();
76   }
hy()77   const FT & hy() const
78   {
79       return base.hy();
80   }
hz()81   const FT & hz() const
82   {
83       return base.hz();
84   }
hw()85   const FT & hw() const
86   {
87       return base.hw();
88   }
89 
90   const FT & cartesian(int i) const;
91   const FT & operator[](int i) const;
92   const FT & homogeneous(int i) const;
93 
cartesian_begin()94   Cartesian_const_iterator cartesian_begin() const
95   {
96     return base.cartesian_begin();
97   }
98 
cartesian_end()99   Cartesian_const_iterator cartesian_end() const
100   {
101     return base.cartesian_end();
102   }
103 
dimension()104   int dimension() const
105   {
106       return base.dimension();
107   }
108 
transform(const Aff_transformation_3 & t)109   Point_3 transform(const Aff_transformation_3 &t) const
110   {
111     return t.transform(*this);
112   }
113 };
114 
115 template < class R >
116 inline
117 const typename PointC3<R>::FT &
cartesian(int i)118 PointC3<R>::cartesian(int i) const
119 {
120   return base.cartesian(i);
121 }
122 
123 template < class R >
124 inline
125 const typename PointC3<R>::FT &
126 PointC3<R>::operator[](int i) const
127 {
128   return base[i];
129 }
130 
131 template < class R >
132 inline
133 const typename PointC3<R>::FT &
homogeneous(int i)134 PointC3<R>::homogeneous(int i) const
135 {
136   return base.homogeneous(i);
137 }
138 
139 } //namespace CGAL
140 
141 #endif // CGAL_CARTESIAN_POINT_3_H
142