BWAPI
|
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/Boolean_set_operations_2/include/CGAL/Boolean_set_operations_2/Gps_bfs_xor_visitor.h $ 00015 // $Id: Gps_bfs_xor_visitor.h 48113 2009-02-17 16:21:43Z ophirset $ 00016 // 00017 // 00018 // Author(s) : Baruch Zukerman <baruchzu@post.tau.ac.il> 00019 // Ophir Setter <ophir.setter@cs.tau.ac.il> 00020 00021 #ifndef CGAL_GPS_BFS_XOR_VISITOR_H 00022 #define CGAL_GPS_BFS_XOR_VISITOR_H 00023 00024 #include <CGAL/Boolean_set_operations_2/Gps_bfs_base_visitor.h> 00025 00026 CGAL_BEGIN_NAMESPACE 00027 00028 template <class Arrangement_> 00029 class Gps_bfs_xor_visitor : 00030 public Gps_bfs_base_visitor<Arrangement_, Gps_bfs_xor_visitor<Arrangement_> > 00031 { 00032 typedef Arrangement_ Arrangement; 00033 typedef typename Arrangement::Face_iterator Face_iterator; 00034 typedef typename Arrangement::Halfedge_iterator Halfedge_iterator; 00035 typedef Gps_bfs_xor_visitor<Arrangement> Self; 00036 typedef Gps_bfs_base_visitor<Arrangement, Self> Base; 00037 typedef typename Base::Edges_hash Edges_hash; 00038 typedef typename Base::Faces_hash Faces_hash; 00039 00040 public: 00041 00042 Gps_bfs_xor_visitor(Edges_hash* edges_hash, Faces_hash* faces_hash, 00043 unsigned int n_pgn) : 00044 Base(edges_hash, faces_hash, n_pgn) 00045 {} 00046 00048 00053 bool contained_criteria(unsigned int ic) 00054 { 00055 // xor means odd number of polygons. 00056 return (ic % 2) == 1; 00057 } 00058 00060 00065 void after_scan(Arrangement& arr) 00066 { 00067 typedef typename Arrangement::Geometry_traits_2 Traits; 00068 typedef typename Traits::Compare_endpoints_xy_2 Compare_endpoints_xy_2; 00069 typedef typename Traits::Construct_opposite_2 Construct_opposite_2; 00070 typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2; 00071 typedef typename Arrangement::Edge_iterator Edge_iterator; 00072 00073 Traits tr; 00074 Compare_endpoints_xy_2 cmp_endpoints = 00075 tr.compare_endpoints_xy_2_object(); 00076 Construct_opposite_2 ctr_opp = tr.construct_opposite_2_object(); 00077 00078 for(Edge_iterator eit = arr.edges_begin(); 00079 eit != arr.edges_end(); 00080 ++eit) 00081 { 00082 Halfedge_iterator he = eit; 00083 const X_monotone_curve_2& cv = he->curve(); 00084 const bool is_cont = he->face()->contained(); 00085 const Comparison_result he_res = 00086 ((Arr_halfedge_direction)he->direction() == ARR_LEFT_TO_RIGHT) ? 00087 SMALLER : LARGER; 00088 const bool has_same_dir = (cmp_endpoints(cv) == he_res); 00089 00090 if ((is_cont && !has_same_dir) || (!is_cont && has_same_dir)) 00091 arr.modify_edge(he, ctr_opp(cv)); 00092 } 00093 } 00094 00095 }; 00096 00097 CGAL_END_NAMESPACE 00098 00099 #endif