BWAPI
|
00001 // Copyright (c) 2005 Tel-Aviv University (Israel). 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: 00015 // $Id: 00016 // 00017 // 00018 // Author(s) : Ophir Setter <ophirset@post.tau.ac.il> 00019 // 00020 #ifndef CGAL_ARR_DO_INTERSECT_ZONE_VISITOR_H 00021 #define CGAL_ARR_DO_INTERSECT_ZONE_VISITOR_H 00022 00027 CGAL_BEGIN_NAMESPACE 00028 00034 template <class Arrangement_> 00035 class Arr_do_intersect_zone_visitor 00036 { 00037 public: 00038 00039 typedef Arrangement_ Arrangement_2; 00040 00041 typedef typename Arrangement_2::Vertex_handle Vertex_handle; 00042 typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; 00043 typedef typename Arrangement_2::Face_handle Face_handle; 00044 00045 typedef typename Arrangement_2::Point_2 Point_2; 00046 typedef typename Arrangement_2::X_monotone_curve_2 X_monotone_curve_2; 00047 00048 typedef std::pair<Halfedge_handle, bool> Result; 00049 00050 private: 00051 00052 const Halfedge_handle invalid_he; // Invalid halfedge. 00053 const Vertex_handle invalid_v; // Invalid vertex. 00054 00055 bool m_intersect; // Boolean to hold the answer. 00056 00057 public: 00058 00060 Arr_do_intersect_zone_visitor () : 00061 invalid_he (), 00062 invalid_v (), 00063 m_intersect (false) 00064 {} 00065 00067 void init (Arrangement_2 *) 00068 { 00069 m_intersect = false; 00070 } 00071 00087 Result found_subcurve (const X_monotone_curve_2&, 00088 Face_handle, 00089 Vertex_handle left_v, Halfedge_handle left_he, 00090 Vertex_handle right_v, Halfedge_handle right_he) 00091 { 00092 if ((left_v == invalid_v) && (right_v == invalid_v) && 00093 (left_he == invalid_he) && (right_he == invalid_he)) 00094 { 00095 // The current subcurve just lies inside the given face, and its 00096 // endpoints are not incident to any valid vertex or edge, so it does 00097 // not intersect the arrangement. 00098 return (Result (invalid_he, false)); 00099 } 00100 00101 // We found an intersection. Note we return a result indicating that the 00102 // zone-computation can stop here. 00103 m_intersect = true; 00104 return (Result (invalid_he, true)); 00105 } 00106 00118 Result found_overlap (const X_monotone_curve_2&, 00119 Halfedge_handle, 00120 Vertex_handle, Vertex_handle) 00121 { 00122 // We found an overlap (hence an intersection). Note we return a result 00123 // indicating that the zone-computation can stop here. 00124 m_intersect = true; 00125 return (Result (invalid_he, true)); 00126 } 00127 00128 bool do_intersect () const 00129 { 00130 return (m_intersect); 00131 } 00132 }; 00133 00134 CGAL_END_NAMESPACE 00135 00136 #endif