BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Segment_Delaunay_graph_2/Are_same_points_C2.h
Go to the documentation of this file.
00001 // Copyright (c) 2003,2004,2005,2006  INRIA Sophia-Antipolis (France) and
00002 // Notre Dame University (U.S.A.).  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/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Are_same_points_C2.h $
00015 // $Id: Are_same_points_C2.h 45156 2008-08-26 13:40:26Z spion $
00016 // 
00017 //
00018 // Author(s)     : Menelaos Karavelas <mkaravel@cse.nd.edu>
00019 
00020 
00021 #ifndef CGAL_SEGMENT_DELAUNAY_GRAPH_2_ARE_SAME_POINTS_C2_H
00022 #define CGAL_SEGMENT_DELAUNAY_GRAPH_2_ARE_SAME_POINTS_C2_H
00023 
00024 #include <CGAL/Segment_Delaunay_graph_2/basic.h>
00025 
00026 CGAL_BEGIN_NAMESPACE
00027 
00028 CGAL_SEGMENT_DELAUNAY_GRAPH_2_BEGIN_NAMESPACE
00029 
00030 template<class K>
00031 class Are_same_points_C2
00032 {
00033 private:
00034   typedef typename K::Point_2     Point_2;
00035   typedef typename K::Segment_2   Segment_2;
00036   typedef typename K::Site_2      Site_2;
00037   typedef typename K::Compare_x_2 Compare_x_2;
00038   typedef typename K::Compare_y_2 Compare_y_2;
00039   typedef typename K::Boolean     Boolean;
00040 
00041   typedef typename K::Intersections_tag  ITag;
00042 
00043   Compare_x_2 compare_x_2;
00044   Compare_y_2 compare_y_2;
00045 
00046   Boolean   are_same(const Point_2& p, const Point_2& q) const
00047   {
00048     return
00049       compare_x_2(p, q) == EQUAL && compare_y_2(p, q) == EQUAL;
00050   }
00051 
00052   Boolean   are_same(const Site_2& s, const Site_2& t) const
00053   {
00054     return
00055       ( are_same(s.source(), t.source()) &&
00056         are_same(s.target(), t.target()) ) ||
00057       ( are_same(s.source(), t.target()) &&
00058         are_same(s.target(), t.source()) );
00059   }
00060 
00061   Boolean   predicate(const Site_2& p, const Site_2& q, const Tag_false&) const
00062   {
00063     return are_same(p.point(), q.point()); 
00064   }
00065 
00066   Boolean   predicate(const Site_2& p, const Site_2& q, const Tag_true&) const
00067   {
00068     if ( !p.is_input() && !q.is_input() ) {
00069       Site_2 s[2] = { p.supporting_site(0), p.supporting_site(1) };
00070       Site_2 t[2] = { q.supporting_site(0), q.supporting_site(1) };
00071 
00072       if (  ( are_same(s[0], t[0]) && are_same(s[1], t[1]) ) ||
00073             ( are_same(s[0], t[1]) && are_same(s[1], t[0]) )  ) {
00074         return true;
00075       }
00076     }
00077 
00078     return predicate(p, q, Tag_false());
00079   }
00080 
00081 public:
00082   typedef Boolean        result_type;
00083   typedef Site_2         argument_type;
00084 
00085   Boolean   operator()(const Site_2& p, const Site_2& q) const
00086   {
00087     CGAL_precondition( p.is_point() && q.is_point() );
00088 
00089     return predicate(p, q, ITag());
00090   }
00091 };
00092 
00093 CGAL_SEGMENT_DELAUNAY_GRAPH_2_END_NAMESPACE
00094 
00095 CGAL_END_NAMESPACE
00096 
00097 #endif // CGAL_SEGMENT_DELAUNAY_GRAPH_2_ARE_SAME_POINTS_C2_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines