BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Arr_topology_traits/Arr_unb_planar_insertion_helper.h
Go to the documentation of this file.
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_unb_planar_insertion_helper.h $
00015 // $Id: Arr_unb_planar_insertion_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_INSERTION_HELPER_H
00023 #define CGAL_ARR_UNB_PLANAR_INSERTION_HELPER_H
00024 
00029 #include <CGAL/Sweep_line_2/Arr_construction_sl_visitor.h>
00030 #include <CGAL/Arr_topology_traits/Arr_unb_planar_construction_helper.h>
00031 
00032 CGAL_BEGIN_NAMESPACE
00033 
00039 template <class Traits_, class Arrangement_, class Event_, class Subcurve_> 
00040 class Arr_unb_planar_insertion_helper :
00041   public Arr_unb_planar_construction_helper<Traits_, Arrangement_,
00042                                             Event_, Subcurve_>
00043 {
00044 public:
00045 
00046   typedef Traits_                                      Traits_2;
00047   typedef Arrangement_                                 Arrangement_2;
00048   typedef Event_                                       Event;
00049   typedef Subcurve_                                    Subcurve;
00050 
00051   typedef typename Traits_2::X_monotone_curve_2        X_monotone_curve_2;
00052   typedef typename Traits_2::Point_2                   Point_2;
00053 
00054 
00055   typedef Arr_unb_planar_construction_helper<Traits_2, Arrangement_2, Event,
00056                                              Subcurve> Base;
00057 
00058   typedef Sweep_line_empty_visitor<Traits_2, Subcurve, Event>
00059                                                        Base_visitor;
00060 
00061   typedef Arr_unb_planar_insertion_helper<Traits_2, Arrangement_2, Event,
00062                                           Subcurve>    Self;
00063 
00064   typedef Arr_construction_sl_visitor<Self>            Parent_visitor;
00065 
00066   typedef typename Arrangement_2::Face_handle          Face_handle;
00067 
00068   typedef typename Base::Indices_list                  Indices_list;
00069   typedef typename Base::Halfedge_indices_map          Halfedge_indices_map;
00070 
00071 protected:
00072 
00073   typedef typename Base::Topology_traits               Topology_traits;
00074   typedef typename Base::Vertex_handle                 Vertex_handle;
00075   typedef typename Base::Halfedge_handle               Halfedge_handle;
00076   
00077 public:
00078  
00080   Arr_unb_planar_insertion_helper (Arrangement_2 *arr) :
00081     Base (arr)
00082   {}
00083 
00085   virtual ~Arr_unb_planar_insertion_helper(){}
00086 
00088 
00089 
00090   /* A notification issued before the sweep process starts. */
00091   virtual void before_sweep ();
00092 
00097   virtual void before_handle_event (Event* event);
00099 };
00100 
00101 //-----------------------------------------------------------------------------
00102 // Memeber-function definitions:
00103 //-----------------------------------------------------------------------------
00104 
00105 //-----------------------------------------------------------------------------
00106 // A notification issued before the sweep process starts.
00107 //
00108 template <class Tr, class Arr, class Evnt, class Sbcv> 
00109 void Arr_unb_planar_insertion_helper<Tr,Arr,Evnt,Sbcv>::before_sweep ()
00110 {
00111   // Obtain the four fictitious vertices that form the "corners" of the
00112   // fictitious face in the DCEL.
00113   Vertex_handle   v_bl =
00114     Vertex_handle (this->m_top_traits->bottom_left_vertex());
00115   Vertex_handle   v_tl = 
00116     Vertex_handle (this->m_top_traits->top_left_vertex());
00117   Vertex_handle   v_br = 
00118     Vertex_handle (this->m_top_traits->bottom_right_vertex());
00119 
00120   // Get the fictitous halfedges incident to these vertices, and lying on
00121   // the left, right, top and bottom edges of the fictitious face.
00122   //
00123   //            m_th
00124   //  v_tl (.)<---x      (.) v_tr
00125   //                      ^
00126   //        x             | m_rh
00127   //   m_lh |             x
00128   //        v              
00129   //  v_bl (.)----->x    (.) v_br
00130   //              m_bh
00131   //
00132   this->m_lh = v_bl->incident_halfedges();
00133 
00134   if (this->m_lh->source()->parameter_space_in_x() != ARR_LEFT_BOUNDARY)
00135     this->m_lh = this->m_lh->next()->twin();
00136    
00137   this->m_bh = this->m_lh->next();
00138   
00139   this->m_th = v_tl->incident_halfedges();
00140   if (this->m_th->source()->parameter_space_in_x() == ARR_LEFT_BOUNDARY)
00141     this->m_th = this->m_th->next()->twin();
00142 
00143   this->m_rh = v_br->incident_halfedges();
00144   if (this->m_rh->source()->parameter_space_in_x() == ARR_RIGHT_BOUNDARY)
00145     this->m_rh = this->m_rh->twin();
00146   else
00147     this->m_rh = this->m_rh->next();
00148 
00149   CGAL_assertion_code (
00150     Face_handle fict_face = Face_handle (this->m_top_traits->fictitious_face());
00151   );
00152   CGAL_assertion (this->m_lh->direction() == ARR_RIGHT_TO_LEFT);
00153   CGAL_assertion (this->m_lh->face() != fict_face);
00154   CGAL_assertion (this->m_lh->target() == v_bl);
00155 
00156   CGAL_assertion (this->m_bh->direction() == ARR_LEFT_TO_RIGHT);
00157   CGAL_assertion (this->m_bh->face() != fict_face);
00158   CGAL_assertion (this->m_bh->source() == v_bl);
00159 
00160   CGAL_assertion (this->m_rh->direction() == ARR_LEFT_TO_RIGHT);
00161   CGAL_assertion (this->m_rh->face() != fict_face);
00162   CGAL_assertion (this->m_rh->source() == v_br);
00163 
00164   CGAL_assertion (this->m_th->direction() == ARR_RIGHT_TO_LEFT);
00165   CGAL_assertion (this->m_th->face() != fict_face);
00166   CGAL_assertion (this->m_th->target() == v_tl);
00167 }
00168 
00169 //-----------------------------------------------------------------------------
00170 // A notification invoked before the sweep-line starts handling the given
00171 // event.
00172 //
00173 template <class Tr, class Arr, class Evnt, class Sbcv> 
00174 void Arr_unb_planar_insertion_helper<Tr,Arr,Evnt,Sbcv>::
00175 before_handle_event (Event* event)
00176 {
00177   if (event->is_closed())
00178     return;
00179 
00180   // In case the event lies at inifinity, check whether its incident curve
00181   // is already in the arrangement.
00182   if (event->curve().halfedge_handle() == Halfedge_handle())
00183   {
00184     // The curve is not in the arrangement, use the base construction helper
00185     // to handle the event:
00186     Base::before_handle_event (event);
00187     return;
00188   }
00189 
00190   // The curve is already in the arrangement, but has an infinite end,
00191   // so we have to update the fictitious halfedges.
00192   const Arr_parameter_space ps_x = event->parameter_space_in_x();
00193       
00194   if (ps_x == ARR_LEFT_BOUNDARY)
00195   {
00196     // The event lies on the left fictitious halfedge.
00197     this->m_lh = this->m_lh->twin()->next()->twin();
00198     this->m_prev_minus_inf_x_event = NULL;
00199   }
00200   else if (ps_x == ARR_RIGHT_BOUNDARY)
00201   {
00202     // The event lies on the right fictitious halfedge.
00203     this->m_rh = this->m_rh->twin()->prev()->twin();
00204   }
00205   else
00206   {
00207     const Arr_parameter_space ps_y = event->parameter_space_in_y();
00208     
00209     if (ps_y == ARR_BOTTOM_BOUNDARY)
00210     {
00211       // The event lies on the bottom fictitious halfedge.
00212       this->m_bh = this->m_bh->twin()->prev()->twin();
00213     }
00214     else
00215     {
00216       // The event lies on the top fictitious halfedge.
00217       CGAL_assertion (ps_y == ARR_TOP_BOUNDARY);
00218       this->m_th = this->m_th->twin()->next()->twin();
00219       this->m_prev_plus_inf_y_event = NULL;
00220     }
00221   }
00222  
00223   return;
00224 }
00225 
00226 
00227 CGAL_END_NAMESPACE
00228 
00229 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines