1 // Copyright (c) 2003-2008  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/Circular_kernel_2/include/CGAL/Line_arc_2.h $
7 // $Id: Line_arc_2.h 059bc60 2020-07-22T15:13:09+02:00 Dmitry Anisimov
8 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
9 //
10 // Author(s)     : Monique Teillaud, Sylvain Pion, Julien Hazebrouck, Pedro Machado
11 
12 // Partially supported by the IST Programme of the EU as a Shared-cost
13 // RTD (FET Open) Project under Contract No  IST-2000-26473
14 // (ECG - Effective Computational Geometry for Curves and Surfaces)
15 // and a STREP (FET Open) Project under Contract No  IST-006413
16 // (ACS -- Algorithms for Complex Shapes)
17 
18 #ifndef CGAL_LINE_ARC_2_H
19 #define CGAL_LINE_ARC_2_H
20 
21 #include <CGAL/license/Circular_kernel_2.h>
22 
23 
24 #include <CGAL/Bbox_2.h>
25 
26 namespace CGAL {
27 
28 template <class CircularKernel>
29 class Line_arc_2
30   : public CircularKernel::Kernel_base::Line_arc_2
31 {
32   typedef typename CircularKernel::FT                        FT;
33   typedef typename CircularKernel::RT                        RT;
34   //typedef typename CircularKernel::Linear_kernel::Point_2    Point_2;
35   typedef typename CircularKernel::Point_2                   Point_2;
36   typedef typename CircularKernel::Line_2                    Line_2;
37   typedef typename CircularKernel::Circle_2                  Circle_2;
38   typedef typename CircularKernel::Circular_arc_point_2   Circular_arc_point_2;
39   typedef typename CircularKernel::Segment_2                 Segment_2;
40 
41   typedef typename CircularKernel::Kernel_base::Line_arc_2 RLine_arc_2;
42 public:
43   typedef  RLine_arc_2 Rep;
44   typedef  CircularKernel   R;
45 
rep()46  const Rep& rep() const
47   {
48     return *this;
49   }
50 
rep()51   Rep& rep()
52   {
53     return *this;
54   }
55 
Line_arc_2()56    Line_arc_2()
57      : RLine_arc_2(typename R::Construct_line_arc_2()())
58    {}
59 
60    // Not Documented
Line_arc_2(const Line_2 & support,const Circle_2 & c1,const bool b1,const Circle_2 & c2,const bool b2)61    Line_arc_2(const Line_2 &support,
62               const Circle_2 &c1,const bool b1,
63               const Circle_2 &c2,const bool b2)
64      : RLine_arc_2(typename R::Construct_line_arc_2()(support, c1, b1, c2, b2))
65    {}
66 
67    // Not Documented
Line_arc_2(const Line_2 & support,const Line_2 & l1,const Line_2 & l2)68    Line_arc_2(const Line_2 &support,
69                const Line_2 &l1,
70                const Line_2 &l2)
71      : RLine_arc_2(typename R::Construct_line_arc_2()(support, l1, l2))
72    {}
73 
Line_arc_2(const Line_2 & support,const Circular_arc_point_2 & p1,const Circular_arc_point_2 & p2)74    Line_arc_2(const Line_2 &support,
75                const Circular_arc_point_2 &p1,
76                const Circular_arc_point_2 &p2)
77      : RLine_arc_2(typename R::Construct_line_arc_2()(support, p1, p2))
78    {}
79 
Line_arc_2(const Segment_2 & s)80    Line_arc_2(const Segment_2 &s)
81      : RLine_arc_2(typename R::Construct_line_arc_2()(s))
82    {}
83 
Line_arc_2(const Point_2 & p1,const Point_2 & p2)84     Line_arc_2(const Point_2 &p1,
85                const Point_2 &p2)
86       : RLine_arc_2(typename R::Construct_line_arc_2()(p1, p2))
87    {}
88 
Line_arc_2(const RLine_arc_2 & a)89     Line_arc_2(const RLine_arc_2 &a )
90      : RLine_arc_2(a)
91    {}
92 
93   decltype(auto)
source()94     source() const
95   {
96         return typename R::Construct_circular_source_vertex_2()(*this);
97   }
98 
99   decltype(auto)
target()100     target() const
101   {
102         return typename R::Construct_circular_target_vertex_2()(*this);
103   }
104 
105   decltype(auto)
left()106   left() const
107   {
108         return typename R::Construct_circular_min_vertex_2()(*this);
109   }
110 
111   decltype(auto)
right()112   right() const
113   {
114         return typename R::Construct_circular_max_vertex_2()(*this);
115   }
116 
117   Line_2
supporting_line()118   supporting_line() const
119   {
120         return typename R::Construct_line_2()(*this);
121   }
122 
123 
is_vertical()124   bool is_vertical() const
125   {
126       return typename R::Is_vertical_2()(*this);
127   }
128 
bbox()129   Bbox_2  bbox() const
130   {
131         return typename R::Construct_bbox_2()(*this);
132   }
133 
134  };
135 
136 template < typename CircularKernel >
137 inline
138 bool
139 operator==(const Line_arc_2<CircularKernel> &p,
140            const Line_arc_2<CircularKernel> &q)
141 {
142   return CircularKernel().equal_2_object()(p, q);
143 }
144 
145 template < typename CircularKernel >
146 inline
147 bool
148 operator!=(const Line_arc_2<CircularKernel> &p,
149            const Line_arc_2<CircularKernel> &q)
150 {
151   return ! (p == q);
152 }
153 
154 
155  template < typename CK >
156     std::ostream &
157     operator<<(std::ostream & os, const Line_arc_2<CK> &a)
158     {
159 
160       return os << a.supporting_line() << " "
161                 << a.source() << " "
162                 << a.target() << " ";
163     }
164 
165   template < typename CK >
166   std::istream &
167   operator>>(std::istream & is, Line_arc_2<CK> &a)
168   {
169     typename CK::Line_2 l;
170     typename CK::Circular_arc_point_2 p1;
171     typename CK::Circular_arc_point_2 p2;
172     is >> l >> p1 >> p2 ;
173     if (is)
174       a = Line_arc_2<CK>(l, p1, p2);
175     return is;
176   }
177 
178 
179 } //namespace CGAL
180 
181 #endif // CGAL_LINE_ARC_2_H
182 
183 
184