BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Arr_bounded_planar_topology_traits_2.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_bounded_planar_topology_traits_2.h $
00015 // $Id: Arr_bounded_planar_topology_traits_2.h 50366 2009-07-05 12:56:48Z efif $
00016 // 
00017 //
00018 // Author(s) : Ron Wein        <wein@post.tau.ac.il>
00019 //             Efi Fogel       <efif@post.tau.ac.il>
00020 //             Eric Berberich  <ericb@post.tau.ac.il>
00021 
00022 #ifndef CGAL_ARR_BOUNDED_PLANAR_TOPOLOGY_TRAITS_2_H
00023 #define CGAL_ARR_BOUNDED_PLANAR_TOPOLOGY_TRAITS_2_H
00024 
00029 #include <CGAL/Arr_tags.h>
00030 #include <CGAL/Arr_topology_traits/Arr_planar_topology_traits_base_2.h>
00031 #include <CGAL/Arr_topology_traits/Arr_bounded_planar_construction_helper.h>
00032 #include <CGAL/Arr_topology_traits/Arr_bounded_planar_insertion_helper.h>
00033 #include <CGAL/Arr_topology_traits/Arr_bounded_planar_overlay_helper.h>
00034 #include <CGAL/Arr_topology_traits/Arr_bounded_planar_batched_pl_helper.h>
00035 #include <CGAL/Arr_topology_traits/Arr_bounded_planar_vert_decomp_helper.h>
00036 #include <CGAL/Arr_topology_traits/Arr_inc_insertion_zone_visitor.h>
00037 
00038 CGAL_BEGIN_NAMESPACE
00039 
00040 // Forward declaration:
00041 template <class GeomTraits_, class TopTraits_> 
00042 class Arrangement_on_surface_2;
00043 
00048 template <class GeomTraits_,
00049           class Dcel_ = Arr_default_dcel<GeomTraits_> >
00050 class Arr_bounded_planar_topology_traits_2 :
00051   public Arr_planar_topology_traits_base_2<GeomTraits_, Dcel_>
00052 {
00053 private:
00054 
00055   typedef Arr_planar_topology_traits_base_2<GeomTraits_, Dcel_> Base;
00056 
00057 public:
00058 
00060 
00061   typedef GeomTraits_                                     Geometry_traits_2;
00062   typedef typename Base::Point_2                          Point_2;
00063   typedef typename Base::X_monotone_curve_2               X_monotone_curve_2;
00065 
00067 
00068   typedef Dcel_                                           Dcel;
00069   typedef typename Base::Size                             Size;
00070   typedef typename Base::Vertex                           Vertex;
00071   typedef typename Base::Halfedge                         Halfedge;
00072   typedef typename Base::Face                             Face;
00073   typedef typename Base::Outer_ccb                        Outer_ccb;
00074   typedef typename Base::Inner_ccb                        Inner_ccb;
00075   typedef typename Base::Isolated_vertex                  Isolated_vertex;
00077 
00078   // TODO remove adaptor as top-traits might be instantiated by Aos_2 itself
00079   typedef Arr_traits_basic_adaptor_2<Geometry_traits_2>   Traits_adaptor_2;
00080   
00081   typedef Arr_bounded_planar_topology_traits_2<Geometry_traits_2, Dcel>
00082                                                           Self;
00083   
00085 
00086   // are inherited from the geometry traits
00087   typedef typename Traits_adaptor_2::Arr_left_side_tag   Arr_left_side_tag;
00088   typedef typename Traits_adaptor_2::Arr_bottom_side_tag Arr_bottom_side_tag;
00089   typedef typename Traits_adaptor_2::Arr_top_side_tag    Arr_top_side_tag;
00090   typedef typename Traits_adaptor_2::Arr_right_side_tag  Arr_right_side_tag;
00091   
00092   BOOST_MPL_ASSERT
00093   ((boost::is_same< Arr_left_side_tag, Arr_oblivious_side_tag >));
00094   BOOST_MPL_ASSERT
00095   ((boost::is_same< Arr_bottom_side_tag, Arr_oblivious_side_tag >));
00096   BOOST_MPL_ASSERT
00097   ((boost::is_same< Arr_top_side_tag, Arr_oblivious_side_tag >));
00098   BOOST_MPL_ASSERT
00099   ((boost::is_same< Arr_right_side_tag, Arr_oblivious_side_tag >));
00101 
00106   template<typename T, typename D>
00107   struct rebind
00108   {
00109     typedef Arr_bounded_planar_topology_traits_2<T,D> other;
00110   };
00111 
00112 protected:
00113 
00114   // Data members:
00115   Face               *unb_face;     // The unbounded face.  
00116 
00117   // Copy constructor and assignment operator - not supported.
00118   Arr_bounded_planar_topology_traits_2 (const Self& );
00119   Self& operator= (const Self& );
00120 
00121 public:
00122 
00124 
00125 
00127   Arr_bounded_planar_topology_traits_2 () :
00128     Base(),
00129     unb_face (NULL)
00130   {}
00131 
00133   Arr_bounded_planar_topology_traits_2 (const Geometry_traits_2 *tr) :
00134     Base (tr),
00135     unb_face (NULL)
00136   {}
00137 
00139   void assign (const Self& other);
00141 
00143 
00144 
00146   bool is_empty_dcel () const
00147   {
00148     // An empty bounded arrangement has no edges or vertices.
00149     return (this->m_dcel.size_of_vertices() == 0 &&
00150             this->m_dcel.size_of_halfedges() == 0);
00151   }
00152 
00154   inline bool is_concrete_vertex (const Vertex *) const
00155   {
00156     return (true);
00157   }
00158 
00160   Size number_of_concrete_vertices () const
00161   {
00162     // All vertices are concrete.
00163     return (this->m_dcel.size_of_vertices());
00164   }
00165 
00167   inline bool is_valid_vertex (const Vertex *) const
00168   {
00169     return (true);
00170   }
00171 
00173   Size number_of_valid_vertices () const
00174   {
00175     // All vertices are valid.
00176     return (this->m_dcel.size_of_vertices());
00177   }
00178 
00180   inline bool is_valid_halfedge (const Halfedge *) const
00181   {
00182     return (true);
00183   }
00184 
00186   Size number_of_valid_halfedges () const
00187   {
00188     // All halfedges are valid.
00189     return (this->m_dcel.size_of_halfedges());
00190   }
00191 
00193   inline bool is_valid_face (const Face *) const
00194   {
00195     return (true);
00196   }
00197 
00199   Size number_of_valid_faces () const
00200   {
00201     // All faces are valid.
00202     return (this->m_dcel.size_of_faces());
00203   }
00205 
00206 private:
00207 
00209 
00210   typedef Arrangement_on_surface_2<Geometry_traits_2, Self>    Arr;
00211 
00212   // Type definition for the constuction sweep-line visitor.
00213   typedef Arr_construction_subcurve<Geometry_traits_2>         CSubcurve; 
00214   typedef Arr_construction_event<Geometry_traits_2,
00215                                  CSubcurve,
00216                                  Arr>                          CEvent;
00217   typedef Arr_bounded_planar_construction_helper<Geometry_traits_2,
00218                                                  Arr,
00219                                                  CEvent,
00220                                                  CSubcurve>    CHelper;
00221 
00222   // Type definition for the basic insertion sweep-line visitor.
00223   typedef Arr_basic_insertion_traits_2<Geometry_traits_2, Arr> BInsTraits;
00224   typedef Arr_construction_subcurve<BInsTraits>                BISubcurve; 
00225   typedef Arr_construction_event<BInsTraits,
00226                                  BISubcurve,
00227                                  Arr>                          BIEvent;
00228   typedef Arr_bounded_planar_insertion_helper<BInsTraits,
00229                                               Arr,
00230                                               BIEvent,
00231                                               BISubcurve>      BIHelper;
00232 
00233   // Type definition for the insertion sweep-line visitor.
00234   typedef Arr_insertion_traits_2<Geometry_traits_2, Arr>       InsTraits;
00235   typedef Arr_construction_subcurve<InsTraits>                 ISubcurve; 
00236   typedef Arr_construction_event<InsTraits,
00237                                  ISubcurve,
00238                                  Arr>                          IEvent;
00239   typedef Arr_bounded_planar_insertion_helper<InsTraits,
00240                                               Arr,
00241                                               IEvent,
00242                                               ISubcurve>       IHelper;
00243 
00244   // Type definition for the batched point-location sweep-line visitor.
00245   typedef Arr_batched_point_location_traits_2<Arr>             BplTraits;
00246   typedef Arr_bounded_planar_batched_pl_helper<BplTraits, Arr> BplHelper;
00247 
00248   // Type definition for the vertical decomposition sweep-line visitor.
00249   typedef Arr_batched_point_location_traits_2<Arr>             VdTraits;
00250   typedef Arr_bounded_planar_vert_decomp_helper<VdTraits, Arr> VdHelper;
00251 
00252   // Type definition for the overlay sweep-line visitor.
00253   template <class ExGeomTraits_, class ArrangementA_, class ArrangementB_>
00254   struct _Overlay_helper : public Arr_bounded_planar_overlay_helper
00255       <ExGeomTraits_, ArrangementA_, ArrangementB_, Arr,
00256        Arr_construction_event<ExGeomTraits_,
00257                               Arr_overlay_subcurve<ExGeomTraits_>,
00258                               Arr>,
00259        Arr_overlay_subcurve<ExGeomTraits_> >
00260   {
00261     typedef Arr_bounded_planar_overlay_helper
00262               <ExGeomTraits_, ArrangementA_, ArrangementB_, Arr,
00263                Arr_construction_event<ExGeomTraits_,
00264                                       Arr_overlay_subcurve<ExGeomTraits_>,
00265                                       Arr>,
00266                Arr_overlay_subcurve<ExGeomTraits_> >     Base;
00267 
00268     typedef typename Base::Traits_2                      Traits_2;
00269     typedef typename Base::Arrangement_red_2             Arrangement_red_2;
00270     typedef typename Base::Arrangement_blue_2            Arrangement_blue_2;
00271     typedef typename Base::Arrangement_2                 Arrangement_2;
00272     typedef typename Base::Event                         Event;
00273     typedef typename Base::Subcurve                      Subcurve;
00274     typedef typename Base::Construction_helper           Construction_helper;
00275 
00276     _Overlay_helper (const ArrangementA_ *arrA,
00277                      const ArrangementB_ *arrB) :
00278       Base (arrA, arrB)
00279     {}
00280   };
00282 
00283 public:
00284 
00286 
00287 
00288   typedef Arr_construction_sl_visitor<CHelper>
00289                              Sweep_line_construction_visitor;
00290 
00291   typedef Arr_insertion_sl_visitor<IHelper>
00292                              Sweep_line_insertion_visitor;
00293 
00294   typedef Sweep_line_construction_visitor
00295                              Sweep_line_non_intersecting_construction_visitor;
00296   
00297   typedef Arr_basic_insertion_sl_visitor<BIHelper>
00298                              Sweep_line_non_intersecting_insertion_visitor;
00299 
00300   template <class OutputIterator_>
00301   struct Sweep_line_bacthed_point_location_visitor :
00302     public Arr_batched_pl_sl_visitor<BplHelper, OutputIterator_>
00303   {
00304     typedef OutputIterator_                                   Output_iterator;
00305     typedef Arr_batched_pl_sl_visitor<BplHelper,
00306                                       Output_iterator>        Base;
00307 
00308     typedef typename Base::Traits_2                           Traits_2;
00309     typedef typename Base::Event                              Event;
00310     typedef typename Base::Subcurve                           Subcurve;
00311 
00312     Sweep_line_bacthed_point_location_visitor (const Arr *arr,
00313                                                Output_iterator *oi) :
00314       Base (arr, oi)
00315     {}
00316   };
00317 
00318   template <class OutputIterator_>
00319   struct Sweep_line_vertical_decomposition_visitor :
00320     public Arr_vert_decomp_sl_visitor<VdHelper, OutputIterator_>
00321   {
00322     typedef OutputIterator_                                   Output_iterator;
00323     typedef Arr_vert_decomp_sl_visitor<VdHelper,
00324                                        Output_iterator>       Base;
00325 
00326     typedef typename Base::Traits_2                           Traits_2;
00327     typedef typename Base::Event                              Event;
00328     typedef typename Base::Subcurve                           Subcurve;
00329 
00330     Sweep_line_vertical_decomposition_visitor (const Arr *arr,
00331                                                Output_iterator *oi) :
00332       Base (arr, oi)
00333     {}
00334   };
00335 
00336   template <class ArrangementA_, class ArrangementB_, class OverlayTraits_>
00337   struct Sweep_line_overlay_visitor :
00338     public Arr_overlay_sl_visitor <
00339       _Overlay_helper<
00340         Arr_overlay_traits_2< Arr_traits_basic_adaptor_2<Geometry_traits_2>,
00341                               ArrangementA_,
00342                               ArrangementB_>,
00343         ArrangementA_, 
00344         ArrangementB_>,
00345       OverlayTraits_>
00346   {
00347     typedef ArrangementA_                            ArrangementA_2;
00348     typedef ArrangementB_                            ArrangementB_2;
00349     typedef Arr                                      Arrangement_result_2;
00350     typedef OverlayTraits_                           Overlay_traits;
00351 
00352     typedef Arr_overlay_traits_2< 
00353               Arr_traits_basic_adaptor_2<Geometry_traits_2>,
00354               ArrangementA_2,
00355               ArrangementB_2>                        Geom_ovl_traits_2;
00356 
00357     typedef _Overlay_helper<Geom_ovl_traits_2, ArrangementA_2, ArrangementB_2>
00358                                                      Ovl_helper;
00359 
00360     typedef Arr_overlay_sl_visitor<Ovl_helper, Overlay_traits>
00361                                                      Base;
00362 
00363     typedef typename Base::Traits_2                  Traits_2;
00364     typedef typename Base::Event                     Event;
00365     typedef typename Base::Subcurve                  Subcurve;
00366 
00367     Sweep_line_overlay_visitor (const ArrangementA_2 *arrA,
00368                                 const ArrangementB_2 *arrB,
00369                                 Arrangement_result_2 *arr_res,
00370                                 Overlay_traits *overlay_tr) :
00371       Base (arrA, arrB, arr_res, overlay_tr)
00372     {}
00373   };
00374 
00375   typedef Arr_inc_insertion_zone_visitor<Arr>
00376                                               Zone_insertion_visitor;
00377 
00378   typedef Arr_walk_along_line_point_location<Arr>
00379                                               Default_point_location_strategy;
00380 
00382 
00384 
00385 
00389   void init_dcel ();
00390 
00394   void dcel_updated ();
00395 
00406   bool are_equal (const Vertex *v,
00407                   const X_monotone_curve_2& cv, Arr_curve_end ind,
00408                   Arr_parameter_space ps_x, Arr_parameter_space ps_y) const
00409   {
00410     CGAL_assertion (ps_x == ARR_INTERIOR && ps_y == ARR_INTERIOR);
00411 
00412     if (ind == ARR_MIN_END)
00413     {
00414       // Compare v with the left endpoint of cv.
00415       return (this->traits->equal_2_object()
00416               (this->traits->construct_min_vertex_2_object() (cv),
00417                v->point()));
00418     }
00419     else
00420     {
00421       // Compare v with the right endpoint of cv.
00422       return (this->traits->equal_2_object()
00423               (this->traits->construct_max_vertex_2_object() (cv),
00424                v->point()));
00425     }
00426   }
00427 
00440   CGAL::Object place_boundary_vertex (Face *,
00441                                       const X_monotone_curve_2&,
00442                                       Arr_curve_end,
00443                                       Arr_parameter_space /* ps_x */,
00444                                       Arr_parameter_space /* ps_y */)
00445   {
00446     // This function should never be called:
00447     CGAL_error();
00448     return Object();
00449   }
00450 
00463   Halfedge*
00464   locate_around_boundary_vertex (Vertex *,
00465                                  const X_monotone_curve_2&,
00466                                  Arr_curve_end,
00467                                  Arr_parameter_space /* ps_x */,
00468                                  Arr_parameter_space /* ps_y */) const
00469   {
00470     CGAL_error();
00471     return (NULL);
00472   }
00473 
00483   CGAL::Object locate_curve_end (const X_monotone_curve_2&,
00484                                  Arr_curve_end,
00485                                  Arr_parameter_space /* ps_x */,
00486                                  Arr_parameter_space /* ps_y */)
00487   {
00488     // This function should never be called:
00489     CGAL_error();
00490     return Object();
00491   }
00492 
00501   Halfedge* split_fictitious_edge (Halfedge *, Vertex *)
00502   {
00503     // This function should never be called:
00504     CGAL_error();
00505     return (NULL);
00506   }
00507 
00513   bool is_unbounded (const Face *f) const
00514   {
00515     // There is only one unbounded face in the arrangement:
00516     return (f == unb_face);
00517   }
00518 
00524   bool is_redundant (const Vertex *) const
00525   {
00526     // There are no redundant vertices.
00527     return (false);
00528   }
00529 
00537   Halfedge* erase_redundant_vertex (Vertex *)
00538   {
00539     // This function should never be called:
00540     CGAL_error();
00541     return (NULL);
00542   }
00543 
00545 
00550   const Face* reference_face() const
00551   {
00552     return unbounded_face();
00553   }
00554  
00556 
00561   Face* reference_face()
00562   {
00563     return unbounded_face();
00564   }
00565 
00567 
00569 
00570 
00572   const Face* initial_face () const
00573   {
00574     return (unb_face);
00575   }
00576 
00578   const Face* unbounded_face () const
00579   {
00580     return (unb_face);
00581   }
00582 
00584   Face* unbounded_face ()
00585   {
00586     return (unb_face);
00587   }
00589 
00591 
00592 
00599   virtual Comparison_result compare_x (const Point_2& p,
00600                                        const Vertex* v) const
00601   {
00602     return (this->traits->compare_x_2_object() (p, v->point()));
00603   }
00604 
00611   virtual Comparison_result compare_xy (const Point_2& p,
00612                                         const Vertex* v) const
00613   {
00614     return (this->traits->compare_xy_2_object() (p, v->point()));
00615   }
00616 
00625   virtual Comparison_result compare_y_at_x (const Point_2& p,
00626                                             const Halfedge* he) const
00627   {
00628     return (this->traits->compare_y_at_x_2_object() (p, he->curve()));
00629   }
00631 };
00632 
00633 CGAL_END_NAMESPACE
00634 
00635 #include <CGAL/Arr_topology_traits/Arr_bounded_planar_topology_traits_2_impl.h>
00636 
00637 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines