1 // Copyright (c) 1997   INRIA Sophia-Antipolis (France).
2 // All rights reserved.
3 //
4 // This file is part of CGAL (www.cgal.org).
5 //
6 // $URL: https://github.com/CGAL/cgal/blob/v5.3/Triangulation_2/include/CGAL/Triangulation_2_traits_3.h $
7 // $Id: Triangulation_2_traits_3.h 0779373 2020-03-26T13:31:46+01:00 Sébastien Loriot
8 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
9 //
10 //
11 // Author(s)     : Mariette Yvinec
12 
13 #ifndef CGAL_TRIANGULATION_2_TRAITS_3_H
14 #define CGAL_TRIANGULATION_2_TRAITS_3_H
15 
16 #include <CGAL/license/Triangulation_2.h>
17 
18 
19 
20 #include <CGAL/Point_3.h>
21 #include <CGAL/Segment_3.h>
22 #include <CGAL/Triangle_3.h>
23 #include <CGAL/Kernel/global_functions_3.h>
24 
25 #include <CGAL/triangulation_assertions.h>
26 
27 namespace CGAL {
28 
29 template<class R>
30 class Compare_yz_3
31 {
32 public:
33   typedef typename  R::Point_3     Point;
34 
operator()35   Comparison_result operator() (Point p, Point q){
36     Comparison_result r;
37     r = CGAL::compare_y(p,q);
38     if (r == EQUAL) r = CGAL::compare_z(p,q);
39     return r;
40    }
41 };
42 
43 
44 template <class R>
45 class Side_of_oriented_circle_2_3
46 {
47   // 2d triangulation needs a side_of_oriented_circle
48    // that in fact is a side_of_bounded_circle
49   // meaning that
50   // bounded side of circle = positive side
51 public:
52   typedef typename  R::Point_3                   Point;
53   typedef typename  R::Coplanar_side_of_bounded_circle_3
54                                                  Side_of_bounded_circle_2_3;
operator()55   Oriented_side operator() (const Point& p,
56                             const Point& q,
57                             const Point& r,
58                             const Point& s) {
59     Side_of_bounded_circle_2_3  side;
60     Bounded_side bs = side(p,q,r,s);
61     return ( bs == ON_UNBOUNDED_SIDE) ? ON_NEGATIVE_SIDE :
62       (bs == ON_BOUNDED_SIDE ) ? ON_POSITIVE_SIDE :
63       ON_ORIENTED_BOUNDARY;
64   }
65 };
66 
67 
68 
69 template < class R >
70 class Triangulation_2_traits_3
71 {
72 public:
73   typedef R Rep;
74   typedef typename Rep::Point_3    Point_2;
75   typedef typename Rep::Segment_3  Segment_2;
76   typedef typename Rep::Triangle_3 Triangle_2;
77 
78   typedef typename Rep::Compare_x_3               Compare_x_2;
79   typedef Compare_yz_3<Rep>                       Compare_y_2;
80   typedef typename Rep::Coplanar_orientation_3    Orientation_2;
81   typedef Side_of_oriented_circle_2_3<Rep>        Side_of_oriented_circle_2;
82   typedef typename Rep::Construct_segment_3       Construct_segment_2;
83   typedef typename Rep::Construct_triangle_3      Construct_triangle_2;
84 
85   // for compatibility with previous versions
86   typedef Point_2      Point;
87   typedef Segment_2    Segment;
88   typedef Triangle_2   Triangle;
89 
90   Compare_x_2
compare_x_2_object()91   compare_x_2_object() const
92     { return Compare_x_2();}
93 
94   Compare_y_2
compare_y_2_object()95   compare_y_2_object() const
96     { return Compare_y_2();}
97 
98   Orientation_2
orientation_2_object()99   orientation_2_object() const
100     { return Orientation_2();}
101 
102   Side_of_oriented_circle_2
side_of_oriented_circle_2_object()103   side_of_oriented_circle_2_object() const
104   {return Side_of_oriented_circle_2();}
105 
construct_segment_2_object()106   Construct_segment_2  construct_segment_2_object() const
107     {return Construct_segment_2();}
108 
construct_triangle_2_object()109   Construct_triangle_2  construct_triangle_2_object() const
110     {return Construct_triangle_2();}
111 
112 };
113 
114 } //namespace CGAL
115 #endif // CGAL_TRIANGULATION_2_TRAITS_3_H
116