BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Arr_topology_traits/Arr_unb_planar_vert_decomp_helper.h
Go to the documentation of this file.
00001 // Copyright (c) 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_unb_planar_vert_decomp_helper.h $
00015 // $Id: Arr_unb_planar_vert_decomp_helper.h 49772 2009-06-03 21:25:53Z eric $
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_UNB_PLANAR_VERT_DECOMP_HELPER_H
00022 #define CGAL_ARR_UNB_PLANAR_VERT_DECOMP_HELPER_H
00023 
00028 CGAL_BEGIN_NAMESPACE
00029 
00030 #include <CGAL/Sweep_line_empty_visitor.h>
00031 
00037 template <class Traits_, class Arrangement_>
00038 class Arr_unb_planar_vert_decomp_helper
00039 {
00040 public:
00041 
00042   typedef Traits_                                      Traits_2;
00043   typedef Arrangement_                                 Arrangement_2;
00044 
00045   typedef typename Arrangement_2::Face_const_handle    Face_const_handle;
00046 
00047   typedef Sweep_line_empty_visitor<Traits_2>           Base_visitor;
00048   typedef typename Base_visitor::Event                 Event;
00049   typedef typename Base_visitor::Subcurve              Subcurve;
00050 
00051 protected:
00052 
00053   typedef typename Arrangement_2::Topology_traits       Topology_traits;
00054   typedef typename Arrangement_2::Halfedge_const_handle Halfedge_const_handle;
00055   typedef typename Arrangement_2::Vertex_const_handle   Vertex_const_handle;
00056 
00057   // Data members:
00058   const Topology_traits *m_top_traits;  // The topology-traits class.
00059   Halfedge_const_handle  m_top_fict;    // The current top fictitious halfedge.
00060   Halfedge_const_handle  m_bottom_fict; // The current bottom fictitious
00061                                         // halfedge.
00062 
00063 public:
00064 
00069   Arr_unb_planar_vert_decomp_helper (const Arrangement_2 *arr) :
00070     m_top_traits (arr->topology_traits())
00071   {}
00072 
00074 
00075 
00076   /* A notification issued before the sweep process starts. */
00077   void before_sweep ();
00078 
00083   void after_handle_event (Event* event);
00085 
00087   CGAL::Object top_object () const
00088   {
00089     // Wrap the top fictitious halfedge by a CGAL object.
00090     return (CGAL::make_object (m_top_fict));
00091   }
00092 
00094   CGAL::Object bottom_object () const
00095   {
00096     // Wrap the bottom fictitious halfedge by a CGAL object.
00097     return (CGAL::make_object (m_bottom_fict));
00098   }
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>
00109 void Arr_unb_planar_vert_decomp_helper<Tr, Arr>::before_sweep ()
00110 {
00111   // Initialize the fictitious halfedge lying on the top edge of the
00112   // bounding rectangle. We start from the leftmost halfedge, which is
00113   // incident to the top-left vertex and directed from right to left.
00114   Vertex_const_handle  v_tl = 
00115     Vertex_const_handle (m_top_traits->top_left_vertex());
00116 
00117   m_top_fict = v_tl->incident_halfedges();
00118   if (m_top_fict->direction() == ARR_LEFT_TO_RIGHT)
00119     m_top_fict = m_top_fict->next()->twin();
00120   
00121   CGAL_assertion_code (
00122     Vertex_const_handle  v_tr = 
00123       Vertex_const_handle (m_top_traits->top_right_vertex());
00124   );
00125   CGAL_assertion
00126     ((m_top_fict->source() == v_tr) ||
00127      (m_top_fict->source()->parameter_space_in_x() == ARR_INTERIOR &&
00128       m_top_fict->source()->parameter_space_in_y() == ARR_TOP_BOUNDARY));
00129 
00130   // Initialize the fictitious halfedge lying on the bottom edge of the
00131   // bounding rectangle. We start from the leftmost halfedge, which is
00132   // incident to the bottom-left vertex and whose source is not at -oo.
00133   Vertex_const_handle  v_bl = 
00134     Vertex_const_handle (m_top_traits->bottom_left_vertex());
00135 
00136   m_bottom_fict = v_bl->incident_halfedges();
00137   if (m_bottom_fict->source()->parameter_space_in_x() == ARR_LEFT_BOUNDARY)
00138       m_bottom_fict = m_bottom_fict->next()->twin();
00139 
00140   CGAL_assertion_code (
00141     Vertex_const_handle  v_br = 
00142       Vertex_const_handle (m_top_traits->bottom_right_vertex());
00143   );
00144   CGAL_assertion
00145     ((m_bottom_fict->source() == v_br) ||
00146      (m_bottom_fict->source()->parameter_space_in_x() == ARR_INTERIOR &&
00147       m_bottom_fict->source()->parameter_space_in_y() == ARR_BOTTOM_BOUNDARY));
00148 
00149   return;
00150 }
00151 
00152 //-----------------------------------------------------------------------------
00153 // A notification invoked after the sweep-line finishes handling the given
00154 // event.
00155 //
00156 template <class Tr, class Arr>
00157 void Arr_unb_planar_vert_decomp_helper<Tr, Arr>::
00158 after_handle_event (Event* event)
00159 {
00160   // If the event is at infinity and occurs on the top edge of the fictitious
00161   // face (namely x is finite and y = +oo), we have to update the fictitious
00162   // halfedges we keep.
00163   if (event->is_closed())
00164     return;
00165 
00166   if (event->parameter_space_in_x() != ARR_INTERIOR)
00167     return;
00168 
00169   Arr_parameter_space     ps_y = event->parameter_space_in_y();
00170 
00171   if (ps_y == ARR_TOP_BOUNDARY)
00172   {
00173     // Update the fictitious top halfedge.
00174     m_top_fict = m_top_fict->twin()->next()->twin();
00175   }
00176   else
00177   {
00178     CGAL_assertion (ps_y == ARR_BOTTOM_BOUNDARY);
00179 
00180     // Update the fictitious bottom halfedge.
00181     m_bottom_fict = m_bottom_fict->prev();
00182   }
00183 
00184   return;
00185 }
00186 
00187 CGAL_END_NAMESPACE
00188 
00189 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines