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/Sweep_line_2/Arr_insertion_sl_visitor.h $ 00015 // $Id: Arr_insertion_sl_visitor.h 40964 2007-11-21 10:23:08Z efif $ 00016 // 00017 // 00018 // Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il> 00019 // Ron Wein <wein@post.tau.ac.il> 00020 00021 #ifndef CGAL_ARR_INSERTION_SL_VISITOR_H 00022 #define CGAL_ARR_INSERTION_SL_VISITOR_H 00023 00028 #include <CGAL/Sweep_line_2/Arr_basic_insertion_sl_visitor.h> 00029 00030 CGAL_BEGIN_NAMESPACE 00031 00036 template <class Helper_> 00037 class Arr_insertion_sl_visitor : 00038 public Arr_basic_insertion_sl_visitor<Helper_> 00039 { 00040 public: 00041 00042 typedef Helper_ Helper; 00043 00044 typedef Arr_basic_insertion_sl_visitor<Helper> Base; 00045 00046 typedef typename Base::Traits_2 Traits_2; 00047 typedef typename Base::Arrangement_2 Arrangement_2; 00048 typedef typename Base::Event Event; 00049 typedef typename Base::Subcurve Subcurve; 00050 00051 typedef typename Base::Halfedge_handle Halfedge_handle; 00052 typedef typename Base::X_monotone_curve_2 X_monotone_curve_2; 00053 typedef typename Base::Point_2 Point_2; 00054 00055 private: 00056 00057 X_monotone_curve_2 sub_cv1; // Auxiliary variables 00058 X_monotone_curve_2 sub_cv2; // (used for splitting curves). 00059 00060 public: 00061 00063 Arr_insertion_sl_visitor (Arrangement_2 *arr) : 00064 Base (arr) 00065 {} 00066 00068 00069 00076 virtual bool is_split_event(Subcurve *sc, Event *event); 00077 00085 virtual Halfedge_handle split_edge (Halfedge_handle he, 00086 Subcurve *sc, 00087 const Point_2& pt); 00089 }; 00090 00091 //----------------------------------------------------------------------------- 00092 // Memeber-function definitions: 00093 //----------------------------------------------------------------------------- 00094 00095 //----------------------------------------------------------------------------- 00096 // Check if the halfedge associated with the given subcurve will be split 00097 // at the given event. 00098 // 00099 template <class Hlpr> 00100 bool Arr_insertion_sl_visitor<Hlpr>::is_split_event 00101 (Subcurve *sc, Event *event) 00102 { 00103 if(sc->last_curve().halfedge_handle() == Halfedge_handle(NULL)) 00104 return (false); 00105 00106 if(! sc->originating_subcurve1()) 00107 { 00108 return (reinterpret_cast<Event*>(sc->left_event())!= 00109 this->current_event()); 00110 } 00111 return 00112 (this->is_split_event 00113 (reinterpret_cast<Subcurve*>(sc->originating_subcurve1()), event) || 00114 this->is_split_event 00115 (reinterpret_cast<Subcurve*>(sc->originating_subcurve2()), event)); 00116 } 00117 00118 //----------------------------------------------------------------------------- 00119 // Split an edge. 00120 // 00121 template <class Hlpr> 00122 typename Arr_insertion_sl_visitor<Hlpr>::Halfedge_handle 00123 Arr_insertion_sl_visitor<Hlpr>::split_edge 00124 (Halfedge_handle he, Subcurve *sc, const Point_2& pt) 00125 { 00126 // Make sure that the halfedge associated with sc is the directed from 00127 // right to left, since we always "look" above , and the incident face 00128 //is on the left of the halfedge 00129 CGAL_assertion (he->direction() == ARR_RIGHT_TO_LEFT); 00130 00131 this->traits()->split_2_object() (he->curve(), pt, 00132 sub_cv2, sub_cv1); 00133 00134 Halfedge_handle new_he = 00135 this->m_arr_access.split_edge_ex (he, 00136 pt.base(), 00137 sub_cv1.base(), 00138 sub_cv2.base()); 00139 00140 Event* last_event_on_sc = reinterpret_cast<Event*>(sc->last_event()); 00141 00142 if(last_event_on_sc->halfedge_handle() == he) 00143 last_event_on_sc->set_halfedge_handle(new_he->next()); 00144 00145 return (new_he); 00146 } 00147 00148 CGAL_END_NAMESPACE 00149 00150 #endif