BWAPI
|
00001 // Copyright (c) 2006-2007 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_insertion_helper.h $ 00015 // $Id: Arr_spherical_insertion_helper.h 41118 2007-12-07 14:25:32Z efif $ 00016 // 00017 // 00018 // Author(s) : Ron Wein <wein@post.tau.ac.il> 00019 // Efi Fogel <efif@post.tau.ac.il> 00020 00021 #ifndef CGAL_ARR_SPHERICAL_INSERTION_HELPER_H 00022 #define CGAL_ARR_SPHERICAL_INSERTION_HELPER_H 00023 00028 #include <CGAL/Sweep_line_2/Arr_construction_sl_visitor.h> 00029 #include <CGAL/Arr_topology_traits/Arr_spherical_construction_helper.h> 00030 00031 CGAL_BEGIN_NAMESPACE 00032 00038 template <class Traits_, class Arrangement_, class Event_, class Subcurve_> 00039 class Arr_spherical_insertion_helper : 00040 public Arr_spherical_construction_helper<Traits_, Arrangement_, 00041 Event_, Subcurve_> 00042 { 00043 public: 00044 00045 typedef Traits_ Traits_2; 00046 typedef Arrangement_ Arrangement_2; 00047 typedef Event_ Event; 00048 typedef Subcurve_ Subcurve; 00049 00050 typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; 00051 typedef typename Traits_2::Point_2 Point_2; 00052 00053 typedef Arr_spherical_construction_helper<Traits_2, Arrangement_2, Event, 00054 Subcurve> Base; 00055 00056 typedef Sweep_line_empty_visitor<Traits_2, Subcurve, Event> 00057 Base_visitor; 00058 00059 typedef Arr_spherical_insertion_helper<Traits_2, Arrangement_2, Event, 00060 Subcurve> Self; 00061 00062 typedef Arr_construction_sl_visitor<Self> Parent_visitor; 00063 00064 typedef typename Arrangement_2::Face_handle Face_handle; 00065 typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; 00066 00067 typedef typename Base::Indices_list Indices_list; 00068 typedef typename Base::Halfedge_indices_map Halfedge_indices_map; 00069 00070 public: 00072 Arr_spherical_insertion_helper (Arrangement_2 *arr) : 00073 Base (arr) 00074 {} 00075 00077 virtual ~Arr_spherical_insertion_helper () 00078 {} 00079 00081 00082 00083 /* A notification issued before the sweep process starts. */ 00084 virtual void before_sweep() 00085 { 00086 // Get the unbounded face. 00087 this->m_spherical_face = Face_handle(this->m_top_traits->south_face()); 00088 } 00089 00094 virtual void before_handle_event (Event* event); 00096 00097 }; 00098 00099 //----------------------------------------------------------------------------- 00100 // Memeber-function definitions: 00101 //----------------------------------------------------------------------------- 00102 00103 //----------------------------------------------------------------------------- 00104 // A notification invoked before the sweep-line starts handling the given 00105 // event. 00106 // 00107 template <class Tr, class Arr, class Evnt, class Sbcv> 00108 void Arr_spherical_insertion_helper<Tr,Arr,Evnt,Sbcv>::before_handle_event 00109 (Event* event) 00110 { 00111 // Ignore events that do not have boundary conditions. 00112 const Arr_parameter_space ps_x = event->parameter_space_in_x(); 00113 const Arr_parameter_space ps_y = event->parameter_space_in_y(); 00114 00115 if (ps_x == ARR_INTERIOR && ps_y == ARR_INTERIOR) 00116 return; 00117 00118 // The is exactly one curve incident to an event with boundary conditions. 00119 // Obtain this curve and check whether it already exists in the arrangement. 00120 CGAL_assertion(((event->number_of_left_curves() == 0) && 00121 (event->number_of_right_curves() == 1)) || 00122 ((event->number_of_left_curves() == 1) && 00123 (event->number_of_right_curves() == 0))); 00124 00125 const Arr_curve_end ind = 00126 (event->number_of_left_curves() == 0 && 00127 event->number_of_right_curves() == 1) ? ARR_MIN_END : ARR_MAX_END; 00128 const X_monotone_curve_2& xc = (ind == ARR_MIN_END) ? 00129 (*(event->right_curves_begin()))->last_curve() : 00130 (*(event->left_curves_begin()))->last_curve(); 00131 00132 if (xc.halfedge_handle() == Halfedge_handle()) 00133 { 00134 // The curve is not in the arrangement, use the base construction helper 00135 // to handle the event: 00136 Base::before_handle_event (event); 00137 return; 00138 } 00139 00140 // In case we encounter an existing curve incident to the curve of 00141 // discontinuity (and exteding to its right) or to the north pole, 00142 // we have to update the current top face (the spherical face). 00143 if (ps_y == ARR_TOP_BOUNDARY) 00144 { 00145 this->m_spherical_face = (ind == ARR_MIN_END) ? 00146 xc.halfedge_handle()->twin()->face() : xc.halfedge_handle()->face(); 00147 } 00148 else if (ps_x == ARR_LEFT_BOUNDARY) 00149 { 00150 CGAL_assertion (ind == ARR_MIN_END); 00151 this->m_spherical_face = xc.halfedge_handle()->twin()->face(); 00152 } 00153 00154 return; 00155 } 00156 00157 CGAL_END_NAMESPACE 00158 00159 #endif