BWAPI
|
00001 // Copyright (c) 2003-2008 INRIA Sophia-Antipolis (France). 00002 // All rights reserved. 00003 // 00004 // This file is part of CGAL (www.cgal.org); you may redistribute it under 00005 // the terms of the Q Public License version 1.0. 00006 // See the file LICENSE.QPL distributed with CGAL. 00007 // 00008 // Licensees holding a valid commercial license may use this file in 00009 // accordance with the commercial license agreement provided with the software. 00010 // 00011 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00012 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00013 // 00014 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Circular_kernel_2/include/CGAL/Circular_arc_2.h $ 00015 // $Id: Circular_arc_2.h 46608 2008-10-31 17:08:32Z pmachado $ 00016 // 00017 // Author(s) : Monique Teillaud, Sylvain Pion, Pedro Machado 00018 00019 // Partially supported by the IST Programme of the EU as a Shared-cost 00020 // RTD (FET Open) Project under Contract No IST-2000-26473 00021 // (ECG - Effective Computational Geometry for Curves and Surfaces) 00022 // and a STREP (FET Open) Project under Contract No IST-006413 00023 // (ACS -- Algorithms for Complex Shapes) 00024 00025 #ifndef CGAL_CIRCULAR_ARC_2_H 00026 #define CGAL_CIRCULAR_ARC_2_H 00027 00028 CGAL_BEGIN_NAMESPACE 00029 00030 template <class CircularKernel> 00031 class Circular_arc_2 00032 : public CircularKernel::Kernel_base::Circular_arc_2 00033 { 00034 typedef typename CircularKernel::RT RT; 00035 typedef typename CircularKernel::FT FT; 00036 typedef typename CircularKernel::Point_2 Point_2; 00037 typedef typename CircularKernel::Line_2 Line_2; 00038 typedef typename CircularKernel::Circle_2 Circle_2; 00039 typedef typename CircularKernel::Circular_arc_point_2 00040 Circular_arc_point_2; 00041 00042 typedef typename CircularKernel::Kernel_base::Circular_arc_2 RCircular_arc_2; 00043 // RCircular_arc_2 to avoid clash with self 00044 public: 00045 typedef RCircular_arc_2 Rep; 00046 typedef CircularKernel R; 00047 00048 00049 const Rep& rep() const 00050 { 00051 return *this; 00052 } 00053 00054 Rep& rep() 00055 { 00056 return *this; 00057 } 00058 00059 00060 Circular_arc_2() 00061 : RCircular_arc_2(typename R::Construct_circular_arc_2()()) 00062 {} 00063 00064 Circular_arc_2(const Circle_2 &c) 00065 : RCircular_arc_2(typename R::Construct_circular_arc_2()(c)) 00066 {} 00067 00068 // Not Documented 00069 Circular_arc_2(const Circle_2 &support, 00070 const Line_2 &l1, const bool b_l1, 00071 const Line_2 &l2, const bool b_l2) 00072 : RCircular_arc_2(typename 00073 R::Construct_circular_arc_2()(support,l1,b_l1,l2,b_l2)) 00074 {} 00075 00076 // Not Documented 00077 Circular_arc_2(const Circle_2 &c, 00078 const Circle_2 &c1, const bool b_1, 00079 const Circle_2 &c2, const bool b_2) 00080 : RCircular_arc_2(typename 00081 R::Construct_circular_arc_2()(c,c1,b_1,c2,b_2)) 00082 {} 00083 00084 Circular_arc_2(const Point_2 &start, 00085 const Point_2 &middle, 00086 const Point_2 &end) 00087 : RCircular_arc_2(typename 00088 R::Construct_circular_arc_2()(start, middle, end)) 00089 {} 00090 00091 Circular_arc_2(const Circle_2 &support, 00092 const Circular_arc_point_2 &begin, 00093 const Circular_arc_point_2 &end) 00094 : RCircular_arc_2(typename 00095 R::Construct_circular_arc_2()(support, begin, end)) 00096 {} 00097 00098 Circular_arc_2(const Point_2 &start, 00099 const Point_2 &end, 00100 const FT &bulge) 00101 : RCircular_arc_2(typename 00102 R::Construct_circular_arc_2()(start, end, bulge)) 00103 {} 00104 00105 Circular_arc_2(const RCircular_arc_2 & a) 00106 : RCircular_arc_2(a) 00107 {} 00108 00109 00110 typename Qualified_result_of 00111 <typename R::Construct_circular_source_vertex_2,Circular_arc_2>::type 00112 //const Circular_arc_point_2 & 00113 source() const 00114 { 00115 return typename R::Construct_circular_source_vertex_2()(*this); 00116 } 00117 00118 typename Qualified_result_of 00119 <typename R::Construct_circular_target_vertex_2,Circular_arc_2>::type 00120 //const Circular_arc_point_2 & 00121 target() const 00122 { 00123 return typename R::Construct_circular_target_vertex_2()(*this); 00124 } 00125 00126 typename Qualified_result_of 00127 <typename R::Construct_circular_min_vertex_2,Circular_arc_2>::type 00128 //const Circular_arc_point_2 & 00129 left() const 00130 { 00131 return typename R::Construct_circular_min_vertex_2()(*this); 00132 } 00133 00134 typename Qualified_result_of 00135 <typename R::Construct_circular_max_vertex_2,Circular_arc_2>::type 00136 //const Circular_arc_point_2 & 00137 right() const 00138 { 00139 return typename R::Construct_circular_max_vertex_2()(*this); 00140 } 00141 00142 bool is_x_monotone() const 00143 { 00144 return typename R::Is_x_monotone_2()(*this); 00145 } 00146 00147 bool is_y_monotone() const 00148 { 00149 return typename R::Is_y_monotone_2()(*this); 00150 } 00151 00152 Circle_2 00153 supporting_circle() const 00154 { 00155 return typename R::Construct_circle_2()(*this); 00156 } 00157 00158 const Point_2 & center() const 00159 { 00160 return typename R::Construct_circle_2()(*this).center(); 00161 } 00162 00163 const FT & squared_radius() const 00164 { 00165 return typename R::Construct_circle_2()(*this).squared_radius(); 00166 } 00167 00168 Bbox_2 bbox(void) const 00169 { 00170 return typename R::Construct_bbox_2()(*this); 00171 } 00172 00173 }; 00174 00175 template < typename CircularKernel > 00176 inline 00177 bool 00178 operator==(const Circular_arc_2<CircularKernel> &p, 00179 const Circular_arc_2<CircularKernel> &q) 00180 { 00181 return CircularKernel().equal_2_object()(p, q); 00182 } 00183 00184 template < typename CircularKernel > 00185 inline 00186 bool 00187 operator!=(const Circular_arc_2<CircularKernel> &p, 00188 const Circular_arc_2<CircularKernel> &q) 00189 { 00190 return ! (p == q); 00191 } 00192 00193 template < typename CK > 00194 std::ostream & 00195 operator<<(std::ostream & os, const Circular_arc_2<CK> &a) 00196 { 00197 // The output format is : 00198 // - supporting circle 00199 // - circle c1 00200 // - bool b1 00201 // - circle c2 00202 // - bool b2 00203 return os << a.supporting_circle() << " " 00204 << a.source() << " " 00205 << a.target() << " "; 00206 } 00207 00208 template < typename CK > 00209 std::istream & 00210 operator>>(std::istream & is, Circular_arc_2<CK> &a) 00211 { 00212 typename CK::Circle_2 s; 00213 typename CK::Circular_arc_point_2 p1; 00214 typename CK::Circular_arc_point_2 p2; 00215 is >> s >> p1 >> p2 ; 00216 if (is) 00217 a = Circular_arc_2<CK>(s, p1, p2); 00218 return is; 00219 } 00220 00221 template < class CK > 00222 struct Filtered_bbox_circular_kernel_2; 00223 00224 template < typename CK > 00225 class Circular_arc_2 < Filtered_bbox_circular_kernel_2 < CK > > { 00226 00227 typedef Filtered_bbox_circular_kernel_2 < CK > BK; 00228 typedef Circular_arc_2< BK > Self; 00229 typedef typename BK::FT FT; 00230 typedef typename BK::RT RT; 00231 typedef typename BK::Point_2 Point_2; 00232 typedef typename BK::Line_2 Line_2; 00233 typedef typename BK::Circle_2 Circle_2; 00234 typedef typename BK::Circular_arc_point_2 Circular_arc_point_2; 00235 typedef typename CK::Circular_arc_2 Rcircular_arc_2; 00236 typedef typename CK::Root_of_2 Root_of_2; 00237 00238 public: 00239 typedef BK R; 00240 typedef Circular_arc_2<BK> Rep; 00241 00242 const Rep& rep() const 00243 { 00244 return *this; 00245 } 00246 00247 Rep& rep() 00248 { 00249 return *this; 00250 } 00251 00253 00254 Circular_arc_2(){} 00255 00256 // otherwise it will lead to ambiguos definitions 00257 explicit Circular_arc_2(const Circle_2 &c) 00258 : P_arc(c),bb(NULL) 00259 {} 00260 00261 Circular_arc_2(const Circle_2 &support, 00262 const Line_2 &l1, const bool b_l1, 00263 const Line_2 &l2, const bool b_l2) 00264 : P_arc(support,l1,b_l1,l2,b_l2),bb(NULL) 00265 {} 00266 00267 00268 Circular_arc_2(const Circle_2 &c, 00269 const Circle_2 &c1, const bool b_1, 00270 const Circle_2 &c2, const bool b_2) 00271 : P_arc(c,c1,b_1,c2,b_2),bb(NULL) 00272 {} 00273 00274 00275 Circular_arc_2(const Rcircular_arc_2 &A, const bool b, 00276 const Circle_2 &ccut, const bool b_cut) 00277 : P_arc(A, b, ccut, b_cut),bb(NULL) 00278 {} 00279 00280 00281 Circular_arc_2(const Point_2 &start, 00282 const Point_2 &middle, 00283 const Point_2 &end) 00284 : P_arc(start, middle, end),bb(NULL) 00285 {} 00286 00287 Circular_arc_2(const Point_2 &begin, 00288 const Point_2 &end, 00289 const FT &bulge) 00290 : P_arc(begin, end, bulge),bb(NULL) 00291 {} 00292 00293 Circular_arc_2(const Circle_2 &support, 00294 const Circular_arc_point_2 &begin, 00295 const Circular_arc_point_2 &end) 00296 : P_arc(support, begin.point(), end.point()),bb(NULL) 00297 {} 00298 00299 Circular_arc_2(const Rcircular_arc_2 &a) 00300 : P_arc(a),bb(NULL) 00301 {} 00302 00303 Circular_arc_2(const Circular_arc_2 &c) : P_arc(c.P_arc) 00304 { 00305 if(c.bb) bb = new Bbox_2(*(c.bb)); 00306 else bb = NULL; 00307 } 00308 00309 ~Circular_arc_2() { if(bb) delete bb; } 00310 00311 00313 00314 bool is_x_monotone() const 00315 { return P_arc.is_x_monotone();} 00316 00317 bool is_y_monotone() const 00318 { return P_arc.is_y_monotone();} 00319 00320 bool on_upper_part() const 00321 { return P_arc.on_upper_part();} 00322 00323 00325 00326 const Rcircular_arc_2& arc () const 00327 { return P_arc ;} 00328 00330 00331 typename Qualified_result_of<typename BK::Construct_circular_source_vertex_2,Self>::type 00332 source() const 00333 { return typename BK::Construct_circular_source_vertex_2()(*this);} 00334 00335 typename Qualified_result_of<typename BK::Construct_circular_target_vertex_2,Self>::type 00336 target() const 00337 { return typename BK::Construct_circular_target_vertex_2()(*this);} 00338 00339 typename Qualified_result_of<typename BK::Construct_circular_min_vertex_2,Self>::type 00340 left() const 00341 { 00342 return typename BK::Construct_circular_min_vertex_2()(*this); 00343 } 00344 00345 typename Qualified_result_of<typename BK::Construct_circular_max_vertex_2,Self>::type 00346 right() const 00347 { 00348 return typename BK::Construct_circular_max_vertex_2()(*this); 00349 } 00350 00351 Circle_2 supporting_circle() const 00352 { return P_arc.supporting_circle();} 00353 00354 Point_2 center() const 00355 { return P_arc.center();} 00356 00357 FT squared_radius() const 00358 { return P_arc.squared_radius();} 00359 00360 Bbox_2 bbox() const 00361 { 00362 if(bb==NULL) 00363 bb=new Bbox_2(P_arc.bbox()); 00364 return *bb; 00365 } 00366 00367 00369 00370 bool has_no_bbox() const 00371 { return (bb==NULL);} 00372 00373 bool equal_ref(const Circular_arc_2 &c) const 00374 { 00375 return CGAL::identical(P_arc, c.P_arc); 00376 } 00377 00378 bool is_full() const { 00379 return P_arc.is_full(); 00380 } 00381 00382 bool is_complementary_x_monotone() const { 00383 return P_arc.is_complementary_x_monotone(); 00384 } 00385 00386 bool is_complementary_y_monotone() const { 00387 return P_arc.is_complementary_y_monotone(); 00388 } 00389 00390 bool two_end_points_on_upper_part() const { 00391 return P_arc.two_end_points_on_upper_part(); 00392 } 00393 00394 bool complementary_on_upper_part() const { 00395 return P_arc.complementary_on_upper_part(); 00396 } 00397 00398 bool two_end_points_on_left_part() const { 00399 return P_arc.two_end_points_on_left_part(); 00400 } 00401 00402 bool on_left_part() const { 00403 return P_arc.on_left_part(); 00404 } 00405 00406 bool complementary_on_left_part() const { 00407 return P_arc.complementary_on_left_part(); 00408 } 00409 00410 private: 00411 00412 Rcircular_arc_2 P_arc; 00413 mutable Bbox_2 *bb; 00414 00415 00416 }; 00417 00418 00419 00420 CGAL_END_NAMESPACE 00421 00422 #endif // CGAL_CIRCULAR_ARC_2_H