~ubuntu-branches/debian/stretch/cgal/stretch

« back to all changes in this revision

Viewing changes to include/CGAL/Boolean_set_operations_2/Gps_polygon_simplifier.h

  • Committer: Package Import Robot
  • Author(s): Joachim Reichel
  • Date: 2014-04-05 10:56:43 UTC
  • mfrom: (1.2.4)
  • Revision ID: package-import@ubuntu.com-20140405105643-jgnrpu2thtx23zfs
Tags: 4.4-1
* New upstream release.
* Remove patches do-not-link-example-with-qt4-support-library.patch and
  fix_jet_fitting_3.patch (applied upstream).

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
//
15
15
// $URL$
16
16
// $Id$
17
 
// 
 
17
//
18
18
//
19
19
// Author(s)     : Baruch Zukerman <baruchzu@post.tau.ac.il>
20
20
 
30
30
#include <CGAL/Boolean_set_operations_2/Gps_bfs_scanner.h>
31
31
#include <CGAL/Boolean_set_operations_2/Gps_bfs_join_visitor.h>
32
32
 
33
 
#include <CGAL/Unique_hash_map.h> 
 
33
#include <CGAL/Unique_hash_map.h>
34
34
#include <CGAL/Arr_accessor.h>
35
 
#include <CGAL/iterator.h> 
 
35
#include <CGAL/iterator.h>
36
36
 
37
37
namespace CGAL {
38
38
 
55
55
  typedef typename Arrangement_2::Face_iterator       Face_iterator;
56
56
  typedef typename Arrangement_2::Edge_iterator       Edge_iterator;
57
57
  typedef typename Arrangement_2::Vertex_handle       Vertex_handle;
58
 
  typedef typename Arrangement_2::Ccb_halfedge_const_circulator 
 
58
  typedef typename Arrangement_2::Ccb_halfedge_const_circulator
59
59
                                                      Ccb_halfedge_const_circulator;
60
 
  typedef typename Arrangement_2::Ccb_halfedge_circulator 
 
60
  typedef typename Arrangement_2::Ccb_halfedge_circulator
61
61
                                                      Ccb_halfedge_circulator;
62
 
  typedef Arr_construction_subcurve<Meta_traits>      Subcurve; 
 
62
  typedef Arr_construction_subcurve<Meta_traits>      Subcurve;
63
63
  typedef Arr_construction_event<Meta_traits,
64
64
                                 Subcurve,
65
65
                                 Arrangement_2>       Event;
74
74
                             Subcurve,
75
75
                             Event>                   Sweep_line_2;
76
76
 
77
 
  typedef Unique_hash_map<Halfedge_handle, 
 
77
  typedef Unique_hash_map<Halfedge_handle,
78
78
                          unsigned int>               Edges_hash;
79
79
 
80
 
  typedef Unique_hash_map<Face_handle, 
 
80
  typedef Unique_hash_map<Face_handle,
81
81
                          unsigned int>               Faces_hash;
82
82
  typedef Gps_bfs_join_visitor<Arrangement_2>         Bfs_visitor;
83
83
  typedef Gps_bfs_scanner<Arrangement_2, Bfs_visitor> Bfs_scanner;
85
85
protected:
86
86
  Arrangement_2*       m_arr;
87
87
  Meta_traits*         m_traits;
 
88
  bool                 m_own_traits;
88
89
  Visitor              m_visitor;
89
90
  Sweep_line_2         m_sweep_line;
90
91
  Edges_hash           m_edges_hash; // maps halfedge to its BC (boundary counter)
92
93
 
93
94
public:
94
95
   /*! Constructor. */
95
 
  Gps_polygon_simplifier (Arrangement_2& arr, Traits_2& tr) :
96
 
    m_arr (&arr),
 
96
  Gps_polygon_simplifier(Arrangement_2& arr, Traits_2& tr) :
 
97
    m_arr(&arr),
97
98
    m_traits(new Meta_traits(tr)),
98
 
    m_visitor (&arr, &m_edges_hash),
99
 
    m_sweep_line (m_traits, &m_visitor)
 
99
    m_own_traits(true),
 
100
    m_visitor(&arr, &m_edges_hash),
 
101
    m_sweep_line(m_traits, &m_visitor)
100
102
  {}
101
103
 
 
104
  /*! Destructor. */
 
105
  ~Gps_polygon_simplifier()
 
106
  {
 
107
    if (m_own_traits && (m_traits != NULL)) {
 
108
      delete m_traits;
 
109
      m_traits = NULL;
 
110
    }
 
111
  }
 
112
 
102
113
  void simplify(const Polygon_2& pgn)
103
114
  {
104
 
    Construct_curves_2 ctr_curves = 
 
115
    Construct_curves_2 ctr_curves =
105
116
      reinterpret_cast<Traits_2*>(m_traits)->construct_curves_2_object();
106
 
    
 
117
 
107
118
    std::list<Meta_X_monotone_curve_2> curves_list;
108
119
 
109
120
    std::pair<Curve_const_iterator,
118
129
      curves_list.push_back(Meta_X_monotone_curve_2(*itr, cv_data));
119
130
    }
120
131
    m_traits->set_polygon_size(static_cast<unsigned int>(curves_list.size()));
121
 
   
 
132
 
122
133
    m_sweep_line.sweep(curves_list.begin(), curves_list.end());
123
134
 
124
135
    // we use the first face with out outer ccbs. This assumpsion should
129
140
      if (it->number_of_outer_ccbs() == 0)
130
141
        break;
131
142
    CGAL_assertion(it != m_arr->faces_end());
132
 
   
133
 
    m_faces_hash[it] = 0; 
 
143
 
 
144
    m_faces_hash[it] = 0;
134
145
    Bfs_visitor visitor(&m_edges_hash, &m_faces_hash, 1);
135
146
    visitor.visit_ubf(it, 0);
136
147
    Bfs_scanner scanner(visitor);