BWAPI
|
00001 // Copyright (c) 2006 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: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Arrangement_on_surface_2/include/CGAL/Arr_topology_traits/Arr_spherical_overlay_helper.h $ 00015 // $Id: Arr_spherical_overlay_helper.h 41118 2007-12-07 14:25:32Z efif $ 00016 // 00017 // 00018 // Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il> 00019 // Ron Wein <wein@post.tau.ac.il> 00020 // Efi Fogel <efif@post.tau.ac.il> 00021 00022 #ifndef CGAL_ARR_SPHERICAL_OVERLAY_HELPER_H 00023 #define CGAL_ARR_SPHERICAL_OVERLAY_HELPER_H 00024 00029 #include <CGAL/Arr_topology_traits/Arr_spherical_construction_helper.h> 00030 00031 CGAL_BEGIN_NAMESPACE 00032 00038 template <class Traits_, 00039 class ArrangementRed_, 00040 class ArrangementBlue_, 00041 class Arrangement_, 00042 class Event_, 00043 class Subcurve_> 00044 class Arr_spherical_overlay_helper 00045 { 00046 public: 00047 00048 typedef Traits_ Traits_2; 00049 typedef Arrangement_ Arrangement_2; 00050 typedef Event_ Event; 00051 typedef Subcurve_ Subcurve; 00052 00053 typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; 00054 typedef typename Traits_2::Point_2 Point_2; 00055 00056 // The input arrangements (the "red" and the "blue" one): 00057 typedef ArrangementRed_ Arrangement_red_2; 00058 typedef typename Arrangement_red_2::Face_const_handle Face_handle_red; 00059 00060 typedef ArrangementBlue_ Arrangement_blue_2; 00061 typedef typename Arrangement_blue_2::Face_const_handle Face_handle_blue; 00062 00063 // Define the helper class for the construction visitor. 00064 typedef Arr_spherical_construction_helper<Traits_2, Arrangement_2, Event, 00065 Subcurve> Construction_helper; 00066 00067 protected: 00068 // Data members: 00069 const typename Arrangement_red_2::Topology_traits * m_red_top_traits; 00070 const typename Arrangement_blue_2::Topology_traits * m_blue_top_traits; 00071 00073 Face_handle_red m_red_nf; 00074 00076 Face_handle_blue m_blue_nf; 00077 00078 public: 00080 Arr_spherical_overlay_helper(const Arrangement_red_2 * red_arr, 00081 const Arrangement_blue_2 * blue_arr) : 00082 m_red_top_traits(red_arr->topology_traits()), 00083 m_blue_top_traits(blue_arr->topology_traits()) 00084 {} 00085 00087 00088 00089 /* A notification issued before the sweep process starts. */ 00090 void before_sweep() 00091 { 00092 // Get the spherical faces in both arrangements. 00093 /* RWRW: 00094 m_red_nf = Face_handle_red(m_red_top_traits->spherical_face()); 00095 m_blue_nf = Face_handle_blue(m_blue_top_traits->spherical_face()); 00096 */ 00097 m_red_nf = Face_handle_red(m_red_top_traits->south_face()); 00098 m_blue_nf = Face_handle_blue(m_blue_top_traits->south_face()); 00099 return; 00100 } 00101 00105 void before_handle_event(Event * event) 00106 { 00107 if (event->parameter_space_in_y() != ARR_TOP_BOUNDARY && 00108 event->parameter_space_in_x() != ARR_LEFT_BOUNDARY) 00109 return; 00110 00111 Arr_curve_end ind = (event->number_of_left_curves() == 0 && 00112 event->number_of_right_curves() != 0) ? 00113 ARR_MIN_END : ARR_MAX_END; 00114 00115 const Subcurve *sc = (ind == ARR_MIN_END) ? 00116 (*(event->right_curves_begin())) : 00117 (*(event->left_curves_begin())); 00118 00119 if (event->parameter_space_in_y() == ARR_TOP_BOUNDARY) 00120 { 00121 // The curve is incident to the north pole. 00122 switch (sc->color()) { 00123 case Traits_2::RED : 00124 if (ind == ARR_MIN_END) 00125 m_red_nf = sc->red_halfedge_handle()->twin()->face(); 00126 else 00127 m_red_nf = sc->red_halfedge_handle()->face(); 00128 break; 00129 00130 case Traits_2::BLUE : 00131 if (ind == ARR_MIN_END) 00132 m_blue_nf = sc->blue_halfedge_handle()->twin()->face(); 00133 else 00134 m_blue_nf = sc->blue_halfedge_handle()->face(); 00135 break; 00136 00137 case Traits_2::RB_OVERLAP : 00138 if (ind == ARR_MIN_END) 00139 { 00140 m_red_nf = sc->red_halfedge_handle()->twin()->face(); 00141 m_blue_nf = sc->blue_halfedge_handle()->twin()->face(); 00142 } 00143 else 00144 { 00145 m_red_nf = sc->red_halfedge_handle()->face(); 00146 m_blue_nf = sc->blue_halfedge_handle()->face(); 00147 } 00148 break; 00149 } 00150 } 00151 else 00152 { 00153 // The curve extends to the right from the curve of discontinuity. 00154 CGAL_assertion (ind == ARR_MIN_END); 00155 switch (sc->color()) { 00156 case Traits_2::RED : 00157 m_red_nf = sc->red_halfedge_handle()->twin()->face(); 00158 break; 00159 00160 case Traits_2::BLUE : 00161 m_blue_nf = sc->blue_halfedge_handle()->twin()->face(); 00162 break; 00163 00164 case Traits_2::RB_OVERLAP : 00165 m_red_nf = sc->red_halfedge_handle()->twin()->face(); 00166 m_blue_nf = sc->blue_halfedge_handle()->twin()->face(); 00167 break; 00168 } 00169 } 00170 00171 return; 00172 } 00174 00176 Face_handle_red red_top_face() const 00177 { 00178 return m_red_nf; 00179 } 00180 00182 Face_handle_blue blue_top_face() const 00183 { 00184 return m_blue_nf; 00185 } 00186 }; 00187 00188 CGAL_END_NAMESPACE 00189 00190 #endif