Skip to content

Instantly share code, notes, and snippets.

@afabri
Created June 8, 2015 14:07
Show Gist options
  • Save afabri/6a77a8d8a3f4ddd18aba to your computer and use it in GitHub Desktop.
Save afabri/6a77a8d8a3f4ddd18aba to your computer and use it in GitHub Desktop.
An Ersatz for Surface_mesh<P>::Point_iterator
#include <vector>
#include <boost/foreach.hpp>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/centroid.h>
typedef CGAL::Simple_cartesian<double> K;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
typedef Mesh::Vertex_index vertex_descriptor;
template <class SM>
struct V2P {
typedef K::Point_3 result_type;
const SM& sm;
V2P(SM& sm)
: sm(sm)
{}
const typename K::Point_3& operator()(typename SM::Vertex_index v) const
{
return sm.point(v);
}
};
int main()
{
Mesh m;
typedef boost::transform_iterator<V2P<Mesh>,Mesh::Vertex_iterator> Point_iterator;
V2P<Mesh> v2p(m);
Point_iterator b = boost::make_transform_iterator(m.vertices().begin(),v2p);
Point_iterator e = boost::make_transform_iterator(m.vertices().end(),v2p);
CGAL::centroid(b,e);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment