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_point_2.h $ 00015 // $Id: Circular_arc_point_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_POINT_2_H 00026 #define CGAL_CIRCULAR_ARC_POINT_2_H 00027 00028 CGAL_BEGIN_NAMESPACE 00029 00030 template < typename CircularKernel > 00031 class Circular_arc_point_2 00032 : public CircularKernel::Kernel_base::Circular_arc_point_2 00033 { 00034 typedef typename CircularKernel::Kernel_base::Circular_arc_point_2 00035 RCircular_arc_point_2; 00036 typedef typename CircularKernel::Point_2 Point_2; 00037 typedef typename CircularKernel::Circle_2 Circle_2; 00038 00039 typedef typename CircularKernel::Root_of_2 Root_of_2; 00040 00041 public: 00042 typedef typename CircularKernel::Root_for_circles_2_2 00043 Root_for_circles_2_2; 00044 typedef CircularKernel R; 00045 typedef RCircular_arc_point_2 Rep; 00046 00047 00048 const Rep& rep() const 00049 { 00050 return *this; 00051 } 00052 00053 Rep& rep() 00054 { 00055 return *this; 00056 } 00057 00058 Circular_arc_point_2() 00059 : RCircular_arc_point_2(typename R::Construct_circular_arc_point_2()()) 00060 {} 00061 00062 00063 Circular_arc_point_2(const Root_for_circles_2_2 & np) 00064 : RCircular_arc_point_2(typename R::Construct_circular_arc_point_2()(np)) 00065 {} 00066 00067 Circular_arc_point_2(const RCircular_arc_point_2 & p) 00068 : RCircular_arc_point_2(p) 00069 {} 00070 00071 Circular_arc_point_2(const Point_2 & p) 00072 : RCircular_arc_point_2(typename R::Construct_circular_arc_point_2()(p)) 00073 {} 00074 00075 typename Qualified_result_of 00076 <typename R::Compute_circular_x_2,Circular_arc_point_2>::type 00077 //const Root_of_2 & 00078 x() const 00079 { 00080 return typename R::Compute_circular_x_2()(*this); 00081 } 00082 00083 typename Qualified_result_of 00084 <typename R::Compute_circular_y_2,Circular_arc_point_2>::type 00085 //const Root_of_2 & 00086 y() const 00087 { 00088 return typename R::Compute_circular_y_2()(*this); 00089 } 00090 00091 Bbox_2 bbox() const 00092 { 00093 return typename R::Construct_bbox_2()(*this); 00094 } 00095 00096 }; 00097 00098 template < typename CircularKernel > 00099 inline 00100 bool 00101 operator==(const Circular_arc_point_2<CircularKernel> &p, 00102 const Circular_arc_point_2<CircularKernel> &q) 00103 { 00104 return CircularKernel().equal_2_object()(p, q); 00105 } 00106 00107 template < typename CircularKernel > 00108 inline 00109 bool 00110 operator!=(const Circular_arc_point_2<CircularKernel> &p, 00111 const Circular_arc_point_2<CircularKernel> &q) 00112 { 00113 return ! (p == q); 00114 } 00115 00116 template < typename CircularKernel > 00117 inline 00118 bool 00119 operator<(const Circular_arc_point_2<CircularKernel> &p, 00120 const Circular_arc_point_2<CircularKernel> &q) 00121 { 00122 return CircularKernel().compare_xy_2_object()(p, q) == CGAL::SMALLER; 00123 } 00124 00125 template < typename CircularKernel > 00126 inline 00127 bool 00128 operator>(const Circular_arc_point_2<CircularKernel> &p, 00129 const Circular_arc_point_2<CircularKernel> &q) 00130 { 00131 return CircularKernel().compare_xy_2_object()(p, q) == CGAL::LARGER; 00132 } 00133 00134 template < typename CircularKernel > 00135 inline 00136 bool 00137 operator<=(const Circular_arc_point_2<CircularKernel> &p, 00138 const Circular_arc_point_2<CircularKernel> &q) 00139 { 00140 CGAL::Comparison_result c = CircularKernel().compare_xy_2_object()(p, q); 00141 return (c == CGAL::SMALLER) || (c == CGAL::EQUAL); 00142 } 00143 00144 template < typename CircularKernel > 00145 inline 00146 bool 00147 operator>=(const Circular_arc_point_2<CircularKernel> &p, 00148 const Circular_arc_point_2<CircularKernel> &q) 00149 { 00150 CGAL::Comparison_result c = CircularKernel().compare_xy_2_object()(p, q); 00151 return (c == CGAL::LARGER) || (c == CGAL::EQUAL); 00152 } 00153 00154 template < typename CK > 00155 std::istream & 00156 operator>>(std::istream & is, Circular_arc_point_2<CK> &p) 00157 { 00158 typedef typename CK::Root_of_2 Root_of_2; 00159 typedef typename CK::Root_for_circles_2_2 Root_for_circles_2_2; 00160 00161 Root_for_circles_2_2 r; 00162 is >> r; 00163 if(is) 00164 p = Circular_arc_point_2<CK>(r); 00165 return is; 00166 } 00167 00168 template < class CK > 00169 std::ostream& 00170 operator<<(std::ostream &os, const Circular_arc_point_2<CK> &p) 00171 { 00172 return os << p.x() << " " << p.y() << " "; 00173 } 00174 00175 template < class CK > 00176 struct Filtered_bbox_circular_kernel_2; 00177 00178 template < typename CK > 00179 class Circular_arc_point_2 < Filtered_bbox_circular_kernel_2 < CK > > { 00180 00181 typedef Filtered_bbox_circular_kernel_2 < CK > BK; 00182 typedef typename CK::FT FT; 00183 typedef typename CK::RT RT; 00184 typedef typename BK::Point_2 Point_2; 00185 typedef typename CK::Line_2 Line_2; 00186 typedef typename CK::Circle_2 Circle_2; 00187 typedef typename CK::Circular_arc_point_2 Rcircular_arc_point_2; 00188 typedef typename CK::Circular_arc_2 Circular_arc_2; 00189 typedef typename CK::Root_of_2 Root_of_2; 00190 00191 public: 00192 typedef typename Rcircular_arc_point_2::Root_for_circles_2_2 00193 Root_for_circles_2_2; 00194 typedef BK R; 00195 typedef Circular_arc_point_2<BK> Rep; 00196 00197 const Rep& rep() const 00198 { 00199 return *this; 00200 } 00201 00202 Rep& rep() 00203 { 00204 return *this; 00205 } 00206 00208 Circular_arc_point_2() 00209 : P_point(),bb(NULL) 00210 {} 00211 00212 Circular_arc_point_2(const Root_for_circles_2_2 & np) 00213 : P_point(np), bb(NULL) 00214 {} 00215 00216 Circular_arc_point_2(const Point_2 & p) 00217 : P_point(p), bb(NULL) 00218 {} 00219 00220 Circular_arc_point_2(const Rcircular_arc_point_2 & p) 00221 : P_point(p),bb(NULL) 00222 {} 00223 00224 Circular_arc_point_2(const Circular_arc_point_2 &c) : P_point(c.P_point) 00225 { 00226 if(c.bb) bb = new Bbox_2(*(c.bb)); 00227 else bb = NULL; 00228 } 00229 00230 ~Circular_arc_point_2() { if(bb) delete bb; } 00231 00233 const Rcircular_arc_point_2& point() const 00234 {return P_point;} 00235 00236 typename Qualified_result_of<typename R::Compute_circular_x_2,Rcircular_arc_point_2>::type 00237 x() const 00238 { return P_point.x();} 00239 00240 typename Qualified_result_of<typename R::Compute_circular_y_2,Rcircular_arc_point_2>::type 00241 y() const 00242 { return P_point.y();} 00243 00244 00246 00247 bool has_no_bbox() const 00248 { return (bb==NULL);} 00249 00250 Bbox_2 bbox() const 00251 { 00252 if(this->has_no_bbox()) 00253 bb= new Bbox_2(P_point.bbox()); 00254 00255 return *bb; 00256 } 00257 00258 const Root_for_circles_2_2 & coordinates() const 00259 { return P_point.coordinates(); } 00260 00261 bool equal_ref(const Circular_arc_point_2 &p) const 00262 { 00263 return CGAL::identical(P_point, p.P_point); 00264 } 00265 00266 private: 00267 00268 Rcircular_arc_point_2 P_point; 00269 mutable Bbox_2 *bb; 00270 00271 }; 00272 00273 CGAL_END_NAMESPACE 00274 00275 #endif // CGAL_CIRCULAR_ARC_POINT_2_H