add documentation

This commit is contained in:
Sébastien Loriot 2024-03-25 10:18:34 +01:00
parent a54e024a32
commit f3c9181718
2 changed files with 13 additions and 4 deletions

View File

@ -510,11 +510,12 @@ Dynamic property tags, such as `dynamic_vertex_property_t`, are a generalization
value type of the dynamic property map, and a default value.
`boost::property_map<G,T>::%type` is used to obtain the
type of the dynamic property map for a graph of type `G`, for a
dynamic property tag `T`. This type must be default constructible and assignable.
dynamic property tag `T`. This type must be assignable, and if no
default is provided it must be default constructible.
As for ordinary properties, the function `%get()` is overloaded and
serves for retrieving a property map for a given graph and dynamic
property tag, as well as for retrieving a value for a given key and
property map.
property map. The default value is provided as third parameter.
The following example shows how to attach a `string` property to vertices and
a `double` value to the halfedges of a graph.

View File

@ -14,16 +14,24 @@ int main()
CGAL::make_triangle(Point_3(0,0,0),Point_3(1,0,0),Point_3(1,1,0), mesh);
typedef boost::property_map<Mesh, CGAL::dynamic_vertex_property_t<std::string> >::type VertexNameMap;
VertexNameMap vnm = get(CGAL::dynamic_vertex_property_t<std::string>(), mesh);
VertexNameMap vnm = get(CGAL::dynamic_vertex_property_t<std::string>(), mesh, std::string("default"));
put(vnm, *(vertices(mesh).first), "Paris");
assert(get(vnm, *(vertices(mesh).first))=="Paris");
assert(get(vnm, *(std::next(vertices(mesh).first)))=="default");
std::cout << get(vnm, *(vertices(mesh).first)) << std::endl;
std::cout << get(vnm, *(std::next(vertices(mesh).first))) << std::endl;
typedef boost::property_map<Mesh, CGAL::dynamic_halfedge_property_t<double> >::type TrafficDensityMap;
TrafficDensityMap tdm = get(CGAL::dynamic_halfedge_property_t<double>(), mesh);
TrafficDensityMap tdm = get(CGAL::dynamic_halfedge_property_t<double>(), mesh, -1.);
put(tdm, *(halfedges(mesh).first), 0.7);
assert(get(tdm, *(halfedges(mesh).first))==0.7);
assert(get(tdm, *(std::next(halfedges(mesh).first)))==-1.);
std::cout << get(tdm, *(halfedges(mesh).first)) << std::endl;
std::cout << get(tdm, *(std::next(halfedges(mesh).first))) << std::endl;
return 0;
}