diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arrangement_2.h b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arrangement_2.h index 3aaca743d2e..277ddf71eca 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arrangement_2.h +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arrangement_2.h @@ -545,6 +545,10 @@ returning constant iterators instead of mutable ones. */ Vertex_iterator vertices_end(); + /*! + returns a range over handles of the arrangement vertices . + */ + unspecified_type vertex_handles(); /*! returns the number of arrangement vertices that lie at infinity and are not associated with valid points. Such vertices are not considered @@ -578,6 +582,11 @@ returning constant iterators instead of mutable ones. */ Halfedge_iterator halfedges_end(); + /*! + returns a range over handles of the arrangement halfedges . + */ + unspecified_type halfedge_handles(); + /*! returns the number of edges in the arrangement (equivalent to `arr.number_of_halfedges() / 2`). @@ -594,6 +603,10 @@ returning constant iterators instead of mutable ones. */ Edge_iterator edges_end(); + /*! + returns a range over handles of the arrangement edges . + */ + unspecified_type edge_handles(); /// @} @@ -627,6 +640,11 @@ returning constant iterators instead of mutable ones. */ Face_iterator faces_end(); + /*! + returns a range over handles of the arrangement faces . + */ + unspecified_type face_handles(); + /*! returns the number of unbounded faces in the arrangement. Note `arr.number_of_faces()` also counts the unbounded faces diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Concepts/ArrangementDcel.h b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Concepts/ArrangementDcel.h index 8f71879c3c2..3d891443d29 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Concepts/ArrangementDcel.h +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Concepts/ArrangementDcel.h @@ -163,6 +163,11 @@ returns a past-the-end iterator of the vertices in `dcel`. */ Vertex_iterator vertices_end(); +/*! +returns a range over handles of the vertices in `dcel`. +*/ +unspecified_type vertex_handles(); + /*! returns a begin-iterator of the vertices in `dcel`. */ @@ -173,6 +178,11 @@ returns a past-the-end iterator of the vertices in `dcel`. */ Vertex_const_iterator vertices_end() const; +/*! +returns a const range over handles of the vertices in `dcel`. +*/ +unspecified_type vertex_handles() const; + /*! returns a begin-iterator of the halfedges in `dcel`. */ @@ -183,6 +193,11 @@ returns a past-the-end iterator of the halfedges in `dcel`. */ Halfedge_iterator halfedges_end(); +/*! +returns a range over handles of the halfedges in `dcel`. +*/ +unspecified_type halfedge_handles(); + /*! returns a begin-iterator of the halfedges in `dcel`. */ @@ -193,6 +208,11 @@ returns a past-the-end iterator of the halfedges in `dcel`. */ Halfedge_const_iterator halfedges_end() const; +/*! +returns a cosnt range over handles of the halfedges in `dcel`. +*/ +unspecified_type halfedge_handles() const; + /*! returns a begin-iterator of the faces in `dcel`. */ @@ -203,6 +223,11 @@ returns a past-the-end iterator of the faces in `dcel`. */ Face_iterator faces_end(); +/*! +returns a range over handles of the faces in `dcel`. +*/ +unspecified_type faces_handles(); + /*! returns a begin-iterator of the faces in `dcel`. */ @@ -213,6 +238,10 @@ returns a past-the-end iterator of the faces in `dcel`. */ Face_const_iterator faces_end() const; +/*! +returns a const range over handles of the faces in `dcel`. +*/ +unspecified_type faces_handles() const; /// @} diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_dcel_base.h b/Arrangement_on_surface_2/include/CGAL/Arr_dcel_base.h index 6cc5a191bcb..d4c275a814f 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_dcel_base.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_dcel_base.h @@ -1011,24 +1011,64 @@ public: //@{ Vertex_iterator vertices_begin() { return vertices.begin(); } Vertex_iterator vertices_end() { return vertices.end(); } + Iterator_range > + vertex_handles() + { + return make_prevent_deref_range(vertices_begin(), vertices_end()); + } Halfedge_iterator halfedges_begin() { return halfedges.begin();} Halfedge_iterator halfedges_end() { return halfedges.end(); } + Iterator_range > + halfegde_handles() + { + return make_prevent_deref_range(halfedges_begin(), halfedges_end()); + } Face_iterator faces_begin() { return faces.begin(); } Face_iterator faces_end() { return faces.end(); } + Iterator_range > + face_handles() + { + return make_prevent_deref_range(faces_begin(), faces_end()); + } Edge_iterator edges_begin() { return halfedges.begin(); } Edge_iterator edges_end() { return halfedges.end(); } + Iterator_range > + edge_handles() + { + return make_prevent_deref_range(edges_begin(), edges_end()); + } //@} /// \name Obtaining constant iterators. //@{ Vertex_const_iterator vertices_begin() const { return vertices.begin(); } Vertex_const_iterator vertices_end() const { return vertices.end(); } + Iterator_range > + vertex_handles() const + { + return make_prevent_deref_range(vertices_begin(), vertices_end()); + } Halfedge_const_iterator halfedges_begin() const { return halfedges.begin(); } Halfedge_const_iterator halfedges_end() const { return halfedges.end(); } + Iterator_range > + halfegde_handles() const + { + return make_prevent_deref_range(halfedges_begin(), halfedges_end()); + } Face_const_iterator faces_begin() const { return faces.begin(); } Face_const_iterator faces_end() const { return faces.end(); } + Iterator_range > + face_handles() const + { + return make_prevent_deref_range(faces_begin(), faces_end()); + } Edge_const_iterator edges_begin() const { return halfedges.begin(); } Edge_const_iterator edges_end() const { return halfedges.end(); } + Iterator_range > + edge_handles() const + { + return make_prevent_deref_range(edges_begin(), edges_end()); + } //@} // \name Creation of new DCEL features. diff --git a/Arrangement_on_surface_2/include/CGAL/Arrangement_on_surface_2.h b/Arrangement_on_surface_2/include/CGAL/Arrangement_on_surface_2.h index 30c2c63feb0..cf72ea2978e 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arrangement_on_surface_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arrangement_on_surface_2.h @@ -1024,6 +1024,15 @@ public: _Is_concrete_vertex(&m_topol_traits))); } + /*! + returns a range over handles of the arrangement vertices . + */ + Iterator_range > + vertex_handles() + { + return make_prevent_deref_range(vertices_begin(), vertices_end()); + } + /*! Get a const iterator for the first vertex in the arrangement. */ Vertex_const_iterator vertices_begin() const { @@ -1039,6 +1048,16 @@ public: _dcel().vertices_end(), _Is_concrete_vertex(&m_topol_traits))); } + + /*! + returns a const range over handles of the arrangement vertices . + */ + Iterator_range > + vertex_handles() const + { + return make_prevent_deref_range(vertices_begin(), vertices_end()); + } + //@} /// \name Traversal functions for the arrangement halfedges. @@ -1060,6 +1079,15 @@ public: _Is_valid_halfedge(&m_topol_traits))); } + /*! + returns a range over handles of the arrangement halfedges . + */ + Iterator_range > + halfedge_handles() + { + return make_prevent_deref_range(halfedges_begin(), halfedges_end()); + } + /*! Get a const iterator for the first halfedge in the arrangement. */ Halfedge_const_iterator halfedges_begin() const { @@ -1075,6 +1103,14 @@ public: _dcel().halfedges_end(), _Is_valid_halfedge(&m_topol_traits))); } + /*! + returns a const range over handles of the arrangement halfedges . + */ + Iterator_range > + halfedge_handles() const + { + return make_prevent_deref_range(halfedges_begin(), halfedges_end()); + } //@} /// \name Traversal functions for the arrangement edges. @@ -1094,6 +1130,15 @@ public: _Is_valid_halfedge(&m_topol_traits))); } + /*! + returns a range over handles of the arrangement edges . + */ + Iterator_range > + edge_handles() + { + return make_prevent_deref_range(edges_begin(), edges_end()); + } + /*! Get a const iterator for the first edge in the arrangement. */ Edge_const_iterator edges_begin() const { @@ -1107,6 +1152,15 @@ public: return (Edge_const_iterator(_dcel().edges_end(), _dcel().edges_end(), _Is_valid_halfedge(&m_topol_traits))); } + + /*! + returns a const range over handles of the arrangement edges . + */ + Iterator_range > + edge_handles() const + { + return make_prevent_deref_range(edges_begin(), edges_end()); + } //@} /// \name Traversal functions for the arrangement faces. @@ -1126,6 +1180,14 @@ public: _Is_valid_face(&m_topol_traits))); } + /*! + returns a range over handles of the arrangement faces . + */ + Iterator_range > + face_handles() + { + return make_prevent_deref_range(faces_begin(), faces_end()); + } /*! Get a const iterator for the first face in the arrangement. */ Face_const_iterator faces_begin() const { @@ -1140,6 +1202,14 @@ public: _Is_valid_face(&m_topol_traits))); } + /*! + returns a const range over handles of the arrangement faces . + */ + Iterator_range > + face_handles() const + { + return make_prevent_deref_range(faces_begin(), f_end()); + } //! reference_face (const version). /*! The function returns a reference face of the arrangement. * All reference faces of arrangements of the same type have a common diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_spherical_removal.cpp b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_spherical_removal.cpp index f686c747842..8019eff7ae0 100644 --- a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_spherical_removal.cpp +++ b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_spherical_removal.cpp @@ -85,9 +85,8 @@ bool test_one_file(std::ifstream& in_file, bool /* verbose */) std::cout.flush(); CGAL::insert_non_intersecting_curves(arr, xcurves.begin(), xcurves.end()); std::cout << "inserted" << std::endl; - for (Halfedge_iterator hit = arr.halfedges_begin(); hit != arr.halfedges_end(); hit++) { - halfedges.push_back(hit); - } + BOOST_FOREACH(Halfedge_handle hh, arr.halfedge_handles()) + halfedges.push_back(hh); #endif curves.clear(); @@ -102,7 +101,6 @@ bool test_one_file(std::ifstream& in_file, bool /* verbose */) } isolated_points.clear(); points.clear(); - std::cout << "The arrangement size:" << std::endl << " V = " << arr.number_of_vertices() << ", E = " << arr.number_of_edges() @@ -110,16 +108,16 @@ bool test_one_file(std::ifstream& in_file, bool /* verbose */) { std::cout << "Faces:" << std::endl; - Arrangement_2::Face_const_iterator fit; - for (fit = arr.faces_begin(); fit != arr.faces_end(); ++fit) { + BOOST_FOREACH(Arrangement_2::Face_handle fh, arr.face_handles()) + { std::cout << " Face: " - << &(*fit) + << &(fh) << std::endl; std::cout << " Outer CCBs: " - << std::distance(fit->outer_ccbs_begin(), fit->outer_ccbs_end()) + << std::distance(fh->outer_ccbs_begin(), fh->outer_ccbs_end()) << std::endl; std::cout << " Inner CCBs: " - << std::distance(fit->inner_ccbs_begin(), fit->inner_ccbs_end()) + << std::distance(fh->inner_ccbs_begin(), fh->inner_ccbs_end()) << std::endl; std::cout << std::endl; }