16
16
#include < CGAL/Simple_cartesian.h>
17
17
#include < CGAL/intersections.h>
18
18
#include < CGAL/Filtered_rational.h>
19
+ #include < CGAL/Static_filtered_predicate.h>
19
20
#include < CGAL/Filtered_kernel/Cartesian_coordinate_iterator_2.h>
20
21
#include < CGAL/Filtered_kernel/Cartesian_coordinate_iterator_3.h>
21
22
#include < CGAL/Interval_nt.h>
27
28
28
29
namespace CGAL {
29
30
31
+ template <typename T1, typename T2>
32
+ struct Approximate_exact_pair : public std ::pair<T1,T2> {
33
+ typedef std::pair<T1,T2> Base;
34
+
35
+ Approximate_exact_pair ()
36
+ {}
37
+
38
+ Approximate_exact_pair (const T1& t1, const T2& ts)
39
+ : Base(t1,t2)
40
+ {}
41
+
42
+ Approximate_exact_pair (const std::pair<T1,T2>& p)
43
+ : Base(p)
44
+ {}
45
+
46
+ const T1& approx () const
47
+ {
48
+ return first;
49
+ }
50
+ };
51
+
30
52
namespace mpl {
31
53
32
54
BOOST_MPL_HAS_XXX_TRAIT_DEF (first_type)
@@ -102,7 +124,7 @@ struct Getter<X>\
102
124
typedef X first_type; \
103
125
typedef X second_type; \
104
126
}; \
105
- const X& get_approx (const X& x) { return x; }\
127
+ const X& approx (const X& x) { return x; }\
106
128
const X& get_exact (const X& x) { return x; }
107
129
108
130
template <class A >
@@ -130,6 +152,13 @@ struct Getter<std::pair<A1, A2> >
130
152
typedef A2 second_type;
131
153
};
132
154
155
+ template <class A1 , class A2 >
156
+ struct Getter <Approximate_exact_pair<A1, A2> >
157
+ {
158
+ typedef A1 first_type;
159
+ typedef A2 second_type;
160
+ };
161
+
133
162
template <class A_FT , class E_FT >
134
163
struct Getter <Filtered_rational<A_FT,E_FT>>
135
164
{
@@ -139,23 +168,23 @@ struct Getter<Filtered_rational<A_FT,E_FT>>
139
168
140
169
template <class A1 , class A2 >
141
170
const A1&
142
- get_approx (const std::pair <A1,A2>& p)
171
+ approx (const Approximate_exact_pair <A1,A2>& p)
143
172
{
144
173
return p.first ;
145
174
}
146
175
147
176
template <class A1 , class A2 >
148
177
const A1&
149
- get_approx (const Filtered_rational<A1,A2>& p)
178
+ approx (const Filtered_rational<A1,A2>& p)
150
179
{
151
180
return p.n1 ();
152
181
}
153
182
154
183
template <class A >
155
184
const typename A::Rep::first_type&
156
- get_approx (const A& a, typename boost::disable_if< mpl::is_pair_<A> >::type* = nullptr )
185
+ approx (const A& a, typename boost::disable_if< mpl::is_pair_<A> >::type* = nullptr )
157
186
{
158
- return get_approx (a.rep ());
187
+ return approx (a.rep ());
159
188
}
160
189
161
190
template <class A1 , class A2 >
@@ -180,13 +209,17 @@ get_exact(const A& a, typename boost::disable_if< mpl::is_pair_<A> >::type* = nu
180
209
}
181
210
182
211
template <class AP , class EP >
183
- class Predicate_wrapper
212
+ class Filtered_rational_predicate
184
213
{
185
214
AP ap;
186
215
EP ep;
187
216
188
217
public:
189
- Predicate_wrapper (const AP &pap = AP(), const EP &pep = EP()) : ap(pap), ep(pep) { }
218
+ // CGAL_static_assertion((std::is_same<typename AP::result_type, typename EP::result_type>::value));
219
+ typedef typename EP::result_type result_type;
220
+
221
+ public:
222
+ Filtered_rational_predicate (const AP &pap = AP(), const EP &pep = EP()) : ap(pap), ep(pep) { }
190
223
191
224
template <class ... A>
192
225
typename CGAL::cpp11::result_of<EP(typename Getter<A>::second_type...)>::type
@@ -199,7 +232,7 @@ class Predicate_wrapper
199
232
200
233
try
201
234
{
202
- result_type_1 res1 = ap (get_approx (a)...);
235
+ result_type_1 res1 = ap (approx (a)...);
203
236
if (is_certain (res1))
204
237
return make_certain (res1);
205
238
}
@@ -211,15 +244,15 @@ class Predicate_wrapper
211
244
};
212
245
213
246
template <class AP , class EP , class AK , class EK , class FRK >
214
- class Construction_wrapper
247
+ class Filtered_rational_construction
215
248
{
216
249
AP ap;
217
250
EP ep;
218
251
219
252
CGAL::Cartesian_converter<EK, AK> e2a;
220
253
221
254
public:
222
- Construction_wrapper (const AP &pap = AP(), const EP &pep = EP()) : ap(pap), ep(pep) { }
255
+ Filtered_rational_construction (const AP &pap = AP(), const EP &pep = EP()) : ap(pap), ep(pep) { }
223
256
224
257
template <class T >
225
258
struct result ;
@@ -269,10 +302,12 @@ class Construction_wrapper
269
302
result_type_2 res2 = ep (get_exact (a)...);
270
303
271
304
return Pairify<result_type_1, result_type_2, EK, FRK>()(Approx<result_type_1>(e2a, ap)
272
- (res2, get_approx (a)...), res2);
305
+ (res2, approx (a)...), res2);
273
306
}
274
307
};
275
308
309
+
310
+
276
311
template < class AK , class EK , class Kernel_ >
277
312
class Filtered_rational_kernel_generic_base
278
313
{
@@ -294,8 +329,9 @@ class Filtered_rational_kernel_generic_base
294
329
typedef CGAL::Object Object_3;
295
330
296
331
typedef Kernel_ Kernel;
297
- typedef AK Kernel1;
298
- typedef EK Kernel2;
332
+ typedef AK Approximate_kernel;
333
+ typedef EK Exact_kernel;
334
+
299
335
300
336
template < typename T >
301
337
struct Ambient_dimension {
@@ -319,7 +355,7 @@ class Filtered_rational_kernel_generic_base
319
355
typedef CGAL::Aff_transformationC3<Kernel_> Aff_transformation_3;
320
356
321
357
// Kernel objects are defined as pairs, with primitives run in parallel.
322
- #define CGAL_kc_pair (X ) typedef std::pair <typename AK::X, typename EK::X> X;
358
+ #define CGAL_frk_pair (X ) typedef Approximate_exact_pair <typename AK::X, typename EK::X> X;
323
359
324
360
325
361
// TODO : Object_[23] are subtil : should probably be Object(pair<...>).
@@ -328,42 +364,42 @@ class Filtered_rational_kernel_generic_base
328
364
// takes its first argument by non-const reference.
329
365
// Maybe Primitive_checker should provide a variant with non-const ref...
330
366
331
- CGAL_kc_pair (Point_2)
332
- CGAL_kc_pair (Weighted_point_2)
333
- CGAL_kc_pair (Vector_2)
334
- CGAL_kc_pair (Direction_2)
335
- CGAL_kc_pair (Line_2)
336
- CGAL_kc_pair (Ray_2)
337
- CGAL_kc_pair (Segment_2)
338
- CGAL_kc_pair (Triangle_2)
339
- CGAL_kc_pair (Iso_rectangle_2)
340
- CGAL_kc_pair (Circle_2)
341
- CGAL_kc_pair (Conic_2)
342
-
343
-
344
- CGAL_kc_pair (Point_3)
345
- CGAL_kc_pair (Weighted_point_3)
346
- CGAL_kc_pair (Plane_3)
347
- CGAL_kc_pair (Vector_3)
348
- CGAL_kc_pair (Direction_3)
349
- CGAL_kc_pair (Line_3)
350
- CGAL_kc_pair (Ray_3)
351
- CGAL_kc_pair (Segment_3)
352
- CGAL_kc_pair (Triangle_3)
353
- CGAL_kc_pair (Tetrahedron_3)
354
- CGAL_kc_pair (Iso_cuboid_3)
355
- CGAL_kc_pair (Circle_3)
356
- CGAL_kc_pair (Sphere_3)
357
-
358
- #undef CGAL_kc_pair
359
-
360
- #define CGAL_Kernel_pred (X, Y ) \
361
- typedef Predicate_wrapper< typename AK::X , typename EK::X> X ; \
362
- X Y () const { return X ( ak.Y (), ek.Y ()); }
363
-
364
- #define CGAL_Kernel_cons (X, Y ) \
365
- typedef Construction_wrapper <typename AK::X , typename EK::X , AK, EK, Kernel_> X ; \
366
- X Y () const { return X (ak.Y (), ek.Y ()); }
367
+ CGAL_frk_pair (Point_2)
368
+ CGAL_frk_pair (Weighted_point_2)
369
+ CGAL_frk_pair (Vector_2)
370
+ CGAL_frk_pair (Direction_2)
371
+ CGAL_frk_pair (Line_2)
372
+ CGAL_frk_pair (Ray_2)
373
+ CGAL_frk_pair (Segment_2)
374
+ CGAL_frk_pair (Triangle_2)
375
+ CGAL_frk_pair (Iso_rectangle_2)
376
+ CGAL_frk_pair (Circle_2)
377
+ CGAL_frk_pair (Conic_2)
378
+
379
+
380
+ CGAL_frk_pair (Point_3)
381
+ CGAL_frk_pair (Weighted_point_3)
382
+ CGAL_frk_pair (Plane_3)
383
+ CGAL_frk_pair (Vector_3)
384
+ CGAL_frk_pair (Direction_3)
385
+ CGAL_frk_pair (Line_3)
386
+ CGAL_frk_pair (Ray_3)
387
+ CGAL_frk_pair (Segment_3)
388
+ CGAL_frk_pair (Triangle_3)
389
+ CGAL_frk_pair (Tetrahedron_3)
390
+ CGAL_frk_pair (Iso_cuboid_3)
391
+ CGAL_frk_pair (Circle_3)
392
+ CGAL_frk_pair (Sphere_3)
393
+
394
+ #undef CGAL_frk_pair
395
+
396
+ #define CGAL_Kernel_pred (P, Pf ) \
397
+ typedef Static_filtered_predicate<Approximate_kernel,Filtered_rational_predicate< typename AK::P , typename EK::P>, Exact_predicates_inexact_constructions_kernel::P> P ; \
398
+ P Pf () const { return P (); } // AF: Why was it P( ak.Pf (), ek.Pf ()) ?
399
+
400
+ #define CGAL_Kernel_cons (C, Cf ) \
401
+ typedef Filtered_rational_construction <typename AK::C , typename EK::C , AK, EK, Kernel_> C ; \
402
+ C Cf () const { return C (ak.Cf (), ek.Cf ()); }
367
403
368
404
369
405
public:
0 commit comments