mirror of https://github.com/CGAL/cgal
improve example
This commit is contained in:
parent
1979820571
commit
fe8fd2ba4a
|
|
@ -39,9 +39,34 @@ int main()
|
||||||
|
|
||||||
{
|
{
|
||||||
std::cout << "all vertices " << std::endl;
|
std::cout << "all vertices " << std::endl;
|
||||||
|
|
||||||
|
// The vertex iterator type is a nested type of the Vertex_range
|
||||||
|
Mesh::Vertex_range::iterator vb, ve;
|
||||||
|
|
||||||
|
Mesh::Vertex_range r = m.vertices();
|
||||||
|
// The iterators can be accessed through the C++ range API
|
||||||
|
vb = r.begin();
|
||||||
|
ve = r.end();
|
||||||
|
// or the boost Range API
|
||||||
|
vb = boost::begin(r);
|
||||||
|
ve = boost::end(r);
|
||||||
|
|
||||||
|
// or with boost::tie, as the CGAL range derives from std::pair
|
||||||
|
for(boost::tie(vb, ve) = m.vertices(); vb != ve; ++vb){
|
||||||
|
std::cout << *vb << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Instead of the classical for loop one can use
|
||||||
|
// the boost macro for a range
|
||||||
BOOST_FOREACH(vertex_descriptor vd, m.vertices()){
|
BOOST_FOREACH(vertex_descriptor vd, m.vertices()){
|
||||||
std::cout << vd << std::endl;
|
std::cout << vd << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// or the C+11 for loop. Note that there is a ':' and not a ',' as in BOOST_FOREACH
|
||||||
|
for(vertex_descriptor vd : m.vertices()){
|
||||||
|
std::cout << vd << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue