1 // Copyright (c) 2003,2004,2005,2006 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/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Are_same_points_C2.h $ 7 // $Id: Are_same_points_C2.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) : Menelaos Karavelas <mkaravel@iacm.forth.gr> 12 13 14 #ifndef CGAL_SEGMENT_DELAUNAY_GRAPH_2_ARE_SAME_POINTS_C2_H 15 #define CGAL_SEGMENT_DELAUNAY_GRAPH_2_ARE_SAME_POINTS_C2_H 16 17 #include <CGAL/license/Segment_Delaunay_graph_2.h> 18 19 20 #include <CGAL/Segment_Delaunay_graph_2/basic.h> 21 22 namespace CGAL { 23 24 namespace SegmentDelaunayGraph_2 { 25 26 template<class K> 27 class Are_same_points_C2 28 { 29 private: 30 typedef typename K::Point_2 Point_2; 31 typedef typename K::Segment_2 Segment_2; 32 typedef typename K::Site_2 Site_2; 33 typedef typename K::Compare_x_2 Compare_x_2; 34 typedef typename K::Compare_y_2 Compare_y_2; 35 typedef typename K::Boolean Boolean; 36 37 typedef typename K::Intersections_tag ITag; 38 39 Compare_x_2 compare_x_2; 40 Compare_y_2 compare_y_2; 41 are_same(const Point_2 & p,const Point_2 & q)42 Boolean are_same(const Point_2& p, const Point_2& q) const 43 { 44 return 45 compare_x_2(p, q) == EQUAL && compare_y_2(p, q) == EQUAL; 46 } 47 are_same(const Site_2 & s,const Site_2 & t)48 Boolean are_same(const Site_2& s, const Site_2& t) const 49 { 50 return 51 ( are_same(s.source(), t.source()) && 52 are_same(s.target(), t.target()) ) || 53 ( are_same(s.source(), t.target()) && 54 are_same(s.target(), t.source()) ); 55 } 56 predicate(const Site_2 & p,const Site_2 & q,const Tag_false &)57 Boolean predicate(const Site_2& p, const Site_2& q, const Tag_false&) const 58 { 59 return are_same(p.point(), q.point()); 60 } 61 predicate(const Site_2 & p,const Site_2 & q,const Tag_true &)62 Boolean predicate(const Site_2& p, const Site_2& q, const Tag_true&) const 63 { 64 if ( !p.is_input() && !q.is_input() ) { 65 Site_2 s[2] = { p.supporting_site(0), p.supporting_site(1) }; 66 Site_2 t[2] = { q.supporting_site(0), q.supporting_site(1) }; 67 68 if ( ( are_same(s[0], t[0]) && are_same(s[1], t[1]) ) || 69 ( are_same(s[0], t[1]) && are_same(s[1], t[0]) ) ) { 70 return true; 71 } 72 } 73 74 return predicate(p, q, Tag_false()); 75 } 76 77 public: 78 typedef Boolean result_type; 79 typedef Site_2 argument_type; 80 operator()81 Boolean operator()(const Site_2& p, const Site_2& q) const 82 { 83 CGAL_precondition( p.is_point() && q.is_point() ); 84 85 return predicate(p, q, ITag()); 86 } 87 }; 88 89 } //namespace SegmentDelaunayGraph_2 90 91 } //namespace CGAL 92 93 #endif // CGAL_SEGMENT_DELAUNAY_GRAPH_2_ARE_SAME_POINTS_C2_H 94