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/Line_arc_2.h $ 00015 // $Id: Line_arc_2.h 46608 2008-10-31 17:08:32Z pmachado $ 00016 // 00017 // Author(s) : Monique Teillaud, Sylvain Pion, Julien Hazebrouck, 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_LINE_ARC_2_H 00026 #define CGAL_LINE_ARC_2_H 00027 00028 CGAL_BEGIN_NAMESPACE 00029 00030 template <class CircularKernel> 00031 class Line_arc_2 00032 : public CircularKernel::Kernel_base::Line_arc_2 00033 { 00034 typedef typename CircularKernel::FT FT; 00035 typedef typename CircularKernel::RT RT; 00036 //typedef typename CircularKernel::Linear_kernel::Point_2 Point_2; 00037 typedef typename CircularKernel::Point_2 Point_2; 00038 typedef typename CircularKernel::Line_2 Line_2; 00039 typedef typename CircularKernel::Circle_2 Circle_2; 00040 typedef typename CircularKernel::Circular_arc_point_2 Circular_arc_point_2; 00041 typedef typename CircularKernel::Segment_2 Segment_2; 00042 00043 typedef typename CircularKernel::Kernel_base::Line_arc_2 RLine_arc_2; 00044 public: 00045 typedef RLine_arc_2 Rep; 00046 typedef CircularKernel R; 00047 00048 const Rep& rep() const 00049 { 00050 return *this; 00051 } 00052 00053 Rep& rep() 00054 { 00055 return *this; 00056 } 00057 00058 Line_arc_2() 00059 : RLine_arc_2(typename R::Construct_line_arc_2()()) 00060 {} 00061 00062 // Not Documented 00063 Line_arc_2(const Line_2 &support, 00064 const Circle_2 &c1,const bool b1, 00065 const Circle_2 &c2,const bool b2) 00066 : RLine_arc_2(typename R::Construct_line_arc_2()(support, c1, b1, c2, b2)) 00067 {} 00068 00069 // Not Documented 00070 Line_arc_2(const Line_2 &support, 00071 const Line_2 &l1, 00072 const Line_2 &l2) 00073 : RLine_arc_2(typename R::Construct_line_arc_2()(support, l1, l2)) 00074 {} 00075 00076 Line_arc_2(const Line_2 &support, 00077 const Circular_arc_point_2 &p1, 00078 const Circular_arc_point_2 &p2) 00079 : RLine_arc_2(typename R::Construct_line_arc_2()(support, p1, p2)) 00080 {} 00081 00082 Line_arc_2(const Segment_2 &s) 00083 : RLine_arc_2(typename R::Construct_line_arc_2()(s)) 00084 {} 00085 00086 Line_arc_2(const Point_2 &p1, 00087 const Point_2 &p2) 00088 : RLine_arc_2(typename R::Construct_line_arc_2()(p1, p2)) 00089 {} 00090 00091 Line_arc_2(const RLine_arc_2 &a ) 00092 : RLine_arc_2(a) 00093 {} 00094 00095 typename Qualified_result_of 00096 <typename R::Construct_circular_source_vertex_2,Line_arc_2>::type 00097 //const Circular_arc_point_2 & 00098 source() const 00099 { 00100 return typename R::Construct_circular_source_vertex_2()(*this); 00101 } 00102 00103 typename Qualified_result_of 00104 <typename R::Construct_circular_target_vertex_2,Line_arc_2>::type 00105 //const Circular_arc_point_2 & 00106 target() const 00107 { 00108 return typename R::Construct_circular_target_vertex_2()(*this); 00109 } 00110 00111 typename Qualified_result_of 00112 <typename R::Construct_circular_min_vertex_2,Line_arc_2>::type 00113 //const Circular_arc_point_2 & left() const 00114 left() const 00115 { 00116 return typename R::Construct_circular_min_vertex_2()(*this); 00117 } 00118 00119 typename Qualified_result_of 00120 <typename R::Construct_circular_max_vertex_2,Line_arc_2>::type 00121 //const Circular_arc_point_2 & right() const 00122 right() const 00123 { 00124 return typename R::Construct_circular_max_vertex_2()(*this); 00125 } 00126 00127 Line_2 00128 supporting_line() const 00129 { 00130 return typename R::Construct_line_2()(*this); 00131 } 00132 00133 00134 bool is_vertical() const 00135 { 00136 return typename R::Is_vertical_2()(*this); 00137 } 00138 00139 Bbox_2 bbox() const 00140 { 00141 return typename R::Construct_bbox_2()(*this); 00142 } 00143 00144 }; 00145 00146 template < typename CircularKernel > 00147 inline 00148 bool 00149 operator==(const Line_arc_2<CircularKernel> &p, 00150 const Line_arc_2<CircularKernel> &q) 00151 { 00152 return CircularKernel().equal_2_object()(p, q); 00153 } 00154 00155 template < typename CircularKernel > 00156 inline 00157 bool 00158 operator!=(const Line_arc_2<CircularKernel> &p, 00159 const Line_arc_2<CircularKernel> &q) 00160 { 00161 return ! (p == q); 00162 } 00163 00164 00165 template < typename CK > 00166 std::ostream & 00167 operator<<(std::ostream & os, const Line_arc_2<CK> &a) 00168 { 00169 00170 return os << a.supporting_line() << " " 00171 << a.source() << " " 00172 << a.target() << " "; 00173 } 00174 00175 template < typename CK > 00176 std::istream & 00177 operator>>(std::istream & is, Line_arc_2<CK> &a) 00178 { 00179 typename CK::Line_2 l; 00180 typename CK::Circular_arc_point_2 p1; 00181 typename CK::Circular_arc_point_2 p2; 00182 is >> l >> p1 >> p2 ; 00183 if (is) 00184 a = Line_arc_2<CK>(l, p1, p2); 00185 return is; 00186 } 00187 00188 template < class CK > 00189 struct Filtered_bbox_circular_kernel_2; 00190 00191 template < typename CK > 00192 class Line_arc_2 < Filtered_bbox_circular_kernel_2 < CK > > { 00193 00194 typedef Filtered_bbox_circular_kernel_2 < CK > BK; 00195 typedef Line_arc_2< BK > Self; 00196 typedef typename CK::FT FT; 00197 typedef typename CK::RT RT; 00198 typedef typename CK::Point_2 Point_2; 00199 typedef typename BK::Line_2 Line_2; 00200 typedef typename CK::Segment_2 Segment_2; 00201 typedef typename CK::Circle_2 Circle_2; 00202 typedef typename BK::Circular_arc_point_2 Circular_arc_point_2; 00203 typedef typename CK::Line_arc_2 Rline_arc_2; 00204 typedef typename CK::Root_of_2 Root_of_2; 00205 00206 00207 public: 00208 typedef BK R; 00209 typedef Line_arc_2<BK> Rep; 00210 00211 const Rep& rep() const 00212 { 00213 return *this; 00214 } 00215 00216 Rep& rep() 00217 { 00218 return *this; 00219 } 00220 00222 00223 Line_arc_2(){} 00224 00225 Line_arc_2(const Line_2 &support, 00226 const Circle_2 &l1, const bool b_l1, 00227 const Circle_2 &l2, const bool b_l2) 00228 : P_arc(support,l1,b_l1,l2,b_l2), bb(NULL) 00229 {} 00230 00231 00232 Line_arc_2(const Line_2 &support, 00233 const Line_2 &l1, 00234 const Line_2 &l2) 00235 : P_arc(support,l1,l2), bb(NULL) 00236 {} 00237 00238 Line_arc_2(const Line_2 &support, 00239 const Circular_arc_point_2 &begin, 00240 const Circular_arc_point_2 &end) 00241 : P_arc(support, begin.point(), end.point()) , bb(NULL) 00242 {} 00243 00244 00245 Line_arc_2(const Segment_2 &s) 00246 : P_arc(s) , bb(NULL) 00247 {} 00248 00249 00250 Line_arc_2(const Point_2 &p1, 00251 const Point_2 &p2) 00252 : P_arc(p1,p2) , bb(NULL) 00253 {} 00254 00255 00256 Line_arc_2(const Rline_arc_2 &a) 00257 : P_arc(a) , bb(NULL) 00258 {} 00259 00260 Line_arc_2(const Line_arc_2 &c) : P_arc(c.P_arc) 00261 { 00262 if(c.bb) bb = new Bbox_2(*(c.bb)); 00263 else bb = NULL; 00264 } 00265 00266 ~Line_arc_2() { if(bb) delete bb; } 00267 00268 00270 00271 bool is_vertical() const 00272 { return P_arc.is_vertical();} 00273 00275 00276 const Rline_arc_2& arc () const 00277 { return P_arc ;} 00278 00280 00281 typename Qualified_result_of<typename BK::Construct_circular_min_vertex_2,Self>::type 00282 left() const 00283 {return typename BK::Construct_circular_min_vertex_2()(*this);} 00284 00285 typename Qualified_result_of<typename BK::Construct_circular_max_vertex_2,Self>::type 00286 right() const 00287 {return typename BK::Construct_circular_max_vertex_2()(*this);} 00288 00289 typename Qualified_result_of<typename BK::Construct_circular_source_vertex_2,Self>::type 00290 source() const 00291 {return typename BK::Construct_circular_source_vertex_2()(*this);} 00292 00293 typename Qualified_result_of<typename BK::Construct_circular_target_vertex_2,Self>::type 00294 target() const 00295 {return typename BK::Construct_circular_target_vertex_2()(*this);} 00296 00297 Line_2 00298 supporting_line() const 00299 { return P_arc.supporting_line();} 00300 00301 Bbox_2 bbox() const 00302 { 00303 if(bb==NULL) 00304 bb=new Bbox_2(P_arc.bbox()); 00305 return *bb; 00306 } 00307 00308 00310 00311 bool has_no_bbox() const 00312 { return (bb==NULL);} 00313 00314 bool equal_ref(const Line_arc_2 &c) const 00315 { 00316 return CGAL::identical(P_arc, c.P_arc); 00317 } 00318 00319 private: 00320 00321 Rline_arc_2 P_arc; 00322 mutable Bbox_2 *bb; 00323 00324 }; 00325 00326 CGAL_END_NAMESPACE 00327 00328 #endif // CGAL_LINE_ARC_2_H 00329 00330