turns iterator pairs into iterable ranges

This commit is contained in:
Sébastien Loriot 2019-03-19 23:21:45 +01:00
parent 6d9b0e4260
commit 0ce7fc09b5
18 changed files with 39 additions and 40 deletions

View File

@ -63,7 +63,7 @@ int main(int argc, char* argv[])
std::cout << "edges of the finite dual graph" << std::endl;
for(boost::graph_traits<FiniteDual>::edge_descriptor e : edges(finite_dual)) {
for(boost::graph_traits<FiniteDual>::edge_descriptor e : CGAL::make_range(edges(finite_dual))) {
std::cout << e << " " << source(e,primal) << " " << source(e,finite_dual) << std::endl;
}

View File

@ -29,6 +29,7 @@
#include <boost/graph/adjacency_list.hpp>
#include <CGAL/assertions.h>
#include <CGAL/tags.h>
#include <CGAL/Iterator_range.h>
namespace CGAL {
@ -185,12 +186,12 @@ void duplicate_terminal_vertices(Graph& graph,
// check all vertices are of degree 1 or 2 and that the source
// and target of each edge are different vertices with different ids
CGAL_assertion_code(
for(vertex_descriptor v : vertices(graph)){
for(vertex_descriptor v : make_range(vertices(graph))){
typename boost::graph_traits<Graph>::degree_size_type
n = degree(v, graph);
CGAL_assertion( n == 0 || n == 1 || n == 2);
}
for(edge_descriptor e : edges(graph)){
for(edge_descriptor e : make_range(edges(graph))){
vertex_descriptor v = target(e, graph);
vertex_descriptor w = source(e, graph);
CGAL_assertion(v != w);
@ -266,13 +267,13 @@ split_graph_into_polylines(const Graph& graph,
typename graph_traits<G_copy>::vertex_descriptor> V2vmap;
V2vmap v2vmap;
for(Graph_vertex_descriptor v : vertices(graph)){
for(Graph_vertex_descriptor v : make_range(vertices(graph))){
vertex_descriptor vc = add_vertex(g_copy);
g_copy[vc] = v;
v2vmap[v] = vc;
}
for(Graph_edge_descriptor e : edges(graph)){
for(Graph_edge_descriptor e : make_range(edges(graph))){
Graph_vertex_descriptor vs = source(e,graph);
Graph_vertex_descriptor vt = target(e,graph);
CGAL_warning_msg(vs != vt, "ignore self loops");
@ -293,7 +294,7 @@ split_graph_into_polylines(const Graph& graph,
G_copy_less g_copy_less(g_copy, less);
std::set<vertex_descriptor, G_copy_less> terminal(g_copy_less);
for(vertex_descriptor v : vertices(g_copy)){
for(vertex_descriptor v : make_range(vertices(g_copy))){
typename graph_traits<G_copy>::degree_size_type n = degree(v, g_copy);
if ( n == 1 ) terminal.insert(v);
if ( n ==0 ){

View File

@ -3623,8 +3623,7 @@ try_lock_and_get_incident_cells(const Vertex_handle& v,
if (!try_lock_element(next)) // LOCK
{
for(Cell_handle& ch :
std::make_pair(cells.begin(), cells.end()))
for(Cell_handle ch : cells)
{
ch->tds_data().clear();
}
@ -3640,7 +3639,7 @@ try_lock_and_get_incident_cells(const Vertex_handle& v,
}
++head;
} while(head != tail);
for(Cell_handle& ch : std::make_pair(cells.begin(), cells.end()))
for(Cell_handle ch : cells)
{
ch->tds_data().clear();
}
@ -3660,8 +3659,7 @@ try_lock_and_get_incident_cells(const Vertex_handle& v,
bool ret = try_lock_and_get_incident_cells(v, tmp_cells);
if (ret)
{
for(Cell_handle& ch :
std::make_pair(tmp_cells.begin(), tmp_cells.end()))
for(Cell_handle ch : tmp_cells)
{
if (filter(ch))
cells.push_back(ch);

View File

@ -368,7 +368,7 @@ void snap_graph_vertices(Graph& graph,
if(tree.size() == 0) return;
for(typename boost::graph_traits<Graph>::vertex_descriptor v :
vertices(graph))
make_range(vertices(graph)))
{
const typename K::Point_3 p = graph[v].point;
NN_search nn(tree, p);

View File

@ -965,7 +965,7 @@ add_featured_edges_to_graph(const Polyhedron_type& p,
typedef typename boost::property_map<Polyhedron,vertex_point_t>::const_type Vpm;
Vpm vpm = get(vertex_point, p);
for(Graph_vertex_descriptor v : vertices(graph)){
for(Graph_vertex_descriptor v : make_range(vertices(graph))){
vertex_descriptor vc;
typename P2vmap::iterator it = p2vmap.find(get(vpm,v));
if(it == p2vmap.end()) {
@ -978,7 +978,7 @@ add_featured_edges_to_graph(const Polyhedron_type& p,
typedef typename boost::property_map<Polyhedron,face_patch_id_t<P_id> >::type Face_patch_id_pmap;
Face_patch_id_pmap fpm = get(face_patch_id_t<P_id>(),p);
for(Graph_edge_descriptor e : edges(graph)){
for(Graph_edge_descriptor e : make_range(edges(graph))){
vertex_descriptor vs = p2vmap[get(vpm,source(e,graph))];
vertex_descriptor vt = p2vmap[get(vpm,target(e,graph))];
CGAL_warning_msg(vs != vt, "ignore self loop");

View File

@ -455,7 +455,7 @@ add_featured_edges_to_graph(const Polyhedron& p,
typedef typename boost::property_map<Polyhedron,vertex_point_t>::const_type Vpm;
Vpm vpm = get(vertex_point, p);
for(Graph_vertex_descriptor v : vertices(graph)){
for(Graph_vertex_descriptor v : make_range(vertices(graph))){
vertex_descriptor vc;
typename P2vmap::iterator it = p2vmap.find(get(vpm,v));
if(it == p2vmap.end()) {
@ -468,7 +468,7 @@ add_featured_edges_to_graph(const Polyhedron& p,
typedef typename boost::property_map<Polyhedron,face_patch_id_t<Tag_> >::type Face_patch_id_pmap;
Face_patch_id_pmap fpm = get(face_patch_id_t<Tag_>(),p);
for(Graph_edge_descriptor e : edges(graph)){
for(Graph_edge_descriptor e : make_range(edges(graph))){
vertex_descriptor vs = p2vmap[get(vpm,source(e,graph))];
vertex_descriptor vt = p2vmap[get(vpm,target(e,graph))];
CGAL_warning_msg(vs != vt, "ignore self loop");

View File

@ -384,7 +384,7 @@ void Polyhedron_demo_mean_curvature_flow_skeleton_plugin::on_actionSegment()
boost::property_map<Face_graph,CGAL::vertex_point_t>::type vpm
= get(CGAL::vertex_point,*smesh);
for(boost::graph_traits<Skeleton>::vertex_descriptor v : vertices(item->skeleton_curve) )
for(boost::graph_traits<Skeleton>::vertex_descriptor v : CGAL::make_range(vertices(item->skeleton_curve)) )
{
const Point& skel_pt = item->skeleton_curve[v].point;
for(vertex_descriptor mesh_v : item->skeleton_curve[v].vertices)

View File

@ -1686,7 +1686,7 @@ private:
boost::predecessor_map(&pred[0]).weight_map(local_eweight_map));
// backtrack to the anchor and tag each vertex in the local patch graph
for(sg_vertex_descriptor v : vertices(glocal)) {
for(sg_vertex_descriptor v : make_range(vertices(glocal))) {
// skip the added super source vertex in the patch
if (v == source)
continue;

View File

@ -52,7 +52,7 @@ int main()
// Output all the edges of the skeleton.
std::ofstream output("skel-lcc.cgal");
for(Skeleton_edge e : edges(skeleton))
for(Skeleton_edge e : CGAL::make_range(edges(skeleton)))
{
const Point& s = skeleton[source(e, skeleton)].point;
const Point& t = skeleton[target(e, skeleton)].point;
@ -62,7 +62,7 @@ int main()
// Output skeleton points and the corresponding surface points
output.open("correspondance-lcc.cgal");
for(Skeleton_vertex v : vertices(skeleton))
for(Skeleton_vertex v : CGAL::make_range(vertices(skeleton)))
for(vertex_descriptor vd : skeleton[v].vertices)
output << "2 " << skeleton[v].point << " " << get(CGAL::vertex_point, lcc, vd) << "\n";

View File

@ -56,7 +56,7 @@ int main(int argc, char* argv[])
// Output all the edges of the skeleton.
std::ofstream output("skel-poly.cgal");
for(Skeleton_edge e : edges(skeleton))
for(Skeleton_edge e : CGAL::make_range(edges(skeleton)))
{
const Point& s = skeleton[source(e, skeleton)].point;
const Point& t = skeleton[target(e, skeleton)].point;
@ -66,7 +66,7 @@ int main(int argc, char* argv[])
// Output skeleton points and the corresponding surface points
output.open("correspondance-poly.cgal");
for(Skeleton_vertex v : vertices(skeleton))
for(Skeleton_vertex v : CGAL::make_range(vertices(skeleton)))
for(vertex_descriptor vd : skeleton[v].vertices)
output << "2 " << skeleton[v].point << " " << get(CGAL::vertex_point, tmesh, vd) << "\n";

View File

@ -55,7 +55,7 @@ int main(int argc, char* argv[])
// Output all the edges of the skeleton.
std::ofstream output("skel-sm.cgal");
for(Skeleton_edge e : edges(skeleton))
for(Skeleton_edge e : CGAL::make_range(edges(skeleton)))
{
const Point& s = skeleton[source(e, skeleton)].point;
const Point& t = skeleton[target(e, skeleton)].point;
@ -65,7 +65,7 @@ int main(int argc, char* argv[])
// Output skeleton points and the corresponding surface points
output.open("correspondance-sm.cgal");
for(Skeleton_vertex v : vertices(skeleton))
for(Skeleton_vertex v : CGAL::make_range(vertices(skeleton)))
for(vertex_descriptor vd : skeleton[v].vertices)
output << "2 " << skeleton[v].point << " " << get(CGAL::vertex_point, tmesh, vd) << "\n";

View File

@ -62,7 +62,7 @@ int main(int argc, char* argv[])
//for each input vertex compute its distance to the skeleton
std::vector<double> distances(num_vertices(tmesh));
for(Skeleton_vertex v : vertices(skeleton) )
for(Skeleton_vertex v : CGAL::make_range(vertices(skeleton)) )
{
const Point& skel_pt = skeleton[v].point;
for(vertex_descriptor mesh_v : skeleton[v].vertices)

View File

@ -67,7 +67,7 @@ int main()
// Output skeleton points and the corresponding surface points
output.open("correspondance-lcc.cgal");
for(Skeleton_vertex v : vertices(skeleton))
for(Skeleton_vertex v : CGAL::make_range(vertices(skeleton)))
for(vertex_descriptor vd : skeleton[v].vertices)
output << "2 " << skeleton[v].point << " "
<< get(CGAL::vertex_point, lcc, vd) << "\n";

View File

@ -70,7 +70,7 @@ int main(int argc, char* argv[])
// Output skeleton points and the corresponding surface points
output.open("correspondance-poly.cgal");
for(Skeleton_vertex v : vertices(skeleton))
for(Skeleton_vertex v : CGAL::make_range(vertices(skeleton)))
for(vertex_descriptor vd : skeleton[v].vertices)
output << "2 " << skeleton[v].point << " "
<< get(CGAL::vertex_point, tmesh, vd) << "\n";

View File

@ -39,7 +39,7 @@ int main(int argc, char* argv[])
// Output all the edges of the skeleton.
std::ofstream output("skel-sm.cgal");
for(Skeleton_edge e : edges(skeleton))
for(Skeleton_edge e : CGAL::make_range(edges(skeleton)))
{
const Point& s = skeleton[source(e, skeleton)].point;
const Point& t = skeleton[target(e, skeleton)].point;
@ -49,7 +49,7 @@ int main(int argc, char* argv[])
// Output skeleton points and the corresponding surface points
output.open("correspondance-sm.cgal");
for(Skeleton_vertex v : vertices(skeleton))
for(Skeleton_vertex v : CGAL::make_range(vertices(skeleton)))
for(vertex_descriptor vd : skeleton[v].vertices)
output << "2 " << skeleton[v].point << " " << get(CGAL::vertex_point, tmesh, vd) << "\n";

View File

@ -78,7 +78,7 @@ int main()
// check all vertices are seen exactly once
{
std::set<vertex_descriptor> visited;
for(vertex_desc v : vertices(skeleton))
for(vertex_desc v : CGAL::make_range(vertices(skeleton)))
{
for(vertex_descriptor vd : skeleton[v].vertices)
if (!visited.insert(vd).second)
@ -111,7 +111,7 @@ int main()
vertex_desc cur = qu.front();
qu.pop();
for(edge_desc ed : in_edges(cur, skeleton))
for(edge_desc ed : CGAL::make_range(in_edges(cur, skeleton)))
{
vertex_desc next = source(ed, skeleton);
if (visited.insert(next).second)
@ -119,7 +119,7 @@ int main()
}
}
for(vertex_desc vd : vertices(skeleton))
for(vertex_desc vd : CGAL::make_range(vertices(skeleton)))
{
if (!visited.count(vd))
{

View File

@ -934,8 +934,8 @@ void Volume::display_surface_mesher_result()
points_out.precision(18);
points_out << "OFF\n" << c2t3.triangulation().number_of_vertices() << " 0 0\n";
for(const Tr::Vertex& v :
std::make_pair(c2t3.triangulation().vertices_begin(),
c2t3.triangulation().vertices_end()))
CGAL::make_range(c2t3.triangulation().vertices_begin(),
c2t3.triangulation().vertices_end()))
{
points_out << v.point() << std::endl;
}

View File

@ -1859,7 +1859,7 @@ public:
Cell_handle next = c->neighbor(i);
if(!this->try_lock_cell(next)) // LOCK
{
for(Cell_handle& ch : std::make_pair(cells.begin(), cells.end()))
for(Cell_handle ch : cells)
{
ch->tds_data().clear();
}
@ -1878,7 +1878,7 @@ public:
}
while(head != tail);
for(Cell_handle& ch : std::make_pair(cells.begin(), cells.end()))
for(Cell_handle ch : cells)
{
ch->tds_data().clear();
}
@ -1914,7 +1914,7 @@ public:
Cell_handle next = c->neighbor(i);
if(!this->try_lock_cell(next)) // LOCK
{
for(Cell_handle& ch : std::make_pair(cells.begin(), cells.end()))
for(Cell_handle ch : cells)
{
ch->tds_data().clear();
}
@ -1933,7 +1933,7 @@ public:
while(head != tail);
std::set<Vertex_handle> tmp_vertices;
for(Cell_handle& ch : std::make_pair(cells.begin(), cells.end()))
for(Cell_handle ch : cells)
{
ch->tds_data().clear();
for(int i = 0; i < 4; ++i)
@ -3636,12 +3636,12 @@ insert_in_conflict(const Point& p,
if(*could_lock_zone == false)
{
for(Cell_handle ch : std::make_pair(cells.begin(), cells.end()))
for(Cell_handle ch : cells)
{
ch->tds_data().clear();
}
for(Facet f : std::make_pair(facets.begin(), facets.end()))
for(Facet& f : facets)
{
f.first->neighbor(f.second)->tds_data().clear();
}