1 // Copyright (c) 2008,2009,2010,2011 Max-Planck-Institute Saarbruecken (Germany),
2 // and Tel-Aviv University (Israel).  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/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Filtered_curved_kernel_via_analysis_2_impl.h $
7 // $Id: Filtered_curved_kernel_via_analysis_2_impl.h 0626eb0 2020-06-11T12:32:33+03:00 Efi Fogel
8 // SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
9 //
10 //
11 // Author(s)     : Eric Berberich <eric@mpi-inf.mpg.de>
12 //                 Pavel Emeliyanenko <asm@mpi-inf.mpg.de>
13 //                 Michael Kerber <mkerber@mpi-inf.mpg.de>
14 
15 #ifndef CGAL_FILTERED_CURVED_KERNEL_VIA_ANALYSIS_2_IMPL_H
16 #define CGAL_FILTERED_CURVED_KERNEL_VIA_ANALYSIS_2_IMPL_H
17 
18 /*!\file include/CGAL/Filtered_curved_kernel_via_analysis_2.h
19  * \brief defines class \c Filtered_curved_kernel_via_analysis_2
20  *
21  * Defines points and arcs supported by curves that can be analyzed
22  * and where some operations are filtered.
23  */
24 
25 #include <CGAL/config.h>
26 #include <CGAL/Curved_kernel_via_analysis_2/Curved_kernel_via_analysis_2_impl.h>
27 #include <CGAL/Curved_kernel_via_analysis_2/Curved_kernel_via_analysis_2_functors.h>
28 
29 #include <CGAL/Bbox_2.h>
30 
31 namespace CGAL {
32 
33 #ifndef CKvA_CERR
34 //#define FCKvA_DEBUG_PRINT_CERR
35 #ifdef FCKvA_DEBUG_PRINT_CERR
36 #define CKvA_CERR(x) std::cout << x
37 #else
38 #define CKvA_CERR(x) static_cast<void>(0)
39 #endif
40 #endif
41 
42 namespace internal {
43 
44 namespace Filtered_curved_kernel_via_analysis_2_Functors {
45 
46 #define CGAL_FILTERED_CKvA_2_GRAB_BASE_FUNCTOR_TYPES \
47     typedef typename Curved_kernel_via_analysis_2::Curve_2 Curve_2; \
48     typedef typename Curved_kernel_via_analysis_2::Point_2 Point_2; \
49     typedef typename Curved_kernel_via_analysis_2::Arc_2 Arc_2; \
50 
51 
52 template < class CurvedKernelViaAnalysis_2, class FunctorBase >
53 class Compare_xy_2 :
54         public FunctorBase::Compare_xy_2 {
55 
56 public:
57     //! this instance template parameter
58     typedef CurvedKernelViaAnalysis_2 Curved_kernel_via_analysis_2;
59 
60     CGAL_FILTERED_CKvA_2_GRAB_BASE_FUNCTOR_TYPES;
61 
62 #if DOXYGEN_RUNNING
63     typedef typename Curved_kernel_via_analysis_2::Curve_2 Curve_2;
64 
65     //! type of point
66     typedef typename Curved_kernel_via_analysis_2::Point_2 Point_2;
67 
68     //! type of arc
69     typedef typename Curved_kernel_via_analysis_2::Arc_2 Arc_2;
70 #endif
71 
72     //! the base type
73     typedef typename FunctorBase::Compare_xy_2 Base;
74 
75     //! the result type
76     typedef CGAL::Comparison_result result_type;
77 
78     //! standard constructor
Compare_xy_2(Curved_kernel_via_analysis_2 * kernel)79     Compare_xy_2(Curved_kernel_via_analysis_2 *kernel) :
80         Base(kernel) {
81     }
82 
83     /*!
84      * Compares two points lexigoraphically: by x, then by y.
85      * \param p1 The first point.
86      * \param p2 The second point.
87      * \return LARGER if x(p1) > x(p2), or if x(p1) = x(p2) and y(p1) > y(p2);
88      *         SMALLER if x(p1) \< x(p2), or if x(p1) = x(p2) and
89      *                   y(p1) \< y(p2);
90      *         EQUAL if the two points are equal.
91      */
operator()92     result_type operator()(const Point_2& p1, const Point_2& p2,
93                            bool equal_x = false) const {
94 
95         CKvA_CERR("\nfilteredcompare_xy_; p1: " << p1 << "; p2: " <<
96              p2 << "\n");
97 
98         return Base::operator()(p1, p2, equal_x);
99     }
100 };
101 
102 
103 // TODO implement Compare_y_limit_on_boundary_2
104 
105 
106 template < class CurvedKernelViaAnalysis_2, class FunctorBase >
107 class Compare_y_near_boundary_2 :
108         public FunctorBase::Compare_y_near_boundary_2 {
109 
110 public:
111     //! this instance template parameter
112     typedef CurvedKernelViaAnalysis_2 Curved_kernel_via_analysis_2;
113 
114     CGAL_FILTERED_CKvA_2_GRAB_BASE_FUNCTOR_TYPES;
115 
116 #if DOXYGEN_RUNNING
117     //! type of curve
118     typedef typename Curved_kernel_via_analysis_2::Curve_2 Curve_2;
119 
120     //! type of point
121     typedef typename Curved_kernel_via_analysis_2::Point_2 Point_2;
122 
123     //! type of arc
124     typedef typename Curved_kernel_via_analysis_2::Arc_2 Arc_2;
125 #endif
126 
127     //! the bae type
128     typedef typename FunctorBase::Compare_y_near_boundary_2
129     Base;
130 
131     //! the result type
132     typedef CGAL::Comparison_result result_type;
133 
134     //! standard constructor
Compare_y_near_boundary_2(Curved_kernel_via_analysis_2 * kernel)135     Compare_y_near_boundary_2(Curved_kernel_via_analysis_2 *kernel) :
136         Base(kernel) {
137     }
138 
139     /*! Compare the y-coordinates of 2 lines at their ends near the boundary
140      * of the parameter space at x = +/- oo.
141      * \param cv1 the first arc.
142      * \param cv2 the second arc.
143      * \param ce the line end indicator.
144      * \return the second comparison result.
145      * \pre the ce ends of the lines xcv1 and xcv2 lie either on the left
146      * boundary or on the right boundary of the parameter space.
147      */
operator()148     result_type operator()(const Arc_2& cv1, const Arc_2& cv2,
149                            CGAL::Arr_curve_end ce) const {
150 
151         CKvA_CERR("\nfilteredcompare_y_near_boundary; cv1: " << cv1
152                   << "; cv2: " << cv2 << "; end: " << ce << "\n");
153 
154         CGAL_assertion_code (
155                 CGAL::Arr_parameter_space loc1 = cv1.location(ce);
156         )
157         CGAL_precondition(Arc_2::is_on_left_right(loc1));
158         CGAL_precondition(loc1 == cv2.location(ce));
159         // comparing ids is the same as calling is_identical() ??
160         if (cv1.id() == cv2.id()) {
161             return CGAL::EQUAL;
162         }
163 
164         typedef typename Arc_2::Curve_kernel_2 Curve_kernel_2;
165 
166         typedef typename Curve_kernel_2::Coordinate_1 Coordinate_1;
167 
168         CGAL::Object obj1, obj2;
169         Coordinate_1 asym_info1, asym_info2;
170         CGAL::Arr_parameter_space ps1, ps2;
171 
172         obj1 =
173           cv1.curve().asymptotic_value_of_arc(cv1.location(ce), cv1.arcno());
174         obj2 =
175           cv2.curve().asymptotic_value_of_arc(cv2.location(ce), cv2.arcno());
176 
177         CGAL::Comparison_result filter_res = CGAL::EQUAL;
178 
179         if (CGAL::assign(ps1, obj1)) {
180             if (CGAL::assign(ps2, obj2)) {
181                 if (ps1 == ps2) {
182                     filter_res = CGAL::EQUAL;
183                 } else {
184                     filter_res = (ps2 == CGAL::ARR_TOP_BOUNDARY ?
185                                   CGAL::SMALLER : CGAL::LARGER);
186                 }
187             } else {
188                 CGAL_assertion(CGAL::assign(asym_info2, obj2));
189                 filter_res = (ps1 == CGAL::ARR_TOP_BOUNDARY ?
190                               CGAL::LARGER : CGAL::SMALLER);
191             }
192         } else {
193             CGAL_assertion_code(bool check = )
194                 CGAL::assign(asym_info1, obj1);
195             CGAL_assertion(check);
196             if (CGAL::assign(ps2, obj2)) {
197                 filter_res = (ps2 == CGAL::ARR_TOP_BOUNDARY ?
198                               CGAL::SMALLER : CGAL::LARGER);
199             } else {
200                 CGAL_assertion_code(bool check = )
201                     CGAL::assign(asym_info2, obj2);
202                 CGAL_assertion(check);
203                 filter_res = Base::_ckva()->kernel().compare_1_object()(
204                         asym_info1, asym_info2
205                 );
206             }
207         }
208 
209         if (filter_res != CGAL::EQUAL) {
210             CGAL_assertion_code(
211             {
212                 Base base_compare_y_near_boundary(this->_ckva());
213 
214                 CGAL::Comparison_result check_res =
215                     base_compare_y_near_boundary(cv1, cv2, ce);
216                 CGAL_assertion(check_res == filter_res);
217             }
218             );
219             return filter_res;
220         }
221 
222         return Base::operator()(cv1, cv2, ce);
223     }
224 };
225 
226 template < class CurvedKernelViaAnalysis_2, class FunctorBase >
227 class Compare_y_at_x_2 :
228         public FunctorBase::Compare_y_at_x_2 {
229 
230 public:
231     //! this instance template parameter
232     typedef CurvedKernelViaAnalysis_2 Curved_kernel_via_analysis_2;
233 
234     CGAL_FILTERED_CKvA_2_GRAB_BASE_FUNCTOR_TYPES;
235 
236 #if DOXYGEN_RUNNING
237     //! type of curve
238     typedef typename Curved_kernel_via_analysis_2::Curve_2 Curve_2;
239 
240     //! type of point
241     typedef typename Curved_kernel_via_analysis_2::Point_2 Point_2;
242 
243     //! type of arc
244     typedef typename Curved_kernel_via_analysis_2::Arc_2 Arc_2;
245 #endif
246 
247     //! the bae type
248     typedef typename FunctorBase::Compare_y_at_x_2 Base;
249 
250     //! the result type
251     typedef CGAL::Comparison_result result_type;
252 
253     //! standard constructor
Compare_y_at_x_2(Curved_kernel_via_analysis_2 * kernel)254     Compare_y_at_x_2(Curved_kernel_via_analysis_2 *kernel) :
255         Base(kernel) {
256     }
257 
258     /*!
259      * Return the location of the given point with respect to the input curve.
260      * \param cv The curve.
261      * \param p The point.
262      * \pre p is in the x-range of cv.
263      * \return SMALLER if y(p) \< cv(x(p)), i.e. the point is below the curve;
264      *         LARGER if y(p) > cv(x(p)), i.e. the point is above the curve;
265      *         EQUAL if p lies on the curve.
266      */
operator()267     result_type operator()(const Point_2& p, const Arc_2& cv) const {
268 
269         return Base::operator()(p, cv);
270     }
271 };
272 
273 template < class CurvedKernelViaAnalysis_2, class FunctorBase >
274 class Compare_y_at_x_left_2 :
275         public FunctorBase::Compare_y_at_x_left_2 {
276 
277 public:
278     //! this instance template parameter
279     typedef CurvedKernelViaAnalysis_2 Curved_kernel_via_analysis_2;
280 
281     CGAL_FILTERED_CKvA_2_GRAB_BASE_FUNCTOR_TYPES;
282 
283 #if DOXYGEN_RUNNING
284     //! type of curve
285     typedef typename Curved_kernel_via_analysis_2::Curve_2 Curve_2;
286 
287     //! type of point
288     typedef typename Curved_kernel_via_analysis_2::Point_2 Point_2;
289 
290     //! type of arc
291     typedef typename Curved_kernel_via_analysis_2::Arc_2 Arc_2;
292 #endif
293 
294     //! the bae type
295     typedef typename FunctorBase::Compare_y_at_x_left_2 Base;
296 
297     //! the result type
298     typedef CGAL::Comparison_result result_type;
299 
300     //! standard constructor
Compare_y_at_x_left_2(Curved_kernel_via_analysis_2 * kernel)301     Compare_y_at_x_left_2(Curved_kernel_via_analysis_2 *kernel) :
302         Base(kernel) {
303     }
304 
305     /*!
306      * Compares the y value of two x-monotone curves immediately to the left
307      * of their intersection point. If one of the curves is vertical
308      * (emanating downward from p), it's always considered to be below the
309      * other curve.
310      * \param cv1 The first curve.
311      * \param cv2 The second curve.
312      * \param p The intersection point.
313      * \pre The point p lies on both curves, and both of them must be also be
314      *      defined (lexicographically) to its left.
315      * \return The relative position of cv1 with respect to cv2 immdiately to
316      *         the left of p: SMALLER, LARGER or EQUAL.
317      */
operator()318     result_type operator() (const Arc_2& cv1, const Arc_2& cv2,
319                             const Point_2& p) const {
320 
321         return Base::operator()(cv1, cv2, p);
322     }
323 };
324 
325 template < class CurvedKernelViaAnalysis_2, class FunctorBase >
326 class Compare_y_at_x_right_2 :
327         public FunctorBase::Compare_y_at_x_right_2 {
328 
329 public:
330     //! this instance template parameter
331     typedef CurvedKernelViaAnalysis_2 Curved_kernel_via_analysis_2;
332 
333     CGAL_FILTERED_CKvA_2_GRAB_BASE_FUNCTOR_TYPES;
334 
335 #if DOXYGEN_RUNNING
336     //! type of curve
337     typedef typename Curved_kernel_via_analysis_2::Curve_2 Curve_2;
338 
339     //! type of point
340     typedef typename Curved_kernel_via_analysis_2::Point_2 Point_2;
341 
342     //! type of arc
343     typedef typename Curved_kernel_via_analysis_2::Arc_2 Arc_2;
344 #endif
345 
346     //! the bae type
347     typedef typename FunctorBase::Compare_y_at_x_right_2 Base;
348 
349     //! the result type
350     typedef CGAL::Comparison_result result_type;
351 
352     //! standard constructor
Compare_y_at_x_right_2(Curved_kernel_via_analysis_2 * kernel)353     Compare_y_at_x_right_2(Curved_kernel_via_analysis_2 *kernel) :
354         Base(kernel) {
355     }
356 
357     /*!
358      * Compares the y value of two x-monotone curves immediately to the right
359      * of their intersection point. If one of the curves is vertical
360      * (emanating downward from p), it's always considered to be below the
361      * other curve.
362      * \param cv1 The first curve.
363      * \param cv2 The second curve.
364      * \param p The intersection point.
365      * \pre The point p lies on both curves, and both of them must be also be
366      *      defined (lexicographically) to its right.
367      * \return The relative position of cv1 with respect to cv2 immdiately to
368      *         the right of p: SMALLER, LARGER or EQUAL.
369      */
operator()370     result_type operator() (const Arc_2& cv1, const Arc_2& cv2,
371                             const Point_2& p) const {
372 
373         CKvA_CERR("\ncompare_y_at_x_right(cv2); cv1: " << cv1 << "; cv2: " <<
374             cv2 << "; p: " << p << "\n");
375 
376         return Base::operator()(cv1, cv2, p);
377     }
378 };
379 
380 template < class CurvedKernelViaAnalysis_2, class FunctorBase >
381 class May_have_intersection_2 :
382         public Curved_kernel_via_analysis_2_Functors::
383     Curved_kernel_via_analysis_2_functor_base< CurvedKernelViaAnalysis_2 > {
384 
385 public:
386     //! this instance template parameter
387     typedef CurvedKernelViaAnalysis_2 Curved_kernel_via_analysis_2;
388 
389     CGAL_FILTERED_CKvA_2_GRAB_BASE_FUNCTOR_TYPES;
390 
391     typedef Curved_kernel_via_analysis_2_Functors::
392         Curved_kernel_via_analysis_2_functor_base< CurvedKernelViaAnalysis_2 >
393     Base;
394 
395 #if DOXYGEN_RUNNING
396     //! type of curve
397     typedef typename Curved_kernel_via_analysis_2::Curve_2 Curve_2;
398 
399     //! type of point
400     typedef typename Curved_kernel_via_analysis_2::Point_2 Point_2;
401 
402     //! type of arc
403     typedef typename Curved_kernel_via_analysis_2::Arc_2 Arc_2;
404 #endif
405 
406 private:
407 
408     typedef typename Curved_kernel_via_analysis_2::Curve_kernel_2
409     Curve_kernel_2;
410 
411     typedef typename Curve_kernel_2::Curve_analysis_2 Curve_analysis_2;
412     typedef typename Curve_kernel_2::Coordinate_1 Coordinate_1;
413     typedef typename Curve_kernel_2::Coordinate_2 Coordinate_2;
414     typedef typename Curve_kernel_2::X_real_traits_1 X_real_traits_1;
415     typedef typename Curve_kernel_2::Y_real_traits_1 Y_real_traits_1;
416 
417     typename X_real_traits_1::Lower_boundary x_low;
418     typename X_real_traits_1::Upper_boundary x_high;
419     typename X_real_traits_1::Refine x_refine;
420 
421     typename Y_real_traits_1::Lower_boundary y_low;
422     typename Y_real_traits_1::Upper_boundary y_high;
423     typename Y_real_traits_1::Refine y_refine;
424 
425     typedef typename Coordinate_1::Rational Boundary;
426 
427 public:
428     typedef bool result_type;
429 
430     //! standard constructor
May_have_intersection_2(Curved_kernel_via_analysis_2 * kernel)431     May_have_intersection_2(Curved_kernel_via_analysis_2 *kernel) :
432         Base(kernel) {
433     }
434 
435     /*!\brief
436      * Checks whether \c cv1 and \c cv2 can have an intersection. If
437      * not it certainly returns false, if possible, it return true.
438      */
operator()439     bool operator()(const Arc_2& cv1, const Arc_2& cv2) const {
440 
441         Arc_2 trimmed_cv1, trimmed_cv2;
442 
443         if(! cv1.is_vertical() && ! cv2.is_vertical() ) {
444 
445             if(! cv1.trim_by_arc(cv2,trimmed_cv1,trimmed_cv2)) {
446                 return false;
447             }
448 
449         } else {
450             trimmed_cv1 = cv1;
451             trimmed_cv2 = cv2;
452         }
453 
454         std::list< CGAL::Bbox_2 > boxes1, boxes2;
455 
456         construct_covering_approximation(trimmed_cv1,
457                                          std::back_inserter(boxes1));
458 
459         construct_covering_approximation(trimmed_cv2,
460                                          std::back_inserter(boxes2));
461 
462         if (!boxes1.empty() && !boxes2.empty()) {
463             // TODO better strategy than quadratic pair of for-loops (MK)
464             for (typename std::list< CGAL::Bbox_2 >::const_iterator bit1 =
465                      boxes1.begin(); bit1 != boxes1.end(); bit1++) {
466                 for (typename std::list< CGAL::Bbox_2 >::const_iterator bit2 =
467                          boxes2.begin(); bit2 != boxes2.end(); bit2++) {
468                     if (CGAL::do_overlap(*bit1, *bit2)) {
469                         return true;
470                     }
471                 }
472             }
473         }
474 
475         return false;
476     }
477 
478 public:
479 
480     /*!\brief
481      * Constructs for a given \c arc its covering approximation.
482      */
483     template < class OutputIterator >
construct_covering_approximation(const Arc_2 & arc,OutputIterator oi)484     OutputIterator construct_covering_approximation(
485             const Arc_2& arc, OutputIterator oi) const {
486 
487         CKvA_CERR("\nconstruct_covering_approximation; arc: " << arc
488              << ";\n cv:" << arc << "\n");
489 
490         // TODO compute more than a single bbox (EB)
491 
492         CGAL::Bbox_2 bbox = arc.bbox();
493 
494         CKvA_CERR("\nres: " << bbox << "\n");
495 
496         *oi++ = bbox;
497         return oi;
498     }
499 
500 };
501 
502 
503 //! checks whether and how two arcs are intersection - with first filtering
504 template < class CurvedKernelViaAnalysis_2, class FunctorBase >
505 class Intersect_2 :
506         public FunctorBase::Intersect_2 {
507 
508 public:
509     //! this instance template parameter
510     typedef CurvedKernelViaAnalysis_2 Curved_kernel_via_analysis_2;
511 
512     CGAL_FILTERED_CKvA_2_GRAB_BASE_FUNCTOR_TYPES;
513 
514 #if DOXYGEN_RUNNING
515     //! type of curve
516     typedef typename Curved_kernel_via_analysis_2::Curve_2 Curve_2;
517 
518     //! type of point
519     typedef typename Curved_kernel_via_analysis_2::Point_2 Point_2;
520 
521     //! type of arc
522     typedef typename Curved_kernel_via_analysis_2::Arc_2 Arc_2;
523 #endif
524 
525     //! the bae type
526     typedef typename FunctorBase::Intersect_2 Base;
527 
528     //! standard constructor
Intersect_2(Curved_kernel_via_analysis_2 * kernel)529     Intersect_2(Curved_kernel_via_analysis_2 *kernel) :
530         Base(kernel) {
531     }
532 
533     /*!
534      * Find all intersections of the two given curves and insert them to the
535      * output iterator. If two arcs intersect only once, only a single will be
536      * placed to the iterator. Type of output iterator is \c CGAL::Object
537      * containing either an \c Arc_2 object (overlap) or a \c Point_2 object
538      * with multiplicity (point-wise intersections)
539      * \param cv1 The first curve.
540      * \param cv2 The second curve.
541      * \param oi The output iterator.
542      * \return The past-the-end iterator.
543      */
544     template < class OutputIterator >
operator()545     OutputIterator operator()(const Arc_2& cv1, const Arc_2& cv2,
546                               OutputIterator oi) const {
547 
548         CKvA_CERR("\nfiltered_intersect; cv1: " << cv1
549              << ";\n cv2:" << cv2 << "");
550 
551         if (!Base::_ckva()->may_have_intersection_2_object()(cv1, cv2)) {
552             // return no one
553             CKvA_CERR("\nfilter: sucessfull\n");
554 
555             CGAL_assertion_code(
556             {
557                 std::vector<CGAL::Object> tmp;
558                 Base::operator()(cv1, cv2, std::back_inserter(tmp));
559                 CGAL_assertion(tmp.empty());
560             });
561             return oi;
562         }
563 
564         // else
565         CKvA_CERR("\nfilter: failed\n");
566 
567         return Base::operator()(cv1, cv2, oi);
568     }
569 };
570 
571 template < class CurvedKernelViaAnalysis_2, class FunctorBase >
572 class Is_on_2 :
573         public FunctorBase::Is_on_2 {
574 
575 public:
576     //! this instance template parameter
577     typedef CurvedKernelViaAnalysis_2 Curved_kernel_via_analysis_2;
578 
579     CGAL_FILTERED_CKvA_2_GRAB_BASE_FUNCTOR_TYPES;
580 
581 #if DOXYGEN_RUNNING
582     //! type of curve
583     typedef typename Curved_kernel_via_analysis_2::Curve_2 Curve_2;
584 
585     //! type of point
586     typedef typename Curved_kernel_via_analysis_2::Point_2 Point_2;
587 
588     //! type of arc
589     typedef typename Curved_kernel_via_analysis_2::Arc_2 Arc_2;
590 #endif
591 
592     //! the bae type
593     typedef typename FunctorBase::Is_on_2 Base;
594 
595     //! the result type
596     typedef bool result_type;
597 
598     //! standard constructor
Is_on_2(Curved_kernel_via_analysis_2 * kernel)599     Is_on_2(Curved_kernel_via_analysis_2 *kernel) :
600         Base(kernel) {
601     }
602 
603     /*!
604      * Checks whether \c p lies on \c c
605      * \param p The point to test
606      * \param c The curve
607      * \return (true) if the \c p lies on \c c
608      */
operator()609     result_type operator()(const Point_2& p, const Curve_2& c) const {
610 
611         CKvA_CERR("\nfiltered_is_on; p: " << p << ";\n c:" << c << "");
612 
613         return Base::operator()(p, c);
614     }
615 
operator()616     result_type operator()(const Point_2& p, const Arc_2& arc) const {
617 
618         return Base::operator()(p, arc);
619     }
620 };
621 
622 #undef CGAL_FILTERED_CKvA_2_GRAB_BASE_FUNCTOR_TYPES
623 
624 } // namespace Filtered_curved_kernel_via_analysis_2_Functors
625 
626 
627 template <class FCKvA, class BaseCKvA>
628 struct Filtered_functor_base :
629       public BaseCKvA::template rebind< FCKvA >::Functor_base {
630 
631     typedef FCKvA Self;
632 
633     typedef BaseCKvA Base_ckva;
634 
635     typedef typename BaseCKvA::template rebind< Self >::Functor_base
636         Functor_base;
637 
638 // declares curved kernel functors, for each functor defines a member function
639 // returning an instance of this functor
640 #define CGAL_FILTERED_CKvA_2_functor_pred(Y, Z) \
641     typedef internal::Filtered_curved_kernel_via_analysis_2_Functors:: \
642         Y< Self, Functor_base > Y; \
643     Y Z() const { return Y(&Self::instance()); }
644 
645 #define CGAL_FILTERED_CKvA_2_functor_cons(Y, Z) \
646     CGAL_FILTERED_CKvA_2_functor_pred(Y, Z)
647 
648     CGAL_FILTERED_CKvA_2_functor_pred(Compare_xy_2, compare_xy_2_object);
649 
650     CGAL_FILTERED_CKvA_2_functor_pred(Compare_y_near_boundary_2,
651                                       compare_y_near_boundary_2_object);
652 
653     CGAL_FILTERED_CKvA_2_functor_pred(Compare_y_at_x_2,
654                                       compare_y_at_x_2_object);
655     CGAL_FILTERED_CKvA_2_functor_pred(Compare_y_at_x_left_2,
656                                       compare_y_at_x_left_2_object);
657     CGAL_FILTERED_CKvA_2_functor_pred(Compare_y_at_x_right_2,
658                                       compare_y_at_x_right_2_object);
659 
660     CGAL_FILTERED_CKvA_2_functor_pred(Is_on_2, is_on_2_object);
661 
662     CGAL_FILTERED_CKvA_2_functor_pred(
663             May_have_intersection_2, may_have_intersection_2_object
664     );
665 
666     CGAL_FILTERED_CKvA_2_functor_cons(Intersect_2, intersect_2_object);
667 
668 #undef CGAL_FILTERED_CKvA_2_functor_pred
669 #undef CGAL_FILTERED_CKvA_2_functor_cons
670 
671 };
672 
673 } // namespace internal
674 
675 /*!\brief
676  * Filtered curved kernel, i.e., intersection predicate is filted by first
677  * computing a covering approximation. Only if these overlap for two arcs
678  * the exact intersection predicate is called.
679  */
680 template < class BaseCKvA_2 >
681 class Filtered_curved_kernel_via_analysis_2 :
682     public internal::Curved_kernel_via_analysis_2_base<
683         Filtered_curved_kernel_via_analysis_2< BaseCKvA_2 >,
684         BaseCKvA_2, typename BaseCKvA_2::Curve_kernel_2,
685         internal::Filtered_functor_base >
686 {
687 public:
688     //! \name public typedefs
689     //!@{
690 
691     //! this instance's first template argument
692     typedef BaseCKvA_2 Curved_kernel_via_analysis_2;
693 
694     //! myself
695     typedef Filtered_curved_kernel_via_analysis_2<
696             Curved_kernel_via_analysis_2 > Self;
697 
698     //! type of curve kernel
699     typedef typename
700     Curved_kernel_via_analysis_2::Curve_kernel_2 Curve_kernel_2;
701 
702     //! type of curve analysis
703     typedef typename Curve_kernel_2::Curve_analysis_2 Curve_analysis_2;
704 
705     //!@}
706 
707 public:
708     //!\name embedded types  for \c Arrangement_2 package
709     //!@{
710 
711     //! type of curve_2
712     typedef Curve_analysis_2 Curve_2;
713 
714     //! type of a point on generic curve
715     typedef internal::Point_2< Self > Point_2;
716 
717     //! type of an arc on generic curve
718     typedef internal::Arc_2< Self > Arc_2;
719 
720     //! type of weakly x-monotone arc for \c ArrangementTraits_2
721     typedef Arc_2 X_monotone_curve_2;
722 
723     //!@}
724 
725 protected:
726 
727     //! base kernel type
728     typedef internal::Curved_kernel_via_analysis_2_base<
729         Self, Curved_kernel_via_analysis_2, Curve_kernel_2,
730         internal::Filtered_functor_base > Base_kernel;
731 
732 public:
733     //! \name Constructors
734     //!@{
735 
736     //! default constructor
Filtered_curved_kernel_via_analysis_2()737     Filtered_curved_kernel_via_analysis_2() :
738         Base_kernel() {
739     }
740 
741     //! construct using specific \c Curve_kernel_2 instance (for controlling)
Filtered_curved_kernel_via_analysis_2(const Curve_kernel_2 & kernel)742     Filtered_curved_kernel_via_analysis_2(const Curve_kernel_2& kernel) :
743         Base_kernel(kernel) {
744     }
745 
746     //!@}
747 
748 }; // class Filtered_curved_kernel_via_analysis_2
749 
750 } // namespace CGAL
751 
752 #endif // CGAL_FILTERED_CURVED_KERNEL_VIA_ANALYSIS_2_IMPL_H
753 // EOF
754