BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Sweep_line_2.h
Go to the documentation of this file.
00001 // Copyright (c) 2005  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.h $
00015 // $Id: Sweep_line_2.h 50366 2009-07-05 12:56:48Z efif $
00016 // 
00017 //
00018 // Author(s)     : Baruch Zukerman <baruchzu@post.tau.ac.il>
00019 //                 (based on old version by Tali Zvi)
00020 
00021 #ifndef CGAL_SWEEP_LINE_2_H
00022 #define CGAL_SWEEP_LINE_2_H
00023 
00028 #include <list>
00029 #include <CGAL/Object.h>
00030 #include <CGAL/Basic_sweep_line_2.h>
00031 #include <CGAL/Sweep_line_2/Sweep_line_curve_pair.h>
00032 #include <CGAL/Arrangement_2/Open_hash.h>
00033 
00034 CGAL_BEGIN_NAMESPACE
00035 
00075 template < class Traits_,
00076            class Visitor_,
00077            class Subcurve_ = Sweep_line_subcurve<Traits_>,
00078            class Event_ = Sweep_line_event<Traits_, Subcurve_>,
00079            typename Allocator_ = CGAL_ALLOCATOR(int) >
00080 class Sweep_line_2 : public Basic_sweep_line_2<Traits_,
00081                                                Visitor_,
00082                                                Subcurve_,
00083                                                Event_,
00084                                                Allocator_>
00085 {
00086 public:
00087 
00088   typedef Traits_                                        Traits_2;
00089   typedef Visitor_                                       Visitor;
00090   typedef Event_                                         Event;
00091   typedef Subcurve_                                      Subcurve;
00092   typedef Allocator_                                     Allocator;
00093 
00094   typedef Basic_sweep_line_2<Traits_2,
00095                              Visitor,
00096                              Subcurve,
00097                              Event,
00098                              Allocator>                  Base;
00099 
00100   typedef typename Base::Traits_adaptor_2                Traits_adaptor_2;
00101   typedef typename Traits_adaptor_2::Point_2             Point_2;
00102   typedef typename Traits_adaptor_2::X_monotone_curve_2  X_monotone_curve_2;
00103  
00104   typedef typename Base::Event_queue_iterator         Event_queue_iterator;
00105   typedef typename Event::Subcurve_iterator           Event_subcurve_iterator;
00106 
00107   typedef typename Base::Base_event                   Base_event;
00108   typedef typename Base_event::Attribute              Attribute;
00109 
00110   typedef typename Base::Base_subcurve                Base_subcurve;
00111   
00112   typedef std::list<Subcurve*>                        Subcurve_container;
00113   typedef typename Subcurve_container::iterator       Subcurve_iterator; 
00114 
00115   typedef typename Base::Status_line_iterator         Status_line_iterator;
00116   
00117   typedef CGAL::Curve_pair<Subcurve>                       Curve_pair;
00118   typedef CGAL::Curve_pair_hasher<Subcurve>                Curve_pair_hasher;
00119   typedef CGAL::Equal_curve_pair<Subcurve>                 Equal_curve_pair;
00120   typedef Open_hash<Curve_pair,
00121                     Curve_pair_hasher,
00122                     Equal_curve_pair>                 Curve_pair_set;
00123 
00124   typedef random_access_input_iterator<std::vector<Object> >
00125                                                       vector_inserter;
00126 
00127 protected:
00128 
00129   // Data members:
00130   Subcurve_container  m_overlap_subCurves;
00131                                      // Contains all of the new sub-curves
00132                                      // creaed by an overlap.
00133 
00134   Curve_pair_set m_curves_pair_set;  // A lookup table of pairs of Subcurves
00135                                      // that have been intersected.
00136 
00137   std::vector<Object> m_x_objects;   // Auxiliary vector for storing the
00138                                      // intersection objects.
00139 
00140   X_monotone_curve_2  sub_cv1;       // Auxiliary varibales
00141   X_monotone_curve_2  sub_cv2;       // (for splitting curves).
00142 
00143 public:
00144 
00149   Sweep_line_2 (Visitor * visitor) :
00150     Base(visitor),
00151     m_curves_pair_set(0)
00152   {}
00153 
00154 
00160   Sweep_line_2 (const Traits_2 * traits, Visitor * visitor) :
00161     Base(traits, visitor),
00162     m_curves_pair_set(0)
00163   {}
00164 
00166   virtual ~Sweep_line_2()
00167   {}
00168 
00169 protected:
00170 
00172   virtual void _init_structures ();
00173 
00175   virtual void _complete_sweep ();
00176 
00178   virtual void _handle_left_curves ();
00179 
00181   virtual void _handle_right_curves ();
00182 
00189   virtual bool _add_curve_to_right (Event * event, Subcurve * curve,
00190                                     bool overlap_exist = false);
00191 
00193   void _fix_overlap_subcurves();
00194 
00202   void _handle_overlap (Event * event, Subcurve * curve,
00203                         Event_subcurve_iterator iter, bool overlap_exist);
00204   
00213   void _intersect (Subcurve * c1, Subcurve * c2);
00214 
00222   void _remove_curve_from_status_line (Subcurve * leftCurve,
00223                                        bool remove_for_good);
00224 
00233   void _create_intersection_point (const Point_2 & xp,
00234                                    unsigned int mult,
00235                                    Subcurve *& c1,
00236                                    Subcurve *& c2,
00237                                    bool is_overlap = false);
00238 
00243   void _fix_finished_overlap_subcurve (Subcurve * sc);
00244 
00245 };
00246 
00247 CGAL_END_NAMESPACE
00248 
00249 // The member-function definitions can be found in:
00250 #include <CGAL/Sweep_line_2/Sweep_line_2_impl.h>
00251 
00252 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines