1 // Copyright (c) 2013 GeometryFactory (France). All rights reserved.
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/Circular_kernel_2/include/CGAL/Circular_kernel_2/Intersection_traits.h $
7 // $Id: Intersection_traits.h 0779373 2020-03-26T13:31:46+01:00 Sébastien Loriot
8 // SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
9 //
10 // $URL: https://github.com/CGAL/cgal/blob/v5.3/Circular_kernel_2/include/CGAL/Circular_kernel_2/Intersection_traits.h $
11 // $Id: Intersection_traits.h 0779373 2020-03-26T13:31:46+01:00 Sébastien Loriot
12 // SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
13 //
14 //
15 // Author(s)     : Philipp Möller and Sebastien Loriot
16 
17 #ifndef CGAL_CIRCULAR_KERNEL_2_INTERSECTION_TRAITS_H
18 #define CGAL_CIRCULAR_KERNEL_2_INTERSECTION_TRAITS_H
19 
20 #include <CGAL/Intersection_traits.h>
21 
22 #include <boost/variant.hpp>
23 
24 namespace CGAL {
25 
26 template <typename CK, typename T1, typename T2>
27 struct CK2_Intersection_traits
28 {};
29 
30 // Intersection_traits for the circular kernel
31 
32 // The additional CGAL_ADDITIONAL_VARIANT_FOR_ICL ( = int) in the variant
33 // has the only purpose to work around a bug of the Intel compiler,
34 // which without it produces the error
35 // /usr/include/boost/type_traits/has_nothrow_copy.hpp(36): internal error: bad pointer
36 // template struct has_nothrow_copy_constructor : public integral_constant{};
37 // See also https://github.com/CGAL/cgal/issues/1581
38 
39 template<typename CK>
40 struct CK2_Intersection_traits<CK, typename CK::Circle_2, typename CK::Circle_2>
41 {
42   typedef typename
43   boost::variant< typename CK::Circle_2,
44                   typename std::pair< typename CK::Circular_arc_point_2,
45                                       unsigned int >
46                   CGAL_ADDITIONAL_VARIANT_FOR_ICL
47                   >
48   type;
49 };
50 
51 template<typename CK>
52 struct CK2_Intersection_traits<CK, typename CK::Circular_arc_2, typename CK::Circular_arc_2>
53 {
54   typedef typename
55   boost::variant< typename CK::Circular_arc_2,
56                   typename std::pair< typename CK::Circular_arc_point_2,
57                                       unsigned int >
58                   CGAL_ADDITIONAL_VARIANT_FOR_ICL
59                   >
60   type;
61 };
62 
63 template<typename CK>
64 struct CK2_Intersection_traits<CK, typename CK::Line_arc_2, typename CK::Line_arc_2>
65 {
66   typedef typename
67   boost::variant< typename CK::Line_arc_2,
68                   typename std::pair< typename CK::Circular_arc_point_2,
69                                       unsigned int >
70                   CGAL_ADDITIONAL_VARIANT_FOR_ICL
71                   >
72   type;
73 };
74 
75 template<typename CK>
76 struct CK2_Intersection_traits<CK, typename CK::Line_arc_2, typename CK::Circle_2>
77 {
78   typedef typename
79   boost::variant< typename std::pair< typename CK::Circular_arc_point_2,
80                                       unsigned int >
81                   CGAL_ADDITIONAL_VARIANT_FOR_ICL
82                   >
83   type;
84 };
85 
86 template<typename CK>
87 struct CK2_Intersection_traits<CK, typename CK::Circle_2, typename CK::Line_arc_2>
88   : public CK2_Intersection_traits<CK, typename CK::Line_arc_2, typename CK::Circle_2>
89 {};
90 
91 template<typename CK>
92 struct CK2_Intersection_traits<CK, typename CK::Line_arc_2, typename CK::Circular_arc_2>
93 {
94   typedef typename
95   boost::variant< typename std::pair< typename CK::Circular_arc_point_2,
96                                       unsigned int >
97                   CGAL_ADDITIONAL_VARIANT_FOR_ICL
98                   >
99   type;
100 };
101 
102 template<typename CK>
103 struct CK2_Intersection_traits<CK, typename CK::Circular_arc_2, typename CK::Line_arc_2>
104   : public CK2_Intersection_traits<CK, typename CK::Line_arc_2, typename CK::Circular_arc_2>
105 {};
106 
107 template<typename CK>
108 struct CK2_Intersection_traits<CK, typename CK::Line_arc_2, typename CK::Line_2>
109 {
110   typedef typename
111   boost::variant< typename CK::Line_arc_2,
112                   typename std::pair< typename CK::Circular_arc_point_2,
113                                       unsigned int >
114                   CGAL_ADDITIONAL_VARIANT_FOR_ICL
115                   >
116   type;
117 };
118 
119 template<typename CK>
120 struct CK2_Intersection_traits<CK, typename CK::Line_2, typename CK::Line_arc_2>
121   : public CK2_Intersection_traits<CK, typename CK::Line_arc_2, typename CK::Line_2>
122 {};
123 
124 template<typename CK>
125 struct CK2_Intersection_traits<CK, typename CK::Line_2, typename CK::Circular_arc_2>
126 {
127   typedef typename
128   boost::variant< typename std::pair< typename CK::Circular_arc_point_2,
129                                       unsigned int >
130                   CGAL_ADDITIONAL_VARIANT_FOR_ICL
131                   >
132   type;
133 };
134 
135 template<typename CK>
136 struct CK2_Intersection_traits<CK, typename CK::Circular_arc_2, typename CK::Line_2>
137   : public CK2_Intersection_traits<CK, typename CK::Line_2, typename CK::Circular_arc_2>
138 {};
139 
140 // Circular_arc_2 Circle_2 simply aliases
141 template<typename CK>
142 struct CK2_Intersection_traits<CK, typename CK::Circular_arc_2, typename CK::Circle_2>
143   : public CK2_Intersection_traits<CK, typename CK::Circular_arc_2, typename CK::Circular_arc_2>
144 {};
145 
146 template<typename CK>
147 struct CK2_Intersection_traits<CK, typename CK::Circle_2, typename CK::Circular_arc_2>
148   : public CK2_Intersection_traits<CK, typename CK::Circular_arc_2, typename CK::Circular_arc_2>
149 {};
150 
151 // !!! undocumented !!! //
152 
153 // Line_2 Circle_2
154 template<typename CK>
155 struct CK2_Intersection_traits<CK, typename CK::Line_2, typename CK::Circle_2>
156 {
157   typedef typename
158   boost::variant< typename std::pair< typename CK::Circular_arc_point_2,
159                                       unsigned int >
160                   CGAL_ADDITIONAL_VARIANT_FOR_ICL
161                   >
162   type;
163 };
164 
165 template<typename CK>
166 struct CK2_Intersection_traits<CK, typename CK::Circle_2, typename CK::Line_2> :
167     public CK2_Intersection_traits<CK, typename CK::Line_2, typename CK::Circle_2>
168 {};
169 
170 template<typename CK>
171 struct CK2_Intersection_traits<CK, typename CK::Line_2, typename CK::Line_2>
172 {
173   typedef typename Intersection_traits<CK, typename CK::Line_2, typename CK::Line_2>::result_type type;
174 };
175 
176 } //end of namespace CGAL
177 
178 namespace CGAL{
179 namespace internal{
180 
181 // this function is used to call either make_object or a
182 // CK2_Intersection_traits::result_type constructor to create return
183 // values. The Object version takes some dummy template arguments
184 // that are needed for the return of the Intersection_traits. In
185 // theory a one parameter variant could be returned, but this
186 // _could_ come with conversion overhead and so we rather go for
187 // the real type.
188 // Overloads for empty returns are also provided.
189   template<typename RT, typename T>
190   inline RT
191   ck2_intersection_return(T&& t) { return RT(std::forward<T>(t)); }
192   template<typename RT>
193   inline RT
194   ck2_intersection_return() { return RT(); }
195 
196 } } //end of namespace CGAL::internal
197 
198 
199 #endif // CGAL_CIRCULAR_KERNEL_2_INTERSECTION_TRAITS_H
200