CGAL 6.1 - CGAL and the Boost Graph Library

Loading...
Searching...
No Matches
Named Parameters
Reference Manual

The algorithms of the Boost Graph Library (BGL) often have many parameters with default values that are appropriate for most cases.

In general, when no special treatment is applied, the values of such parameters are passed as a sequence. Deviating from the default for a certain parameter requires the user to explicitly pass values for all preceding parameters. The solution to this problem is to first write a tag and then the parameter, which for Dijkstra's shortest path algorithm might look as follows:

std::vector<vertex_descriptor> p(num_vertices(g));
std::vector<int> d(num_vertices(g));
vertex_descriptor s = vertex(A, g);
dijkstra_shortest_paths(g, s, predecessor_map(&p[0]).distance_map(&d[0]));

In the BGL manual, this is called named parameters. The named parameters in the snippet use the tags `predecessor_map` and `distance_map` and they are concatenated using the dot operator.

A similar mechanism was introduced in CGAL, with the small difference that the named parameters tag live in the `CGAL::parameters::` namespace and `CGAL::parameters::default_values()` can be used to indicate that default values of optional named parameters must be used. As in the BGL, named parameters in CGAL are also concatenated using the dot operator, and a typical usage is thus:

Graph g1, g2;
Vertex_point_map_2 vpm_2; // an hypothetical custom property map assigning a Point to the vertices of g2
// without any named parameter (default values are used)
CGAL::copy_face_graph(g1, g2);
// specifying named parameters for the second graph
CGAL::copy_face_graph(g1, g2,
CGAL::parameters::vertex_point_map(vpm) //parameter for g1
.vertex_to_vertex_map(v2v), //other parameter for g1
CGAL::parameters::default_values()); //parameter for g2
CGAL::copy_face_graph
void copy_face_graph(const SourceMesh &sm, TargetMesh &tm, const NamedParameters1 &np1=parameters::default_values(), const NamedParameters2 &np2=parameters::default_values())
copies a source model of FaceListGraph into a target model of a FaceListGraph.
Definition: copy_face_graph.h:350
CGAL::parameters::default_values
Default_named_parameters default_values()