BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Arr_point_location/Arr_lm_middle_edges_generator.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/Arr_point_location/Arr_lm_middle_edges_generator.h $
00015 // $Id: Arr_lm_middle_edges_generator.h 41647 2008-01-16 18:41:36Z golubevs $
00016 // 
00017 //
00018 // Author(s)     : Idit Haran   <haranidi@post.tau.ac.il>
00019 #ifndef CGAL_ARR_LM_MIDDLE_EDGES_GENERATOR_H
00020 #define CGAL_ARR_LM_MIDDLE_EDGES_GENERATOR_H
00021 
00026 #include <CGAL/Arr_point_location/Arr_lm_generator_base.h>
00027 
00028 CGAL_BEGIN_NAMESPACE
00029 
00039 template <class Arrangement_, 
00040           class Nearest_neighbor_ 
00041           = Arr_landmarks_nearest_neighbor <typename Arrangement_::Traits_2> >
00042 class Arr_middle_edges_landmarks_generator 
00043   : public Arr_landmarks_generator_base <Arrangement_, Nearest_neighbor_>
00044 {
00045 public:
00046   typedef Arrangement_                                    Arrangement_2;
00047   typedef Arr_middle_edges_landmarks_generator<Arrangement_2, 
00048                                                Nearest_neighbor_>    Self;
00049   typedef Arr_landmarks_generator_base<Arrangement_2, Nearest_neighbor_>  Base;
00050 
00051   typedef typename Arrangement_2::Traits_2              Traits_2;
00052   typedef typename Arrangement_2::Edge_const_iterator   Edge_const_iterator;
00053   typedef typename Arrangement_2::Vertex_const_handle   Vertex_const_handle;
00054   typedef typename Arrangement_2::Halfedge_const_handle Halfedge_const_handle;
00055   typedef typename Arrangement_2::Face_const_handle     Face_const_handle;
00056   typedef typename Arrangement_2::Vertex_handle         Vertex_handle;
00057   typedef typename Arrangement_2::Halfedge_handle       Halfedge_handle;
00058   typedef typename Arrangement_2::Face_handle           Face_handle;
00059   typedef typename Arrangement_2::Vertex_const_iterator Vertex_const_iterator;
00060   typedef typename Arrangement_2::Ccb_halfedge_circulator
00061                                                        Ccb_halfedge_circulator;
00062   typedef typename Base::NN_Points_set                 NN_Points_set;
00063   typedef typename Base::NN_Point_2                    NN_Point_2;
00064   
00065   typedef typename Traits_2::Point_2                   Point_2;
00066   typedef std::vector<Point_2>                         Points_set;
00067   
00068 private:
00069   
00071   Arr_middle_edges_landmarks_generator (const Self& );
00072   
00074   Self& operator= (const Self& );
00075   
00076   
00077 public: 
00079   Arr_middle_edges_landmarks_generator 
00080   (const Arrangement_2& arr, int /* lm_num */ = -1) : 
00081     Base (arr)
00082   {
00083     //CGAL_PRINT_DEBUG("Arr_middle_edges_landmarks_generator constructor.");
00084     this->build_landmark_set();
00085   }
00086   
00087   //Observer functions that should be empty, because they
00088   // got nothing to do with middle edges
00089   //-------------------------------------------------
00090   virtual void after_create_vertex (Vertex_handle /* v */){}
00091   virtual void after_split_face (Face_handle /* f */,
00092                                  Face_handle /* new_f */, bool /* is_hole */)
00093   {}
00094   virtual void after_add_hole (Ccb_halfedge_circulator /* h */) {}
00095   
00096   virtual void after_merge_face (Face_handle /* f */){}
00097   virtual void after_move_hole (Ccb_halfedge_circulator /* h */){}
00098   virtual void after_remove_vertex () {}
00099   virtual void after_remove_hole (Face_handle /* f */) {}
00100   
00101   
00102 protected:
00107   virtual void _create_nn_points_set (NN_Points_set &nn_points) 
00108   {
00109     //CGAL_PRINT_DEBUG("create_middle_edges_points_list");
00110     Edge_const_iterator    eit;
00111     Halfedge_const_handle  hh;
00112     Arrangement_2 *arr = this->arrangement();
00113 
00114     if(arr->number_of_vertices() == 1)
00115     {
00116       //special treatment for arrangement with one isolated verrtex
00117       Vertex_const_iterator vit = arr->vertices_begin();
00118       CGAL::Object obj = CGAL::make_object(vit);
00119       Point_2 p (vit->point());
00120       NN_Point_2 np(p, obj);
00121       nn_points.push_back(np);
00122 
00123       return;
00124     }
00125     for (eit=arr->edges_begin(); eit != arr->edges_end(); eit++)
00126     {
00127       //get 2 endpoints of edge
00128       hh = eit;
00129       const Point_2& p1 = hh->source()->point();
00130       const Point_2& p2 = hh->target()->point();
00131       Point_2 p ((p1.x()+p2.x())/2, (p1.y()+p2.y())/2);
00132       
00133       //CGAL_PRINT_DEBUG("mid point is= " << p);
00134       
00135       CGAL::Object obj = CGAL::make_object(hh); 
00136       NN_Point_2 np(p, obj); 
00137       nn_points.push_back(np);
00138     } 
00139   }
00140   
00141   virtual void _create_points_set (Points_set & /* points */)
00142   {
00143     std::cerr << "should not reach here!"<< std::endl;
00144     CGAL_error();
00145   }
00146 };
00147 
00148 CGAL_END_NAMESPACE
00149 
00150 #endif
00151 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines