1 // Copyright (c) 2005,2006,2007,2009,2010,2011 Tel-Aviv University (Israel). 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/Arrangement_on_surface_2/include/CGAL/Arr_directional_non_caching_segment_basic_traits_2.h $ 7 // $Id: Arr_directional_non_caching_segment_basic_traits_2.h 254d60f 2019-10-19T15:23:19+02:00 Sébastien Loriot 8 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial 9 // 10 // Author(s) : Efi Fogel <efif@post.tau.ac.il> 11 12 #ifndef CGAL_ARR_DIRECTIONAL_NON_CACHING_SEGMENT_BASIC_TRAITS_2_H 13 #define CGAL_ARR_DIRECTIONAL_NON_CACHING_SEGMENT_BASIC_TRAITS_2_H 14 15 #include <CGAL/license/Arrangement_on_surface_2.h> 16 17 #include <CGAL/disable_warnings.h> 18 19 #include <CGAL/Arr_non_caching_segment_basic_traits_2.h> 20 21 namespace CGAL { 22 23 /*! \class 24 * A model of the following concepts: 25 * 1. ArrangementBasicTraits_2, 26 * 2. ArrangementDirectionalXMonotoneTraits_2, 27 * 4. ArrangementConstructXMonotoneCurveTraits_2, and 28 * 3. ArrangementOpenBoundaryTraits_2 29 * It handles linear curves. 30 */ 31 template <class Kernel_T> 32 class Arr_directional_non_caching_segment_basic_traits_2 : 33 public Arr_non_caching_segment_basic_traits_2<Kernel_T> 34 { 35 public: 36 typedef Kernel_T Kernel; 37 38 typedef Arr_non_caching_segment_basic_traits_2<Kernel> Base; 39 typedef typename Base::Segment_assertions Segment_assertions; 40 typedef typename Base::Has_exact_division Has_exact_division; 41 42 /*! Default constructor. */ Arr_directional_non_caching_segment_basic_traits_2()43 Arr_directional_non_caching_segment_basic_traits_2() : Base() {} 44 45 /// \name Types and functors inherited from the base, required by the 46 // ArrangementBasicTraits_2 concept. 47 //@{ 48 49 // Traits types: 50 typedef typename Base::Has_left_category Has_left_category; 51 typedef typename Base::Has_do_intersect_category Has_do_intersect_category; 52 53 typedef typename Base::Left_side_category Left_side_category; 54 typedef typename Base::Bottom_side_category Bottom_side_category; 55 typedef typename Base::Top_side_category Top_side_category; 56 typedef typename Base::Right_side_category Right_side_category; 57 58 typedef typename Base::Point_2 Point_2; 59 typedef typename Base::X_monotone_curve_2 X_monotone_curve_2; 60 61 /*! Compare the x-coordinates of two points */ 62 typedef typename Base::Compare_x_2 Compare_x_2; 63 64 /*! Compare two points lexigoraphically; by x, then by y */ 65 typedef typename Base::Compare_xy_2 Compare_xy_2; 66 67 /*! Obtain the left endpoint of a given segment */ 68 typedef typename Base::Construct_min_vertex_2 Construct_min_vertex_2; 69 70 /*! Obtain the right endpoint of a given segment */ 71 typedef typename Base::Construct_max_vertex_2 Construct_max_vertex_2; 72 73 /*! Check whether a given segment is vertical */ 74 typedef typename Base::Is_vertical_2 Is_vertical_2; 75 76 /*! Return the location of a given point with respect to an input segment */ 77 typedef typename Base::Compare_y_at_x_2 Compare_y_at_x_2; 78 79 /*! Check if two segments or if two points are identical */ 80 typedef typename Base::Equal_2 Equal_2; 81 82 /*! Compare the y value of two segments immediately to the left of their 83 * intersection point 84 */ 85 typedef typename Base::Compare_y_at_x_left_2 Compare_y_at_x_left_2; 86 87 /*! Compare the y value of two segments immediately to the right of their 88 * intersection point 89 */ 90 typedef typename Base::Compare_y_at_x_right_2 Compare_y_at_x_right_2; 91 92 /*! Construct a segment. */ 93 typedef typename Base::Construct_x_monotone_curve_2 94 Construct_x_monotone_curve_2; 95 96 /*! Obtain an approximation of a point coordinate. */ 97 typedef typename Base::Approximate_number_type Approximate_number_type; 98 99 //@} 100 101 /// \name Types and functors introduced here, required by the 102 // ArrangementDirectionalXMonotoneTraits concept. 103 //@{ 104 typedef typename Kernel::Construct_opposite_segment_2 Construct_opposite_2; 105 106 /*! Obtain a Construct_opposite_2 functor object. */ construct_opposite_2_object()107 Construct_opposite_2 construct_opposite_2_object() const 108 { return Construct_opposite_2(); } 109 110 class Compare_endpoints_xy_2 { 111 protected: 112 typedef Arr_directional_non_caching_segment_basic_traits_2<Kernel> Traits; 113 114 /*! The traits (in case it has state). */ 115 const Traits& m_traits; 116 117 /*! Constructor 118 * \param traits the traits (in case it has state). 119 */ Compare_endpoints_xy_2(const Traits & traits)120 Compare_endpoints_xy_2(const Traits& traits) : m_traits(traits) {} 121 122 friend class Arr_directional_non_caching_segment_basic_traits_2<Kernel>; 123 124 public: 125 /*! Compare the two endpoints of a given curve lexigoraphically. 126 * \param cv The curve. 127 * \return SMALLER if cv is directed from left to right and LARGER 128 * otherwise. 129 */ operator()130 Comparison_result operator()(const X_monotone_curve_2& cv) const 131 { 132 typedef typename Kernel::Construct_vertex_2 Construct_vertex_2; 133 134 const Kernel& kernel = m_traits; 135 Construct_vertex_2 ctr_v = kernel.construct_vertex_2_object(); 136 Compare_xy_2 cmp_xy = m_traits.compare_xy_2_object(); 137 return(cmp_xy(ctr_v(cv,0), ctr_v(cv,1))); 138 } 139 }; 140 141 /*! Obtain a Compare_endpoints_xy_2 functor object. */ compare_endpoints_xy_2_object()142 Compare_endpoints_xy_2 compare_endpoints_xy_2_object() const 143 { return Compare_endpoints_xy_2(*this); } 144 //@} 145 }; 146 147 } 148 149 #include <CGAL/enable_warnings.h> 150 151 #endif 152