BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Arr_topology_traits/Arr_spherical_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_spherical_vert_decomp_helper.h $
00015 // $Id: Arr_spherical_vert_decomp_helper.h 41118 2007-12-07 14:25:32Z efif $
00016 // 
00017 // Author(s)     : Ron Wein <wein@post.tau.ac.il>
00018 //                 Efi Fogel <efif@post.tau.ac.il>
00019 //
00020 
00021 #ifndef CGAL_ARR_SPHERICAL_VERT_DECOMP_HELPER_H
00022 #define CGAL_ARR_SPHERICAL_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_spherical_vert_decomp_helper
00039 {
00040 public:
00041 
00042   typedef Traits_                                      Traits_2;
00043   typedef typename Traits_2::X_monotone_curve_2        X_monotone_curve_2;
00044   typedef Arrangement_                                 Arrangement_2;
00045 
00046   typedef typename Arrangement_2::Face_const_handle    Face_const_handle;
00047   typedef typename Arrangement_2::Vertex_const_handle  Vertex_const_handle;
00048 
00049   typedef Sweep_line_empty_visitor<Traits_2>           Base_visitor;
00050   typedef typename Base_visitor::Event                 Event;
00051   typedef typename Base_visitor::Subcurve              Subcurve;
00052 
00053 protected:
00054 
00055   typedef typename Arrangement_2::Topology_traits      Topology_traits;
00056 
00057   const Topology_traits  *m_top_traits;        // The topology traits.
00058   Vertex_const_handle     m_north_pole;        // The north pole.
00059   bool                    m_valid_north_pole;  // Is this a valid vertex.
00060   Face_const_handle       m_north_face;        // Current north face.
00061   Vertex_const_handle     m_south_pole;        // The south pole.
00062   bool                    m_valid_south_pole;  // Is this a valid vertex.
00063   Face_const_handle       m_south_face;        // Current south face.
00064 
00065 public:
00066 
00070   Arr_spherical_vert_decomp_helper(const Arrangement_2 *arr) :
00071     m_top_traits(arr->topology_traits())
00072   {}
00073 
00075 
00076 
00078   void before_sweep();
00079 
00084   void after_handle_event(Event * event);
00086 
00088   CGAL::Object top_object () const
00089   {
00090     return (m_valid_north_pole) ?
00091       CGAL::make_object (m_north_pole) : CGAL::make_object (m_north_face);
00092   }
00093 
00095   CGAL::Object bottom_object () const
00096   {
00097     return (m_valid_south_pole) ?
00098       CGAL::make_object(m_south_pole) : CGAL::make_object(m_south_face);
00099   }
00100 };
00101 
00102 //-----------------------------------------------------------------------------
00103 // Memeber-function definitions:
00104 //-----------------------------------------------------------------------------
00105 
00106 //-----------------------------------------------------------------------------
00107 // A notification issued before the sweep process starts.
00108 //
00109 template <class Tr, class Arr> 
00110 void Arr_spherical_vert_decomp_helper<Tr, Arr>::before_sweep()
00111 {
00112   // Get the north pole and the face that intially contains it.
00113   m_valid_north_pole = (m_top_traits->north_pole() != NULL);
00114   if (m_valid_north_pole)
00115     m_north_pole = Vertex_const_handle (m_top_traits->north_pole());
00116 
00117   m_north_face = Face_const_handle (m_top_traits->spherical_face());
00118 
00119   // Get the south pole and the face that intially contains it.
00120   m_valid_south_pole = (m_top_traits->south_pole() != NULL);
00121   if (m_valid_south_pole)
00122     m_south_pole = Vertex_const_handle (m_top_traits->south_pole());
00123 
00124   m_south_face = Face_const_handle (m_top_traits->south_face());
00125 }
00126 
00127 //-----------------------------------------------------------------------------
00128 // A notification invoked after the sweep-line finishes handling the given
00129 // event.
00131 template <class Tr, class Arr>
00132 void
00133 Arr_spherical_vert_decomp_helper<Tr, Arr>::after_handle_event (Event *event)
00134 {
00135   // Ignore events that are not incident to the poles.
00136   if (event->parameter_space_in_y() == ARR_INTERIOR)
00137     return;
00138 
00139   // The is exactly one curve incident to an event with boundary conditions.
00140   // Obtain this curve and check whether it already exists in the arrangement.
00141   CGAL_assertion(((event->number_of_left_curves() == 0) &&
00142                   (event->number_of_right_curves() == 1)) ||
00143                  ((event->number_of_left_curves() == 1) &&
00144                   (event->number_of_right_curves() == 0)));
00145 
00146   const Arr_curve_end   ind =
00147     (event->number_of_left_curves() == 0 &&
00148      event->number_of_right_curves() == 1) ? ARR_MIN_END : ARR_MAX_END;
00149   const X_monotone_curve_2& xc = (ind == ARR_MIN_END) ?
00150     (*(event->right_curves_begin()))->last_curve() :
00151     (*(event->left_curves_begin()))->last_curve();
00152 
00153   if (event->parameter_space_in_y() == ARR_TOP_BOUNDARY)
00154   {
00155     // The event is incident to the north pole: update the north face.
00156     if (ind == ARR_MIN_END)
00157       m_north_face = xc.halfedge_handle()->twin()->face();
00158     else
00159       m_north_face = xc.halfedge_handle()->face();
00160   }
00161   else if (event->parameter_space_in_y() == ARR_BOTTOM_BOUNDARY)
00162   {
00163     // The event is incident to the south pole: update the south face.
00164     if (ind == ARR_MIN_END)
00165       m_south_face = xc.halfedge_handle()->face();
00166     else
00167       m_south_face = xc.halfedge_handle()->twin()->face();
00168   }
00169 
00170   return;
00171 }
00172 
00173 CGAL_END_NAMESPACE
00174 
00175 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines