BWAPI
|
00001 // Copyright (c) 1997 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_unb_planar_overlay_helper.h $ 00015 // $Id: Arr_unb_planar_overlay_helper.h 49772 2009-06-03 21:25:53Z eric $ 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_UNB_PLANAR_OVERLAY_HELPER_H 00023 #define CGAL_ARR_UNB_PLANAR_OVERLAY_HELPER_H 00024 00029 #include <CGAL/Arr_topology_traits/Arr_unb_planar_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_unb_planar_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::Halfedge_const_handle 00059 Halfedge_handle_red; 00060 typedef typename Arrangement_red_2::Face_const_handle Face_handle_red; 00061 typedef typename Arrangement_red_2::Vertex_const_handle Vertex_handle_red; 00062 00063 typedef ArrangementBlue_ Arrangement_blue_2; 00064 typedef typename Arrangement_blue_2::Halfedge_const_handle 00065 Halfedge_handle_blue; 00066 typedef typename Arrangement_blue_2::Face_const_handle Face_handle_blue; 00067 typedef typename Arrangement_blue_2::Vertex_const_handle 00068 Vertex_handle_blue; 00069 00070 // Define the helper class for the construction visitor. 00071 typedef Arr_unb_planar_construction_helper<Traits_2, 00072 Arrangement_2, 00073 Event, 00074 Subcurve> Construction_helper; 00075 00076 protected: 00077 00078 // Data members: 00079 const typename Arrangement_red_2::Topology_traits *m_red_top_traits; 00080 const typename Arrangement_blue_2::Topology_traits *m_blue_top_traits; 00081 00082 Halfedge_handle_red m_red_th; // Red top fictitious halfedge. 00083 Halfedge_handle_blue m_blue_th; // Blue top fictitious halfedge. 00084 00085 Vertex_handle_red v_red_tl; // Red top-left fictitious vertex. 00086 Vertex_handle_blue v_blue_tl; // Blue top-left fictitious vertex. 00087 00088 public: 00089 00091 Arr_unb_planar_overlay_helper (const Arrangement_red_2 *red_arr, 00092 const Arrangement_blue_2 *blue_arr) : 00093 m_red_top_traits (red_arr->topology_traits()), 00094 m_blue_top_traits (blue_arr->topology_traits()) 00095 {} 00096 00098 00099 00100 /* A notification issued before the sweep process starts. */ 00101 void before_sweep (); 00102 00107 void before_handle_event (Event* e); 00109 00111 Face_handle_red red_top_face () const 00112 { 00113 return (m_red_th->face()); 00114 } 00115 00117 Face_handle_blue blue_top_face () const 00118 { 00119 return (m_blue_th->face()); 00120 } 00121 }; 00122 00123 //----------------------------------------------------------------------------- 00124 // Memeber-function definitions: 00125 //----------------------------------------------------------------------------- 00126 00127 //----------------------------------------------------------------------------- 00128 // A notification issued before the sweep process starts. 00129 // 00130 template <class Tr, class ArrR, class ArrB, class Arr, class Evnt, class Sbcv> 00131 void Arr_unb_planar_overlay_helper<Tr,ArrR,ArrB,Arr,Evnt,Sbcv>::before_sweep () 00132 { 00133 // Get the top-left fictitious vertices in both arrangements. 00134 v_red_tl = Vertex_handle_red (m_red_top_traits->top_left_vertex()); 00135 v_blue_tl = Vertex_handle_blue (m_blue_top_traits->top_left_vertex()); 00136 00137 // Get the fictitious halfedges incident to the bottom-left fictitious 00138 // vertices in both red and blue arrangements. If there are no vertices 00139 // at x = -oo, we take the halfedge incident to the top-left vertex that 00140 // lies on the top edge of the fictitious face. 00141 Vertex_handle_red v_red_bl = 00142 Vertex_handle_red (m_red_top_traits->bottom_left_vertex()); 00143 00144 m_red_th = v_red_bl->incident_halfedges(); 00145 00146 if (m_red_th->source()->parameter_space_in_x() != ARR_LEFT_BOUNDARY) 00147 m_red_th = m_red_th->next()->twin(); 00148 00149 if (m_red_th->source() == v_red_tl) 00150 m_red_th = m_red_th->prev(); 00151 00152 Vertex_handle_blue v_blue_bl = 00153 Vertex_handle_blue (m_blue_top_traits->bottom_left_vertex()); 00154 00155 m_blue_th = v_blue_bl->incident_halfedges(); 00156 if (m_blue_th->source()->parameter_space_in_x() != ARR_LEFT_BOUNDARY) 00157 m_blue_th = m_blue_th->next()->twin(); 00158 00159 if (m_blue_th->source() == v_blue_tl) 00160 m_blue_th = m_blue_th->prev(); 00161 00162 return; 00163 } 00164 00165 //----------------------------------------------------------------------------- 00166 // A notification invoked before the sweep-line starts handling the given 00167 // event. 00168 // 00169 template <class Tr, class ArrR, class ArrB, class Arr, class Evnt, class Sbcv> 00170 void Arr_unb_planar_overlay_helper<Tr,ArrR,ArrB,Arr,Evnt,Sbcv>:: 00171 before_handle_event (Event* e) 00172 { 00173 // Nothing to do in case the event represents a valid point. 00174 if (e->is_closed()) 00175 return; 00176 00177 // In case the event occurs on the left edge of the fictitious face (x = -oo) 00178 // or on its top edge (finite x and y = +oo), update the fictitious top 00179 // halfedges. 00180 if (e->parameter_space_in_x() == ARR_LEFT_BOUNDARY || 00181 (e->parameter_space_in_x() == ARR_INTERIOR && 00182 e->parameter_space_in_y() == ARR_TOP_BOUNDARY)) 00183 { 00184 switch (e->curve().color()) 00185 { 00186 case (Traits_2::RED) : 00187 // Update the red top fictitious halfedge. 00188 m_red_th = m_red_th->twin()->next()->twin(); 00189 if (m_red_th->source() == v_red_tl) 00190 m_red_th = m_red_th->prev(); 00191 break; 00192 00193 case (Traits_2::BLUE) : 00194 // Update the blue top fictitious halfedge. 00195 m_blue_th = m_blue_th->twin()->next()->twin(); 00196 if (m_blue_th->source() == v_blue_tl) 00197 m_blue_th = m_blue_th->prev(); 00198 break; 00199 00200 case Traits_2::RB_OVERLAP : 00201 // Update both red and blue top fictitious halfedges. 00202 m_red_th = m_red_th->twin()->next()->twin(); 00203 if (m_red_th->source() == v_red_tl) 00204 m_red_th = m_red_th->prev(); 00205 00206 m_blue_th = m_blue_th->twin()->next()->twin(); 00207 if (m_blue_th->source() == v_blue_tl) 00208 m_blue_th = m_blue_th->prev(); 00209 00210 break; 00211 } 00212 } 00213 00214 return; 00215 } 00216 00217 CGAL_END_NAMESPACE 00218 00219 #endif