BWAPI
|
00001 00002 // Copyright (c) 2006 Tel-Aviv University (Israel). 00003 // All rights reserved. 00004 // 00005 // This file is part of CGAL (www.cgal.org); you may redistribute it under 00006 // the terms of the Q Public License version 1.0. 00007 // See the file LICENSE.QPL distributed with CGAL. 00008 // 00009 // Licensees holding a valid commercial license may use this file in 00010 // accordance with the commercial license agreement provided with the software. 00011 // 00012 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00013 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00014 // 00015 // $URL: 00016 // $Id: 00017 // 00018 // 00019 // Author(s) : Ophir Setter <ophir.setter@cs.au.ac.il> 00020 00021 00022 #ifndef CGAL_ARR_GEODESIC_ARC_ON_SPHERE_PARTITION_TRAITS_2_H 00023 #define CGAL_ARR_GEODESIC_ARC_ON_SPHERE_PARTITION_TRAITS_2_H 00024 00040 #include <CGAL/Arr_geodesic_arc_on_sphere_traits_2.h> 00041 00042 #include <vector> 00043 00044 CGAL_BEGIN_NAMESPACE 00045 00046 00047 template <class T_Kernel, class Container_P = 00048 std::vector<typename Arr_geodesic_arc_on_sphere_traits_2< T_Kernel >::Point_2> > 00049 class Arr_geodesic_arc_on_sphere_partition_traits_2 00050 : public Arr_geodesic_arc_on_sphere_traits_2< T_Kernel > 00051 { 00052 private: 00053 typedef Arr_geodesic_arc_on_sphere_partition_traits_2< T_Kernel > Self; 00054 typedef Arr_geodesic_arc_on_sphere_traits_2< T_Kernel > Base; 00055 00056 public: 00057 00059 00060 00061 typedef typename Base::Point_2 Point_2; 00062 00066 class Polygon_2 : public Container_P 00067 { 00068 public: 00069 typedef typename Container_P::const_iterator Vertex_const_iterator; 00070 00071 Vertex_const_iterator vertices_begin() const 00072 { return this->begin();} 00073 00074 Vertex_const_iterator vertices_end() const 00075 { return this->end();} 00076 }; 00077 00080 class Less_xy_2 00081 { 00082 protected: 00084 const Self * m_traits; 00085 00086 public: 00090 Less_xy_2(const Self * traits) : m_traits(traits) {} 00091 00102 bool operator()(const Point_2 & p1, const Point_2 & p2) const 00103 { 00104 CGAL_precondition(p1.is_no_boundary()); 00105 CGAL_precondition(p2.is_no_boundary()); 00106 00107 // compare y and then x (reverse the order of x and y). 00108 Comparison_result res = m_traits->compare_y(p1, p2); 00109 if (res == EQUAL) 00110 return m_traits->compare_x(p1, p2) == SMALLER; 00111 return res == SMALLER; 00112 // return m_traits->compare_xy(p1, p2) == SMALLER; 00113 } 00114 }; 00115 00116 Less_xy_2 less_xy_2_object() const { return Less_xy_2(this); } 00117 00120 class Less_yx_2 00121 { 00122 protected: 00124 const Self * m_traits; 00125 00126 public: 00127 00131 Less_yx_2(const Self * traits) : m_traits(traits) {} 00132 00133 00144 bool operator()(const Point_2 & p1, const Point_2 & p2) const 00145 { 00146 CGAL_precondition(p1.is_no_boundary()); 00147 CGAL_precondition(p2.is_no_boundary()); 00148 00149 // compare x and then y (reverse the order of x and y). 00150 return m_traits->compare_xy(p1, p2) == SMALLER; 00151 } 00152 }; 00153 00154 Less_yx_2 less_yx_2_object() const { return Less_yx_2(this); } 00155 00156 00159 class Orientation_2 00160 { 00161 protected: 00163 const Self * m_traits; 00164 00165 public: 00166 00170 Orientation_2 (const Self * traits) : m_traits(traits) {} 00171 00187 CGAL::Orientation operator()(const Point_2 &p, 00188 const Point_2 &q, 00189 const Point_2 &r) const 00190 { 00191 CGAL_precondition(p.is_no_boundary()); 00192 CGAL_precondition(q.is_no_boundary()); 00193 CGAL_precondition(r.is_no_boundary()); 00194 00195 // the orientation is determined by the relative position of r with 00196 // respect to the plane that contains p and q. 00197 typename Base::Vector_3 normal = 00198 m_traits->construct_cross_product_vector_3_object() (p.vector(), 00199 q.vector()); 00200 00201 Oriented_side res = CGAL::sign(normal * r.vector()); 00202 00203 return (res == ON_NEGATIVE_SIDE) ? RIGHT_TURN : 00204 ((res == ON_POSITIVE_SIDE) ? LEFT_TURN : COLLINEAR); 00205 } 00206 }; 00207 00208 Orientation_2 orientation_2_object() const { return Orientation_2(this); } 00209 00213 class Left_turn_2 00214 { 00215 protected: 00216 const Self * m_traits; 00217 00218 public: 00219 Left_turn_2 (const Self * traits) : m_traits(traits) {} 00220 00221 bool operator()(const Point_2 &p, 00222 const Point_2 &q, 00223 const Point_2 &r) const 00224 { 00225 return m_traits->orientation_2_object()(p, q, r) == LEFT_TURN; 00226 } 00227 }; 00228 00229 Left_turn_2 left_turn_2_object() const { return Left_turn_2(this); } 00230 00234 typedef typename Base::Compare_x_2 Compare_y_2; 00235 00236 Compare_y_2 compare_y_2_object() const {return Base::compare_x_2_object(); } 00237 00238 00241 class Compare_x_2 00242 { 00243 protected: 00245 const Self * m_traits; 00246 00247 public: 00248 00252 Compare_x_2(const Self * traits) : m_traits(traits) {} 00253 00254 00265 Comparison_result operator()(const Point_2 & p1, const Point_2 & p2) const 00266 { 00267 CGAL_precondition(p1.is_no_boundary()); 00268 CGAL_precondition(p2.is_no_boundary()); 00269 00270 // compare y and then x (reverse the order of x and y). 00271 return m_traits->compare_y(p1, p2); 00272 } 00273 }; 00274 00275 Compare_x_2 compare_x_2_object() const { return Compare_x_2(this); } 00276 00278 00282 00283 00284 struct Is_convex_2 00285 { 00286 template <typename T> Is_convex_2(T) {} 00287 00288 template<class InputIterator> 00289 bool operator ()(InputIterator first, InputIterator beyond) const 00290 { return true; } 00291 }; 00292 00293 Is_convex_2 is_convex_2_object() const { return Is_convex_2(); } 00294 00295 struct Is_valid 00296 { 00297 template <typename T> Is_valid(T) {} 00298 00299 template<class InputIterator> 00300 bool operator ()(InputIterator first, InputIterator beyond) const 00301 { return true; } 00302 }; 00303 00304 // Is_valid is_valid_object() const { return Is_valid(); } 00305 00307 00308 }; 00309 00310 00311 CGAL_END_NAMESPACE 00312 00313 #endif // CGAL_ARR_GEODESIC_ARC_ON_SPHERE_PARTITION_TRAITS_2_H 00314 00315 00316 // Copyright (c) 2006 Tel-Aviv University (Israel). 00317 // All rights reserved. 00318 // 00319 // This file is part of CGAL (www.cgal.org); you may redistribute it under 00320 // the terms of the Q Public License version 1.0. 00321 // See the file LICENSE.QPL distributed with CGAL. 00322 // 00323 // Licensees holding a valid commercial license may use this file in 00324 // accordance with the commercial license agreement provided with the software. 00325 // 00326 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00327 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00328 // 00329 // $URL: 00330 // $Id: 00331 // 00332 // 00333 // Author(s) : Ophir Setter <ophir.setter@cs.au.ac.il> 00334 00335 00336 #ifndef CGAL_ARR_GEODESIC_ARC_ON_SPHERE_PARTITION_TRAITS_2_H 00337 #define CGAL_ARR_GEODESIC_ARC_ON_SPHERE_PARTITION_TRAITS_2_H 00338 00354 #include <CGAL/Arr_geodesic_arc_on_sphere_traits_2.h> 00355 00356 #include <vector> 00357 00358 CGAL_BEGIN_NAMESPACE 00359 00360 00361 template <class T_Kernel, class Container_P = std::vector< 00362 typename Arr_geodesic_arc_on_sphere_traits_2< T_Kernel >::Point_2> > 00363 class Arr_geodesic_arc_on_sphere_partition_traits_2 00364 : public Arr_geodesic_arc_on_sphere_traits_2< T_Kernel > 00365 { 00366 private: 00367 typedef Arr_geodesic_arc_on_sphere_partition_traits_2< T_Kernel > Self; 00368 typedef Arr_geodesic_arc_on_sphere_traits_2< T_Kernel > Base; 00369 00370 public: 00371 00373 00374 00375 typedef typename Base::Point_2 Point_2; 00376 00380 class Polygon_2 : public Container_P 00381 { 00382 public: 00383 typedef typename Container_P::const_iterator Vertex_const_iterator; 00384 00385 Vertex_const_iterator vertices_begin() const 00386 { return this->begin();} 00387 00388 Vertex_const_iterator vertices_end() const 00389 { return this->end();} 00390 }; 00391 00394 class Less_xy_2 00395 { 00396 protected: 00398 const Self * m_traits; 00399 00400 public: 00401 00405 Less_xy_2(const Self * traits) : m_traits(traits) {} 00406 00417 bool operator()(const Point_2 & p1, const Point_2 & p2) const 00418 { 00419 CGAL_precondition(p1.is_no_boundary()); 00420 CGAL_precondition(p2.is_no_boundary()); 00421 00422 // compare y and then x (reverse the order of x and y). 00423 Comparison_result res = m_traits->compare_y(p1, p2); 00424 if (res == EQUAL) 00425 return compare_x(p1, p2) == SMALLER; 00426 return res == SMALLER; 00427 // return m_traits->compare_xy(p1, p2) == SMALLER; 00428 } 00429 }; 00430 00431 Less_xy_2 less_xy_2_object() const { return Less_xy_2(this); } 00432 00435 class Less_yx_2 00436 { 00437 protected: 00439 const Self * m_traits; 00440 00441 public: 00442 00446 Less_yx_2(const Self * traits) : m_traits(traits) {} 00447 00458 bool operator()(const Point_2 & p1, const Point_2 & p2) const 00459 { 00460 CGAL_precondition(p1.is_no_boundary()); 00461 CGAL_precondition(p2.is_no_boundary()); 00462 00463 // compare x and then y (reverse the order of x and y). 00464 return m_traits->compare_xy(p1, p2) == SMALLER; 00465 } 00466 }; 00467 00468 Less_yx_2 less_yx_2_object() const { return Less_yx_2(this); } 00469 00470 00473 class Orientation_2 00474 { 00475 protected: 00477 const Self * m_traits; 00478 00479 public: 00480 00484 Orientation_2 (const Self * traits) : m_traits(traits) {} 00485 00501 CGAL::Orientation operator()(const Point_2 &p, 00502 const Point_2 &q, 00503 const Point_2 &r) const 00504 { 00505 CGAL_precondition(p.is_no_boundary()); 00506 CGAL_precondition(q.is_no_boundary()); 00507 CGAL_precondition(r.is_no_boundary()); 00508 00509 // the orientation is determined by the relative position of r with 00510 // respect to the plane that contains p and q. 00511 typename Base::Vector_3 normal = 00512 m_traits->construct_cross_product_vector_3_object() (p.vector(), 00513 q.vector()); 00514 00515 Oriented_side res = m_traits->oriented_side(normal, r); 00516 00517 return (res == ON_NEGATIVE_SIDE) ? RIGHT_TURN : 00518 ((res == ON_POSITIVE_SIDE) ? LEFT_TURN : COLLINEAR); 00519 } 00520 }; 00521 00522 Orientation_2 orientation_2_object() const { return Orientation_2(this); } 00523 00527 class Left_turn_2 00528 { 00529 protected: 00530 const Self * m_traits; 00531 00532 public: 00533 00534 Left_turn_2 (const Self * traits) : m_traits(traits) {} 00535 00536 bool operator()(const Point_2 &p, 00537 const Point_2 &q, 00538 const Point_2 &r) const 00539 { 00540 return m_traits->orientation_2_object()(p, q, r) == LEFT_TURN; 00541 } 00542 }; 00543 00544 Left_turn_2 left_turn_2_object() const { return Left_turn_2(this); } 00545 00549 typedef typename Base::Compare_x_2 Compare_y_2; 00550 00551 Compare_y_2 compare_y_2_object() const {return Base::compare_x_2_object(); } 00552 00555 class Compare_x_2 00556 { 00557 protected: 00559 const Self * m_traits; 00560 00561 public: 00562 00566 Compare_x_2(const Self * traits) : m_traits(traits) {} 00567 00578 Comparison_result operator()(const Point_2 & p1, const Point_2 & p2) const 00579 { 00580 CGAL_precondition(p1.is_no_boundary()); 00581 CGAL_precondition(p2.is_no_boundary()); 00582 00583 // compare y and then x (reverse the order of x and y). 00584 return m_traits->compare_y(p1, p2); 00585 } 00586 }; 00587 00588 Compare_x_2 compare_x_2_object() const { return Compare_x_2(this); } 00589 00591 00595 00596 00597 class Is_convex_2 00598 { 00599 template<class InputIterator> 00600 bool operator ()(InputIterator first, InputIterator beyond) const 00601 { return true; } 00602 }; 00603 00604 Is_convex_2 is_convex_2_object() const { return Is_convex_2(); } 00605 00607 00608 }; 00609 00610 00611 CGAL_END_NAMESPACE 00612 00613 #endif // CGAL_ARR_GEODESIC_ARC_ON_SPHERE_PARTITION_TRAITS_2_H