| BWAPI
   
    | 
00001 // Copyright (c) 2005 INRIA Sophia-Antipolis (France). 00002 // All rights reserved. 00003 // 00004 // This file is part of CGAL (www.cgal.org); you can redistribute it and/or 00005 // modify it under the terms of the GNU Lesser General Public License as 00006 // published by the Free Software Foundation; version 2.1 of the License. 00007 // See the file LICENSE.LGPL 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: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Filtered_kernel/include/CGAL/Static_filters/Compare_y_at_x_2.h $ 00016 // $Id: Compare_y_at_x_2.h 44920 2008-08-12 15:23:12Z spion $ 00017 // 00018 // Author(s) : Andreas Meyer 00019 00020 #ifndef CGAL_STATIC_FILTERS_COMPARE_Y_AT_X_2_H 00021 #define CGAL_STATIC_FILTERS_COMPARE_Y_AT_X_2_H 00022 00023 #include <CGAL/Profile_counter.h> 00024 #include <CGAL/Static_filter_error.h> 00025 #include <CGAL/algorithm.h> 00026 00027 CGAL_BEGIN_NAMESPACE 00028 00029 template < typename K_base, typename Kernel > 00030 class SF_Compare_y_at_x_2 00031 : public K_base::Compare_y_at_x_2 00032 { 00033 typedef typename K_base::Point_2 Point_2; 00034 typedef typename K_base::Segment_2 Segment_2; 00035 typedef typename K_base::FT FT; 00036 typedef typename K_base::Compare_y_at_x_2 Base; 00037 00038 public: 00039 00040 using Base::operator(); 00041 00042 Comparison_result 00043 operator()( const Point_2& p, const Segment_2& s ) const { 00044 // compares the y-coordinates of p and the vertical projection of p on s. 00045 // Precondition : p is in the x-range of s. 00046 00047 typename Kernel::Less_x_2 less_x = Kernel().less_x_2_object(); 00048 typename Kernel::Less_y_2 less_y = Kernel().less_y_2_object(); 00049 typename Kernel::Orientation_2 orientation = Kernel().orientation_2_object(); 00050 00051 CGAL_kernel_precondition( are_ordered(s.source(), p, s.target(), less_x) ); 00052 00053 if( less_x( s.source(), s.target() ) ) 00054 return orientation(p, s.source(), s.target()); 00055 else if ( less_x( s.target(), s.source() ) ) 00056 return orientation(p, s.target(), s.source()); 00057 else { 00058 if( less_y(p, s.source()) && less_y(p, s.target()) ) 00059 return SMALLER; 00060 if( less_y(s.source(), p) && less_y(s.target(), p) ) 00061 return LARGER; 00062 return EQUAL; 00063 } 00064 } 00065 }; 00066 00067 CGAL_END_NAMESPACE 00068 00069 #endif
 1.7.6.1
 1.7.6.1